Alu, processor, chip, device and texel index calculation method

By inputting the integer and fractional parts of the texture coordinates into different computational units for calculation, the problem of large bit width of the computational unit in the conversion from texture coordinates to texel indexes is solved, thereby reducing computational efficiency and power consumption.

CN120894223BActive Publication Date: 2026-01-27MOORE THREADS TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511431361.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-09
Publication Date
2026-01-27
Estimated Expiration
2045-10-09

AI Technical Summary

Technical Problem

In existing technologies, the conversion from texture coordinates to texel indices requires a large bit width of the computational unit, resulting in complex physical implementation, large area, long latency, and high power consumption, making it difficult to meet the requirements.

Method used

The integer and fractional parts of the input texture coordinates are input into different computation units for calculation. Multipliers, dividers, adders, and texel adjustment units are used to process the integer and fractional parts respectively, thereby reducing the bit width of the computation unit.

Benefits of technology

This effectively reduces the bit width of the computing unit, lowers the complexity of physical implementation, improves computing efficiency, and reduces power consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120894223B_ABST
    Figure CN120894223B_ABST
Patent Text Reader

Abstract

The application discloses an ALU, a processor, a chip, a device and a texel index calculation method, and belongs to the chip technical field. The ALU comprises a multiplier, a first divider, a first adder, a second adder and a texel adjustment unit. The multiplier is used for calculating the product of the decimal part of input texture coordinates and the texture size to obtain a first value. The first divider is used for calculating the first ratio between the input offset and the second value. The first adder is used for determining the first calculation result according to the integer part of the input texture coordinates and the first ratio. The second adder is used for determining the second calculation result according to the first value and the first ratio. The texel adjustment unit is used for determining the texel index corresponding to the input texture coordinates according to the first calculation result and the second calculation result. According to the above method, only part of the data of the input texture coordinates needs to be calculated in a single calculation unit, the bit width of the calculation unit is effectively reduced, and the complexity of the physical implementation of the calculation unit is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of chip technology, and in particular to an ALU (Arithmetic Logic Unit), processor, chip, device, and texel index calculation method. Background Technology

[0002] Texture coordinates are a coordinate system in computer graphics used to locate the mapping of textures on the surface of an object. The coordinates indicate from which position in the texture image the object's vertices should read data. The texel index is used to precisely locate texels within the texture image.

[0003] In related technologies, the conversion from texture coordinates to texel indices is typically implemented in the Texture Processing Unit (TPU) of the Texture Coordinate ALU. The general calculation formula is: texel_index = input_coord * texture size + offset, where input_coord is the input texture coordinate in floating-point format, texture size is the texture size, and offset is the configured or calculated offset, which typically includes sampling offset, coordinate offset, pixel offset, etc. Offset is usually a series of non-normalized fixed-point numbers. The output texel index is in signed fixed-point format.

[0004] The above calculation process involves data format conversion and alignment, along with precision calculation and rounding. The calculation units used, such as adders, multipliers, and dividers, have relatively large bit widths, making their physical implementation complex. Summary of the Invention

[0005] This application provides an ALU, processor, chip, device, and texel index calculation method. The technical solution provided by this application is as follows:

[0006] According to one aspect of the embodiments of this application, an ALU is provided, the ALU comprising: a multiplier, a first divider, a first adder, a second adder, and a texel adjustment unit;

[0007] The multiplier is used to calculate the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, wherein the texture size is used to indicate the size of the texture image;

[0008] The first divider is used to calculate a first ratio between an input offset and a second value, the input offset being used to indicate the offset of a texel relative to at least one texture image, and the second value being determined based on the texture size;

[0009] The first adder is used to determine a first calculation result based on the integer part of the input texture coordinates and the first ratio;

[0010] The second adder is used to determine a second calculation result based on the first value and the first ratio;

[0011] The texel adjustment unit is used to determine the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

[0012] According to one aspect of the embodiments of this application, a processor is provided, the processor including the ALU described above.

[0013] According to one aspect of the embodiments of this application, a chip product is provided, the chip product including a processor, the processor including the above-described ALU.

[0014] According to one aspect of the embodiments of this application, a computer device is provided, the computer device including a processor, the processor including the ALU described above.

[0015] According to one aspect of the embodiments of this application, a texel index calculation method applied to an ALU is provided, wherein the ALU includes: a multiplier, a first divider, a first adder, a second adder, and a texel adjustment unit; the method includes:

[0016] The multiplier calculates the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, whereby the texture size is used to indicate the size of the texture image;

[0017] The first divider calculates a first ratio between an input offset and a second value, the input offset being used to indicate the offset of a texel relative to at least one texture image, and the second value being determined based on the texture size;

[0018] The first adder determines the first calculation result based on the integer part of the input texture coordinates and the first ratio;

[0019] The second adder determines the second calculation result based on the first value and the first ratio;

[0020] The texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

[0021] The technical solutions provided in this application have at least the following beneficial effects:

[0022] For scenarios where input texture coordinates are converted into texel indices, the integer and fractional parts of the input texture coordinates are input into different computing units for computation. Compared to related technologies that input the integer and fractional parts of the input texture coordinates into a single computing unit for computation, this method allows a single computing unit to perform computations on only a portion of the input texture coordinate data. This effectively reduces the bit width of each computing unit and lowers the complexity of the physical implementation of the computing unit. Attached Figure Description

[0023] Figure 1 This is a schematic diagram of at least one texture image in one possible implementation of this application;

[0024] Figure 2 This is a schematic diagram of the ALU in one possible implementation of this application;

[0025] Figure 3 This is a schematic diagram of the ALU in another possible implementation of this application;

[0026] Figure 4 This is a flowchart of a texel index calculation method applied to the ALU in one possible implementation of this application. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0028] Before introducing and explaining the technical solution of this application, some concepts involved in this application will be defined and explained.

[0029] 1. TPU (Texture Processing Unit)

[0030] The TPU (Graphics Processing Unit) is a module within the GPU specifically responsible for texture mapping and processing. It can perform operations such as rotating, resizing, and distorting bitmap images to place them as textures on any plane of a given model, playing a crucial role in graphics processing. The texture coordinate ALU (Arithmetic Logic Unit) within the TPU is used to convert input texture coordinates into texel indices. The ALU includes different types of computation units, such as adders, multipliers, and dividers.

[0031] 2. Texture coordinates

[0032] Texture coordinates are a coordinate system used in computer graphics to locate the mapping of textures on the surface of an object. The coordinates indicate from which position of the object's vertices should read data from the texture image. For example, texture coordinates can be uv coordinates, where u and v correspond to the width and height directions of the texture, respectively. The value range of uv coordinates is usually [0, 1].

[0033] 3. Verb Index

[0034] A texel is the basic unit of a texture image; that is, a texture image is composed of multiple texels, equivalent to a pixel in an image. texel indexing is used to precisely locate texels in a texture image.

[0035] 4. Texture Type

[0036] Texture type refers to the type or format of texture data processed by the TPU, indicating the type of texture image and helping the GPU understand how to process and render this texture data. Texture types can include 1D (One-Dimensional), 2D (Two-Dimensional), 3D (Three-Dimensional), Cube, Buffer, etc. A 1D texture is a linear array of pixels or data; a 2D texture is a two-dimensional array of pixels or data used to represent an image; a 3D texture is a three-dimensional array of pixels or data, which can be viewed as a stack of multiple 2D textures; a Cube texture is the surface of a cube composed of six two-dimensional textures, each face representing a face of the cube; and a Buffer texture is a linear memory buffer used to store arbitrary data.

[0037] 5. Floating-point numbers

[0038] Floating-point numbers include fp32, which refers to a 32-bit single-precision floating-point number. It's a way of approximating real numbers in computers. The highest bit of fp32 is the sign bit (0 for positive, 1 for negative); the middle 8 bits represent the exponent, ranging from 0 to 255, corresponding to the actual exponent range of -126 to 127; the lower 23 bits represent the mantissa. The decimal value represented by an fp32 number can be calculated using the following expression: .

[0039] 6. Integers

[0040] Integers, also known as integers, are used to represent numerical values ​​without a decimal part. Integer values ​​can be positive, negative, or 0. They are divided into signed integers (signed int) and unsigned integers (unsigned int), and the range of values ​​depends on the actual number of bits. The highest bit of a signed int is used as the sign bit, with 0 representing a positive number and 1 representing a negative number. Unsigned int only represents non-negative integers. Because it has no sign bit, it can represent a larger range of positive numbers with the same number of bits.

[0041] 7. Fixed-point numbers (FXP)

[0042] Fixed-point numbers are a common numerical representation method used to represent decimals with a limited number of bits of storage. They typically consist of an integer part and a fractional part, and are commonly categorized as signed fixed-point numbers and unsigned fixed-point numbers. Unlike floating-point numbers, fixed-point numbers pre-determine the position of the decimal point during storage, making their operations generally faster and less resource-intensive than floating-point operations. However, because the decimal point position is fixed, their range and precision are limited, requiring greater care to control overflow risks during calculations.

[0043] 8. Address Mode

[0044] When a texture image is mapped onto a model surface, different addressing modes are used to define the mapping of texture coordinates (which can be represented by UV coordinates). Common addressing modes include repeat, mirror, pinch, and border color. For different addressing modes, the actual position of the texture image corresponding to the input UV coordinates is different; that is, different addressing modes output different texel indices based on the input UV coordinates.

[0045] The following example demonstrates the process of calculating the texel index corresponding to the input texture coordinate 4.25 in the u direction, using the repeat addressing mode, 2D texture type, input texture coordinates of 4.25, input offset of 12, and texture size of 8. The repeat addressing mode mentioned above means that when the texture coordinates exceed the range of the texture image, the excess coordinates are remapped to the starting point of the texture image, thus achieving the repeating effect. For detailed descriptions of other addressing modes, please see below. This may include steps 1 through 3 as follows:

[0046] Step 1: As shown in Formula 1 below, where u_conv_input_coord refers to the initial calculated value for converting texture coordinates into texel indices, and u_texture_size refers to the texture size in the u direction, such as... Figure 1As shown, the texture size is 8, and u_input_coord refers to the input texture coordinates in the u direction.

[0047] (Formula 1)

[0048] Step 2: As shown in Formula 2 below, where offset refers to the input offset and u_texel_index refers to the median value of the texel index in the u direction.

[0049] (Formula 2)

[0050] Step 3: As shown in Formula 3 below, the final texel index includes the quotient and the remainder. In this application, the quotient of the texel index is also called the integer of the texel index.

[0051] (Formula 3)

[0052] In some embodiments, the target texel indicated by the input texture coordinates can be determined based on the quotient and remainder of the texel index. The quotient (i.e., the integer) of the texel index is used to determine the target texture image from a plurality of texture images, where the target texture image refers to the texture image corresponding to the input texture coordinates. The remainder of the texel index is used to determine the target texel from a plurality of texels contained in the target texture image. For example, when the quotient of the texel index is 5 and the remainder is 6, such as... Figure 1 As shown, a quotient of 5 for the texel index indicates that the position of the texel in the texture image needs to move 5 texture images forward from the first texture image (i.e., texture image 1) in the positive direction of u, i.e., texture image 6. Therefore, the target texture image is texture image 6. A remainder of 6 for the texel index indicates that the specific texel position of the target texel in the determined texture image is the 7th texel in the positive direction of u, based on the current position of texture image 6. Therefore, the target texel is the 7th texel in texture image 6. It is understandable that to uniquely determine the texel position, it is also necessary to calculate the texel index corresponding to the input texture coordinates in the v direction. The specific calculation process can be found in steps 1-3 above.

[0053] In the process of calculating the quotient and remainder in steps 1 to 3 above, possible hardware implementation methods include, but are not limited to:

[0054] Method 1: Step 1: Use a floating-point multiplier to multiply u_input_coord (in fp32 format) with the integer u_texture_size. The result of the multiplication is still in fp32 format. Step 2: Convert offset from fixed-point format to fp32 format, and then calculate the floating-point addition between u_conv_input_coord and offset. Step 3: Use an fp32 divider to obtain the remainder. Then, perform overflow detection and rounding on the remainder to convert it to a fixed-point number in the specified format.

[0055] Method 2: Step 1: Convert the FP32 format `u_input_coord` to a fixed-point number, multiply it by the integer `u_texture_size`, and adjust the precision of the fixed-point result. Step 2: Adjust the `offset` fixed-point number to match the result calculated in Step 1, and then perform fixed-point addition. Step 3: Use a fixed-point divider to obtain the remainder, and perform overflow detection and rounding on the remainder, converting it to a fixed-point number in the specified format. Finally, Methods 1 and 2 check the quotient in Step 3 for out-of-bounds errors, and determine whether to further process the remainder before outputting it based on the parity of the quotient and the addressing mode.

[0056] For Methods 1 and 2, each step of the calculation involves different overflow and rounding judgments for input values ​​in different FP32 formats. The rounding mode needs to be configured, and the configuration result will affect the final calculation accuracy. Furthermore, for different addressing modes, the parity of the input texture coordinates also needs to be considered. Each step of the calculation involves data format conversion and alignment, accompanied by precision calculation and rounding. The bit widths of the adders, multipliers, and dividers used are relatively large, resulting in complex physical implementation and potentially requiring multiple output cycles. Therefore, existing solutions retain relatively large data bit widths in the conversion from texture coordinates to texel indices, and the data bit width determines the combinational logic complexity of the calculation unit. Large bit width calculation units often mean larger areas, longer computational latency, more difficult physical routing, and higher power consumption. Therefore, further research is needed on how to reduce the bit width of the calculation unit.

[0057] Before introducing the scheme of this application, the conversion formula from the above input texture coordinates to texel indices is analyzed as follows. As shown in Formula 4 below:

[0058] (Formula 4)

[0059] The aforementioned OUTPUT refers to the output texel index, including Q (Quotient) and R (Remainder), where the quotient of the texel index is also called the integer of the texel index. conv_input_coord refers to the preliminary calculated value for converting texture coordinates into texel indices, offset refers to the input offset, and texture_size refers to the texture size. It can be understood that when the texture type is 2D, the texture size can be the texture size in the u-direction or the texture size in the v-direction, where the texture size in the u-direction and the texture size in the v-direction can be the same or different. input_coord refers to the input texture coordinates. Similarly, when the texture type is 2D, the input texture coordinates can be the texture coordinates in the u-direction or the texture coordinates in the v-direction; this application does not impose any limitations on this. The `input_coord_integer_part` mentioned above refers to the integer part of the input texture coordinates, and `input_coord_decimal_part` refers to the decimal part. In other words, for any real number, the value to the left of the decimal point is the integer part, and the value to the right of the decimal point is the decimal part. For example, in the above example, if the input texture coordinates are 4.25, then the integer part of the input texture coordinates is 4, and the decimal part is 0.25.

[0060] Formula 4 above can be further divided into two parts, as shown in expressions A and B below:

[0061]

[0062]

[0063] in, It refers to the quotient of expression B. It is the remainder of expression B.

[0064] The expression A above can be further divided into two parts, as shown in expressions A1 and A2 below:

[0065]

[0066] in, It refers to the quotient of expression A1. It refers to the remainder of expression A1. It refers to the quotient of expression A2. It refers to the remainder of expression A2.

[0067] As shown above, the integer and remainder of the output texel index are expressed as follows: As shown:

[0068]

[0069] It is understandable that if R t0 >texture_size, at this point we need to calculate the integer and remainder of the texel index (i.e. Further adjustments will be made, that is, calculations will be performed. ,in, Indicates the quotient of the two. This represents the remainder between the two.

[0070] Arrange the integer and remainder of the output texel indices as shown in the following expressions Q and R:

[0071]

[0072] Simplifying the above expressions A1 and A2, it is easy to see that R A1 = 0, Q A1 = input_coord_integer_part,Q A2 =0、R A2 If input_coord_decimal_part is used, then the expression for the integer and remainder of the final output texel index is shown in Formula 5 below:

[0073] (Formula 5)

[0074] Regarding the above (Q) B R B In the division part, the various input offsets are typically fixed-point numbers with small bit widths, meaning that the divider consumes relatively few resources during division operations. Analyzing the above formula conversion process, we can see that the fractional part of the input texture coordinates affects the integer and remainder of the output texel index at different stages; the integer part of the input texture coordinates only affects the integer part of the output texel index. Therefore, this scheme calculates the integer and fractional parts of the input texture coordinates separately. On the one hand, each computation unit only needs to process a portion of the input texture coordinate data, thereby reducing the bit width requirement of a single computation unit. For example, for a certain adder, only the addition operation on the integer or fractional part of the input texture coordinates needs to be calculated, which effectively reduces the bit width of the adder compared to calculating the addition operation on both the integer and fractional parts simultaneously. On the other hand, the parallel operation of each computation unit improves the computation efficiency of the texel index.

[0075] Please refer to Figure 2 The diagram illustrates an ALU provided in one possible implementation of this application. The ALU 20 includes: a multiplier 21, a first divider 22, a first adder 23, a second adder 24, and a texel adjustment unit 25.

[0076] Multiplier 21 is used to calculate the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, whereby the texture size is used to indicate the size of the texture image.

[0077] A first divider 22 is used to calculate a first ratio between an input offset and a second value, wherein the input offset is used to indicate the offset of a texel relative to at least one texture image, and the second value is determined based on the texture size.

[0078] The first adder 23 is used to determine the first calculation result based on the integer part of the input texture coordinates and the first ratio.

[0079] The second adder 24 is used to determine the second calculation result based on the first value and the first ratio.

[0080] The texel adjustment unit 25 is used to determine the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

[0081] In some embodiments, such as Figure 2 As shown, the ALU 20 can be divided into three modules: Module 0, Module 1, and Module 2. Module 0 includes a multiplier 21, which eliminates calculation errors between the fractional part and the input offset by calculating the product of the texture size and the fractional part of the input texture coordinates. Module 1 includes a first divider 22, a first adder 23, and a second adder 24. The first divider 22 determines the influence of the input offset on the quotient and remainder of the texel index by calculating a first ratio between the input offset and a second value. Compared to related technologies that first calculate the product of the input texture coordinates (including the integer and fractional parts) and the texture size, then calculate the sum of this product and the input offset, and finally use the sum of this product and the input offset as the dividend and the texture size as the divisor for division, the proposed solution reduces the bit width of the divider. Furthermore, since the second value is the smaller of the absolute values ​​of the texture size and the maximum offset, this method can further reduce the bit width of the divider. The first adder 23 only needs to process the addition of the integer part of the input texture coordinates, and the second adder only needs to process the addition of the first ratio and the first value (the first value is determined by the fractional part of the input texture coordinates). By using two independent adders (the first adder and the second adder) to calculate the addition operations related to the integer and fractional parts respectively, the bit width of a single adder can be reduced. Module 2 includes a texel adjustment unit 25, which is used to further adjust the output texel index based on the output results of each calculation unit in Module 0 and Module 1, combined with the addressing mode. Please refer to the following text for the specific implementation of each module.

[0082] A multiplier is a hardware unit in the ALU used to perform multiplication operations. In this case, it is used to calculate the product of the fractional part of the input texture coordinates and the texture size to obtain the first value.

[0083] A texture image is an image used to apply textures to the surface of a 3D model. Texture images typically contain information such as color, material, and lighting to enhance the visual effect of the 3D model. Texture images can be photographs, paintings, or other forms of images. In some embodiments, texture images can be regular images, such as rectangles or squares, or irregular images; this application does not limit this. Texture size is typically expressed in texels. For any given texture image, the texture size in different directions can be the same or different. For example, a texture image can be a 1024×1024 texel square image, indicating that the texture size in both the horizontal and vertical directions is 1024 texels. A texture image can also be a 512×2048 texel rectangular image, indicating that the texture size in the horizontal direction is 512 texels and the texture size in the vertical direction is 2048 texels.

[0084] At least one texture image is used to indicate a texture surface; that is, a texture surface can include multiple texture images. The input offset is used to indicate the offset of the texel relative to the texture surface. The decimal part of the input texture coordinates can be understood as the offset relative to a single texture image. In other words, the calculation granularity of the input offset and the decimal part of the input texture coordinates is different, resulting in calculation errors. To facilitate the subsequent calculation of the second result, the decimal part of the input texture coordinates needs to be enlarged here, that is, multiplied by the texel size to obtain the first value, thereby ensuring the accuracy of the subsequent second calculation result.

[0085] The input offsets mentioned above can include at least one of the following: sampling offset, coordinate offset, and pixel offset. Sampling offset refers to the positional offset of a sampling point relative to the original texture coordinates during texture sampling, and can be used to achieve various texture effects, such as blurring, sharpening, and edge detection filters. Coordinate offset refers to the positional offset of texture coordinates relative to the model surface during texture mapping, and can be used to achieve transformations such as translation, rotation, and scaling of the texture, allowing the texture to adjust its position and orientation as needed. Pixel offset refers to the positional offset of a pixel relative to the texture coordinates during rasterization, and can be used to achieve anti-aliasing, texture smoothing, and other effects, improving the accuracy and quality of texture mapping.

[0086] In some embodiments, the input texture coordinates are floating-point numbers, such as... Figure 3As shown, in addition to multiplier 21, first divider 22, first adder 23, second adder 24, and texel adjustment unit 25, ALU 20 also includes a format conversion unit 26. This format conversion unit 26 is used to convert input texture coordinates from floating-point format to fixed-point format, whereby the fixed-point format input texture coordinates are used to determine the fractional and integer parts of the input texture coordinates.

[0087] In some implementations, the sign bit, exponent, and mantissa of the input texture coordinates in floating-point format are determined; the input texture coordinates in fixed-point format are determined based on the sign bit, exponent, and mantissa of the floating-point number, and the input texture coordinates in fixed-point format include an integer part and a fractional part. In some embodiments, the decimal value corresponding to the floating-point number is calculated based on the sign bit, exponent, and mantissa, and the decimal value may include an integer and a fractional part; based on the bit width and format of the fixed-point number (including the number of bits occupied by the integer part and the fractional part respectively), the integer and fractional parts of the decimal value are converted into the integer and fractional parts of the fixed-point number, respectively. The bit width occupied by the integer and fractional parts of the fixed-point number can be configured according to the precision requirements, and this application does not limit this.

[0088] For example, the input texture coordinates can be floating-point numbers in fp32 format. Parsing the fp32 format input texture coordinates, we can obtain coordinate

[31] as sign (sign bit), where coordinate

[31] represents the 31st bit of the floating-point number; coordinate[30:23] as exponent (exponent), where coordinate[30:23] represents the 30th to 23rd bits of the floating-point number; {1'b1, coordinate[22:0]} as mantissa (mantissa), where coordinate[22:0] represents the 22nd to 0th bits of the floating-point number, and 1'b1 represents the binary number 1. Based on the above parsing results, the mantissa can be extracted, and combined with the exponent and sign bit, the input texture coordinates in fixed-point format can be determined.

[0089] The above method, by converting the input texture coordinates from floating-point format to fixed-point format, improves subsequent computational efficiency. Fixed-point arithmetic is generally faster than floating-point arithmetic in hardware because it does not require handling complex exponents and mantissas, thus enabling rapid subsequent addition / multiplication / division operations, such as quickly calculating the multiplication between the fractional part of the input texture coordinates and the texture size. Furthermore, fixed-point format allows for the rapid determination of the integer and fractional parts of the input texture coordinates, facilitating subsequent input of these parts into different computational units. For example, the fractional part can be input into multiplier 21 for calculation, while the integer part can be input into the first adder 23.

[0090] In some embodiments, the multiplier 21 calculates the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, which may include both integers and fractions. The number of decimal places retained in the first value can be configured according to precision requirements, and this application does not limit this. For example, the texture size can be n bits, the fractional part of the input texture coordinates can be q bits, and the fractional part of the first value can also be q bits, where n and q are positive integers, and this application does not limit this.

[0091] A divider refers to a hardware unit in the ALU used to perform division operations. The first divider 22 calculates a first ratio between the input offset and a second value, where the second value is the smaller of the texture size and the absolute value of the maximum offset. The maximum offset refers to the pre-configured maximum value of the input offset in a given calculation or processing step. In some embodiments, the maximum offset can be positive or negative; this application does not limit this. The maximum offset can correspond to any number of bits. The number of bits corresponding to the maximum offset refers to the number of binary bits occupied when the maximum offset is represented in binary form in a computer. It includes a sign bit for indicating positive or negative and numeric bits for indicating the magnitude of the value. For example, the number of bits corresponding to the maximum offset can be n, where the highest bit can represent the sign bit, and the lower n-1 bits can represent the number of numeric bits. The absolute value of the maximum offset is 2^n. n-1 The sign of the maximum offset depends on the sign indicated by the highest bit. If the sign bit is 1, it means the maximum offset is negative, in which case the maximum offset is -2. n-1 If the sign bit is 0, it indicates that the maximum offset is positive, in which case the maximum offset is +2. n-1 .

[0092] In some embodiments, when the texture size is greater than the absolute value of the maximum offset, the second value is the absolute value of the maximum offset; when the texture size is less than or equal to the absolute value of the maximum offset, the second value is the texture size.

[0093] In some embodiments, the ALU 20 further includes: a comparator ( Figure 2 (Not shown in the image) is used to compare the absolute value of the texture size with the absolute value of the maximum offset. If the texture size is greater than the absolute value of the maximum offset, the second value is the absolute value of the maximum offset; if the texture size is less than or equal to the absolute value of the maximum offset, the second value is the texture size.

[0094] In some embodiments, when the number of bits corresponding to the maximum offset is less than the number of bits corresponding to the texture size, the absolute values ​​of the texture size and the maximum offset are compared. In this case, since the number of bits corresponding to the maximum offset is less than the number of bits corresponding to the texture size, the first value can be optimized, thereby reducing the bit width of the first divider. Conversely, if the number of bits corresponding to the maximum offset is greater than or equal to the number of bits corresponding to the texture size, the bit width of the first divider cannot be reduced, and there is no need to compare the absolute values ​​of the texture size and the maximum offset. That is, the above steps are performed only when it is determined that the number of bits corresponding to the maximum offset is less than the number of bits corresponding to the texture size: when the texture size is greater than the absolute value of the maximum offset, the second value is the absolute value of the maximum offset; when the texture size is less than or equal to the absolute value of the maximum offset, the second value is the texture size.

[0095] In some embodiments, when the texture size is greater than the absolute value of the maximum offset, it is easy to see that the ratio between the input offset and the texture size is always less than 1, that is, the quotient of the two is 0 and the remainder is the input offset. In other words, the offset crosses at most the boundary of one texture image, but not the entire texture image. Determining the divisor to be the absolute value of the maximum offset in this case is understandable because, since the maximum offset is less than the texture size, the bit width occupied by the maximum offset will be less than the bit width occupied by the texture size. The above method further reduces the bit width of the divider by reducing the number of bits occupied by the divisor.

[0096] In some embodiments, when the texture size is less than or equal to the absolute value of the maximum offset, the ratio between the input offset and the texture size may be greater than or equal to 1, or less than or equal to -1, depending on the sign of the input offset. In other words, the offset may span one or more texture images. Determining the texture size as the divisor in this case serves two purposes: firstly, since the texture size is less than the absolute value of the maximum offset, the bit width occupied by the texture size will be less than the bit width occupied by the maximum offset (excluding the sign bit), thus further reducing the bit width of the divider. Secondly, the remainder of the ratio can be used to determine the specific number of texels the input offset covers in a texture image, and the quotient can be used to determine the specific number of texture images the input offset covers.

[0097] In some embodiments, such as Figure 3 As shown, the first ratio includes a quotient and a remainder. The specific implementation method for determining the first calculation result is as follows: a first adder is used to calculate the sum of the integer part of the input texture coordinates and the quotient of the first ratio to obtain the first calculation result. The adder refers to the hardware unit in the ALU used to perform addition operations.

[0098] In some embodiments, the quotient of the first ratio can be 0, and the remainder is the input offset. In this case, the first calculation result is the integer part of the input texture coordinates. In some embodiments, the quotient of the first ratio can be greater than or equal to 1, or less than or equal to -1, and the remainder is the input offset % texture size, or the remainder is 0. In this case, the first calculation result is the sum of the integer part of the input texture coordinates and the quotient of the first ratio.

[0099] In some embodiments, such as Figure 3 As shown, the first ratio includes the quotient and the remainder. The specific implementation method for determining the second calculation result is as follows: a second adder is used to calculate the sum of the remainders of the first value and the first ratio to obtain the second calculation result.

[0100] In some embodiments, when the quotient of the first ratio is 0, the remainder is the input offset, and the second calculation result is the sum of the first value and the input offset. In some embodiments, when the quotient of the first ratio is greater than or equal to 1, or less than or equal to -1, the remainder is the input offset % texture size or 0, and the second calculation result is the sum of the first value and (input offset % texture size), or the second calculation result is the first value.

[0101] In the above method, the first adder only needs to process the addition operation of the integer part of the input texture coordinates, and the second adder only needs to process the addition operation of the remainder of the first ratio and the first value (the first value is determined by the fractional part of the input texture coordinates). Compared with using a single adder to calculate the addition of integers and remainders at the same time, by using two independent adders (the first adder and the second adder) to calculate the addition operation related to the integer part and the fractional part respectively, the bit width of a single adder can be reduced.

[0102] In some embodiments, the second calculation result may include an integer and a decimal. The absolute value of the second calculation result may be less than the texture size, or it may be greater than or equal to the texture size. It is understood that when the absolute value of the second calculation result is less than the texture size, the second calculation result only affects the remainder portion of the final texel index; when the absolute value of the second calculation result is greater than or equal to the texture size, the second calculation result affects both the integer and remainder portions of the final texel index.

[0103] In summary, the technical solution provided by the embodiments of this application, for the scenario of converting input texture coordinates into texel indices, inputs the integer and fractional parts of the input texture coordinates into different computing units for calculation. Compared with the related technology method of inputting the integer and fractional parts of the input texture coordinates into one computing unit for calculation, this method allows a single computing unit to calculate only a portion of the input texture coordinate data, effectively reducing the bit width of each computing unit and lowering the complexity of the physical implementation of the computing unit.

[0104] The following describes three specific implementations for determining the integer and remainder of the texel index.

[0105] Method 1

[0106] In some embodiments, such as Figure 3 As shown, the ALU 20 also includes: a second divider 27; the second divider 27 is used to calculate a second ratio between the second calculation result and the texture size, the second ratio including the quotient and the remainder; and a texel adjustment unit 25 is used to calculate the sum of the quotients of the first calculation result and the second ratio.

[0107] In some embodiments, when the second calculation result is greater than or equal to the texture size, the second ratio includes a quotient and a remainder. In this case, the quotient is 1 or -1, and the remainder is the second calculation result % texture size. The quotient of the first calculation result and the second ratio is the first calculation result plus 1 or plus -1. When the second calculation result is less than the texture size, the second ratio includes a quotient and a remainder. In this case, the quotient is 0, and the remainder is the second calculation result. The quotient of the first calculation result and the second ratio is the first calculation result.

[0108] In some embodiments, the first adder 23 may also be used to calculate the sum of the quotient of the first calculation result and the second ratio, which is not limited in this application.

[0109] The above method allows the second divider 27 to calculate the second ratio between the second calculation result and the texture size. Then, the texel adjustment unit 25 can calculate the sum of the quotient of the second ratio and the first calculation result. Based on the calculation results of the second divider 27 and the texel adjustment unit 25, it is convenient to determine the integer and remainder of the texel index in the subsequent process.

[0110] In some embodiments, the texel index includes an integer and a remainder; the texel adjustment unit is configured to determine the sum of the quotients of the first calculation result and the second ratio as the integer of the texel index, the integer of the texel index being used to determine the target texture image from a plurality of texture images, the target texture image being the texture image corresponding to the input texture coordinates; the texel adjustment unit 25 is configured to determine the remainder of the second ratio as the remainder of the texel index, the remainder of the texel index being used to determine the target texel from a plurality of texels contained in the target texture image, the target texel being the texel corresponding to the input texture coordinates.

[0111] The second ratio includes a quotient and a remainder. The texel adjustment unit 25 is used to determine the sum of the quotient of the first calculation result and the second ratio as the integer of the texel index. The texel adjustment unit 25 is used to determine the remainder of the second ratio as the remainder of the texel index.

[0112] In some embodiments, the second ratio must be calculated regardless of whether the absolute value of the second calculation result is greater than, equal to, or less than the texture size. It is understood that when the quotient of the second ratio is 0, corresponding to a scenario where the absolute value of the second calculation result is less than the texture size, the second calculation result only affects the remainder of the texel index, not the integer part. Therefore, the first calculation result can be determined as the integer part of the texel index, and the second calculation result as the remainder of the texel index, thus directly determining the texel index. When the quotient of the second ratio is 1 or -1, corresponding to a scenario where the absolute value of the second calculation result is greater than or equal to the texture size, the texel adjustment unit 25 is used to determine the sum of the quotient of the first calculation result and the second ratio as the integer part of the texel index, and to determine the remainder of the second ratio as the remainder of the texel index.

[0113] The following example illustrates the scenario where the second calculation result is greater than the texture size. For instance, when the input texture coordinates are 4.9 (the integer part of the input texture coordinates is 4, and the decimal part is 0.9), the input offset is 12, and the texture size is 10, the calculation steps may include the following steps: step1 to step6.

[0114] Step 1: Calculate the product of the decimal part of the input texture coordinates and the texture size, that is, the first value = 0.9 * 10 = 9.

[0115] Step 2: Calculate the first ratio between the input offset and the second value (i.e., the texture size), that is, the first ratio = 12 / 10 = 1...2 (quotient 1 remainder 2).

[0116] Step 3: Calculate the sum of the quotients of the integer part of the input texture coordinates and the first ratio, that is, the first calculation result = 4 + 1 = 5.

[0117] Step 4: Calculate the sum of the remainders of the first value and the first ratio, which is the second calculation result = 9 + 5 = 14.

[0118] Step 5: Since the absolute value of the second calculation result, 14, is greater than the texture size, 10, calculate the ratio of the second calculation result to the texture size, that is, the second ratio = 14 / 10 = 1...4 (quotient 1, remainder 4).

[0119] Step 6: Calculate the sum of the quotients of the first calculation result and the second ratio, i.e., 5 + 1 = 6. Then, determine the integer of the texel index as the sum of the quotients of the first calculation result and the second ratio, 6, and determine the remainder of the texel index as the remainder of the second ratio, 4. Based on the integer of the texel index, the target texture image can be determined to be texture image 7, and the target texel is the 5th texel in texture image 7.

[0120] The above method calculates a second ratio using a second divider, and then uses a texel adjustment unit to determine the integer and remainder of the texel index based on the second ratio. This ensures that the integer and remainder of the texel index can be accurately determined whether the absolute value of the second calculation result is greater than, equal to, or less than the texture size.

[0121] In some embodiments, the second ratio may only need to be calculated under specific conditions. Specifically, the ALU 20 further includes: a comparator ( Figure 2 (Not shown in the image) The texel adjustment unit 25 compares the absolute value of the second calculation result with the size of the texture. If the absolute value of the second calculation result is less than the texture size, the texel adjustment unit 25 determines the first calculation result as an integer of the texel index and the second calculation result as a remainder of the texel index. In other words, when the absolute value of the second calculation result is less than the texture size, there is no need to calculate the aforementioned second ratio to avoid computational complexity.

[0122] Method 2

[0123] In some embodiments, the texel index is used to indicate the target texel, which is determined based on the integer and remainder of the texel index. When the absolute value of the second calculation result is less than the texture size, the texel adjustment unit 25 is used to determine the first calculation result as the integer of the texel index. The integer of the texel index is used to determine the target texture image from multiple texture images. The target texture image refers to the texture image corresponding to the input texture coordinates. The texel adjustment unit 25 is also used to determine the second calculation result as the remainder of the texel index. The remainder of the texel index is used to determine the target texel from multiple texels contained in the target texture image. The target texel refers to the texel corresponding to the input texture coordinates.

[0124] The following example illustrates the scenario where the second calculated result is less than the texture size. For instance, when the input texture coordinates are 4.25 (the integer part of the input texture coordinates is 4, and the decimal part is 0.25), the input offset is 12, and the texture size is 8, the calculation steps may include the following steps: step1 to step5.

[0125] Step 1: Calculate the product of the decimal part of the input texture coordinates and the texture size, that is, the first value = 0.25 * 8 = 2.

[0126] Step 2: Calculate the first ratio between the input offset and the second value (i.e., the texture size), that is, the first ratio = 12 * 8 = 1...4 (quotient 1 remainder 4).

[0127] Step 3: Calculate the sum of the quotients of the integer part of the input texture coordinates and the first ratio, that is, the first calculation result = 4 + 1 = 5.

[0128] Step 4: Calculate the sum of the remainders of the first value and the first ratio, which is the second calculation result = 2 + 4 = 6.

[0129] Step 5: Since the absolute value of the second calculation result, 6, is less than the texture size, 8, the integer value of the texel index is determined to be the first calculation result, 5, and the remainder of the texel index is determined to be the second calculation result, 6. Based on the integer value of the texel index, the target texture image can be determined to be texture image 6, and the target texel is the 7th texel in texture image 6.

[0130] The ALU in the above method also includes a comparator. When the absolute value of the second calculation result is less than the texture size, the second calculation result only affects the remainder part of the texel index and does not affect the integer part of the texel index. In this case, there is no need to calculate the second ratio. The first calculation result can be directly determined as the integer of the texel index and the second calculation result can be determined as the remainder of the texel index, so that there is no need to calculate the second ratio to avoid unnecessary division operations.

[0131] Method 3

[0132] The methods for calculating the texel index in Method 1 and Method 2 above are equivalent to the default addressing mode being repeated addressing mode.

[0133] In some embodiments, the technical solutions provided in this application can be applied to the calculation of texel indices under other different addressing modes. Specifically, the texel adjustment unit 25 is used to determine the texel index corresponding to the input texture coordinates based on the addressing mode, the first calculation result, and the second calculation result.

[0134] In some embodiments, the texel adjustment unit 25 is configured to determine an initial texel index based on a first calculation result and a second calculation result; and to determine the texel index corresponding to the input texture coordinates based on the initial texel index.

[0135] In some embodiments, the initial texel index is calculated in the same way as in methods 1 and 2 described above. In other words, method 3 uses the texel indices calculated in methods 1 and 2 as the initial texel index. Specifically, the integer values ​​of the texel indices in methods 1 and 2 are used as the integer values ​​of the initial texel index, and the remainders of the texel indices are used as the remainders of the initial texel index. The texel index corresponding to the input texture coordinates is determined by combining the initial texel index and the addressing mode. That is, method 3 calculates the texel index corresponding to the input texture coordinates based on the calculations in methods 1 and 2, combined with the addressing mode. For the specific implementation of calculating the initial texel index, please refer to methods 1 and 2 described above; it will not be repeated here.

[0136] In some embodiments, the integer of the texel index corresponding to the input texture coordinate remains unchanged and is still the integer of the initial texel index mentioned above; the remainder of the texel index also needs to be calculated in combination with the remainder of the initial texel index and the addressing mode.

[0137] In some embodiments, the texel indices corresponding to the input texture coordinates are different in different addressing modes. The addressing modes may include at least one of the following: mirror addressing mode, border color addressing mode, and pinch mode, which are not limited in this application.

[0138] In some embodiments, when the addressing mode is mirror addressing mode, assuming that the integer part of the initial texel index is an odd multiple of the texture image, the remainder of the initial texel index also needs to be mirrored. For example, in the above example, taking mirror addressing mode as an example, when the input texture coordinates are 4.25 (the integer part of the input texture coordinates is 4, and the fractional part is 0.25), the input offset is 12, and the texture size is 8, the calculation steps may include the following steps: step 1 to step 6.

[0139] Step 1: Calculate the product of the decimal part of the input texture coordinates and the texture size, that is, the first value = 0.25 * 8 = 2.

[0140] Step 2: Calculate the first ratio between the input offset and the second value (i.e., the texture size), that is, the first ratio = 12 * 8 = 1...4 (quotient 1 remainder 4).

[0141] Step 3: Calculate the sum of the quotients of the integer part of the input texture coordinates and the first ratio, that is, the first calculation result = 4 + 1 = 5.

[0142] Step 4: Calculate the sum of the remainders of the first value and the first ratio, which is the second calculation result = 2 + 4 = 6.

[0143] Step 5: Since the absolute value of the second calculation result 6 is less than the texture size 8, the integer of the initial texel index is determined to be the first calculation result 5, and the remainder of the initial texel index is determined to be the second calculation result 6.

[0144] Step 6: Since the initial texel index is an integer of 5, which is an odd multiple of the texture image, the remainder of the initial texel index needs to be mirrored. Specifically, if the remainder of the initial texel index is 6 and the texture size is 8, then the remainder of the texel index is determined to be the texture size minus the remainder of the initial texel index minus 1. Therefore, the remainder of the texel index is 8 - 6 - 1 = 1, and the target texel is the second texel in the target texture image. Here, the integer value of the texel index remains unchanged, still being the initial integer 5. Based on the integer value of the texel index, the target texture image can be determined to be texture image 6, and the target texel is the second texel in texture image 6.

[0145] For example, in the above example, the remainder of the initial texel index is 6. Assuming the initial texel index is an integer, it is an even multiple of the texture image, and there is no need to perform a mirror flip on the remainder of the initial texel index. That is, the remainder of the texel index is the remainder of the initial texel index, which is 6.

[0146] The above method can flexibly adapt to different addressing modes to accurately determine the texel index corresponding to the input texture coordinates.

[0147] The following is an embodiment of the texel index calculation method applied to the above-mentioned ALU 20. For details, please refer to the relevant content on the ALU side above. This application will not repeat it here.

[0148] Please refer to Figure 4 This document illustrates a flowchart of a texel index calculation method applied to an ALU, as provided in one possible implementation of this application. This application provides a texel index calculation method applied to an ALU. The ALU includes a multiplier, a first divider, a first adder, a second adder, and a texel adjustment unit. The method may include at least one of steps 410-450. It should be noted that this application does not limit the execution order of steps 410-450.

[0149] Step 410: The multiplier calculates the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, whereby the texture size is used to indicate the size of the texture image.

[0150] Step 420: The first divider calculates a first ratio between an input offset and a second value, the input offset being used to indicate the offset of a texel relative to at least one texture image, and the second value being determined based on the texture size.

[0151] Step 430: The first adder determines the first calculation result based on the integer part of the input texture coordinates and the first ratio.

[0152] Step 440: The second adder determines the second calculation result based on the first value and the first ratio.

[0153] Step 450: The texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

[0154] In some embodiments, the first ratio includes a quotient and a remainder; the first adder determines a first calculation result based on the integer part of the input texture coordinates and the first ratio, including: the first adder calculates the sum of the quotients of the integer part of the input texture coordinates and the first ratio to obtain the first calculation result; the second adder determines a second calculation result based on the first value and the first ratio, including: the second adder calculates the sum of the remainders of the first value and the first ratio to obtain the second calculation result.

[0155] In some embodiments, the texel index includes an integer and a remainder; when the absolute value of the second calculation result is less than the texture size, the texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result, including: the texel adjustment unit determines the first calculation result as the integer of the texel index, the integer of the texel index being used to determine the target texture image from multiple texture images, the target texture image referring to the texture image corresponding to the input texture coordinates; the texel adjustment unit determines the second calculation result as the remainder of the texel index, the remainder of the texel index being used to determine the target texel from multiple texels contained in the target texture image, the target texel referring to the texel corresponding to the input texture coordinates.

[0156] In some embodiments, the ALU further includes: a second divider; the method further includes: the second divider calculating a second ratio between a second calculation result and a texture size, the second ratio including a quotient and a remainder; and the texel adjustment unit calculating the sum of the quotients of the first calculation result and the second ratio.

[0157] In some embodiments, the second ratio includes a quotient and a remainder, and the texel index includes an integer and a remainder. The integer of the texel index is used to determine a target texture image from a plurality of texture images, where the target texture image refers to the texture image corresponding to the input texture coordinates. The remainder of the texel index is used to determine a target texel from a plurality of texels contained in the target texture image, where the target texel refers to the texel corresponding to the input texture coordinates. The method further includes: a texel adjustment unit determining the sum of the quotients of the first calculation result and the second ratio as the integer of the texel index; and a texel adjustment unit determining the remainder of the second ratio as the remainder of the texel index.

[0158] In some embodiments, when the texture size is greater than the absolute value of the maximum offset, the second value is the absolute value of the maximum offset; when the texture size is less than or equal to the absolute value of the maximum offset, the second value is the texture size.

[0159] In some embodiments, the method further includes: a texel adjustment unit determining a texel index corresponding to the input texture coordinates based on an addressing mode, a first calculation result, and a second calculation result, wherein the texel index corresponding to the input texture coordinates is different in different addressing modes.

[0160] In some embodiments, the input texture coordinates are floating-point numbers, and the ALU further includes a format conversion unit; the method further includes: the format conversion unit converts the input texture coordinates from floating-point format to fixed-point format, wherein the fixed-point format input texture coordinates are used to determine the fractional and integer parts of the input texture coordinates.

[0161] An exemplary embodiment of this application also provides a chip product, which includes a processor that includes the ALU described above. Optionally, the chip product may be a GPU chip product, with the processor being a GPU that includes the ALU described above. Optionally, the above-described chip product may be implemented as a graphics card, which includes a processor that includes the ALU described above.

[0162] An exemplary embodiment of this application also provides a computer device, which includes a processor including the ALU described above. Optionally, the computer device may be a personal computer, workstation, game console, and some mobile devices (such as tablet computers, smartphones, etc.), or it may be an in-vehicle terminal device, smart home device, smart TV, smart robot, etc., or it may be a server, server cluster, artificial intelligence computing cluster, cloud computing cluster, etc., wherein the artificial intelligence computing cluster may also be simply referred to as an intelligent computing cluster or smart computing cluster, and this application does not limit it in this regard.

[0163] It should be understood that "multiple" as used herein refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. Furthermore, the step numbers described herein are merely illustrative of one possible execution order. In some other embodiments, the steps may not be executed in numerical order, such as two steps with different numbers being executed simultaneously, or two steps with different numbers being executed in the reverse order of the illustration. This application does not limit this.

[0164] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

Claims

1. An arithmetic logic unit (ALU), characterized in that, The ALU includes: a multiplier, a first divider, a first adder, a second adder, and a texel adjustment unit; The multiplier is used to calculate the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, wherein the texture size is used to indicate the size of the texture image; The first divider is used to calculate a first ratio between an input offset and a second value, the input offset being used to indicate the offset of a texel relative to at least one texture image, and the second value being the smaller of the absolute values ​​of the texture size and the maximum offset. The first adder is used to determine a first calculation result based on the integer part of the input texture coordinates and the first ratio; The second adder is used to determine a second calculation result based on the first value and the first ratio; The texel adjustment unit is used to determine the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

2. The ALU according to claim 1, characterized in that, The first ratio includes the quotient and the remainder; The first adder is used to calculate the sum of the integer part of the input texture coordinate and the quotient of the first ratio to obtain the first calculation result; The second adder is used to calculate the sum of the remainders of the first value and the first ratio to obtain the second calculation result.

3. The ALU according to claim 2, characterized in that, The texel index includes an integer and a remainder; The texel adjustment unit is used to determine the first calculation result as an integer of the texel index when the absolute value of the second calculation result is less than the texture size. The integer of the texel index is used to determine the target texture image from multiple texture images. The target texture image refers to the texture image corresponding to the input texture coordinates. The texel adjustment unit is used to determine the second calculation result as the remainder of the texel index. The remainder of the texel index is used to determine the target texel from the multiple texels contained in the target texture image. The target texel refers to the texel corresponding to the input texture coordinates.

4. The ALU according to claim 2, characterized in that, The ALU also includes: a second divider; The second divider is used to calculate a second ratio between the second calculation result and the texture size, the second ratio including a quotient and a remainder; The texture adjustment unit is used to calculate the sum of the quotients of the first calculation result and the second ratio.

5. The ALU according to claim 4, characterized in that, The texel index includes an integer and a remainder; The texel adjustment unit is used to determine the sum of the quotients of the first calculation result and the second ratio as the integer of the texel index. The integer of the texel index is used to determine the target texture image from multiple texture images. The target texture image refers to the texture image corresponding to the input texture coordinates. The texel adjustment unit is used to determine the remainder of the second ratio as the remainder of the texel index. The remainder of the texel index is used to determine the target texel from the plurality of texels contained in the target texture image. The target texel refers to the texel corresponding to the input texture coordinates.

6. The ALU according to claim 1, characterized in that, The ALU also includes: a comparator; The comparator is used to compare the absolute value of the texture size and the maximum offset. The comparator is configured to determine the second value as the absolute value of the maximum offset when the texture size is greater than the absolute value of the maximum offset; or, to determine the second value as the texture size when the texture size is less than or equal to the absolute value of the maximum offset.

7. The ALU according to claim 1, characterized in that, The texel adjustment unit is used to determine the texel index corresponding to the input texture coordinates based on the addressing mode, the first calculation result, and the second calculation result, wherein the texel index corresponding to the input texture coordinates is different in different addressing modes.

8. The ALU according to claim 1, characterized in that, The input texture coordinates are floating-point numbers, and the ALU further includes: a format conversion unit; The format conversion unit is used to convert the input texture coordinates from floating-point format to fixed-point format, wherein the input texture coordinates in fixed-point format are used to determine the fractional and integer parts of the input texture coordinates.

9. A method for calculating texel indexes applied to an arithmetic logic unit (ALU), characterized in that, The ALU includes: a multiplier, a first divider, a first adder, a second adder, and a texel adjustment unit; the method includes: The multiplier calculates the product of the fractional part of the input texture coordinates and the texture size to obtain a first value, whereby the texture size is used to indicate the size of the texture image; The first divider calculates a first ratio between an input offset and a second value, the input offset being used to indicate the offset of a texel relative to at least one texture image, and the second value being the smaller of the absolute values ​​of the texture size and the maximum offset. The first adder determines the first calculation result based on the integer part of the input texture coordinates and the first ratio; The second adder determines the second calculation result based on the first value and the first ratio; The texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result.

10. The method according to claim 9, characterized in that, The first ratio includes the quotient and the remainder; The first adder determines a first calculation result based on the integer part of the input texture coordinates and the first ratio, including: The first adder calculates the sum of the integer part of the input texture coordinate and the quotient of the first ratio to obtain the first calculation result; The second adder determines the second calculation result based on the first value and the first ratio, including: The second adder calculates the sum of the remainders of the first value and the first ratio to obtain the second calculation result.

11. The method according to claim 10, characterized in that, The texel index includes an integer and a remainder; The texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the first calculation result and the second calculation result, including: When the absolute value of the second calculation result is less than the texture size, the texel adjustment unit determines the first calculation result as the integer of the texel index. The integer of the texel index is used to determine the target texture image from multiple texture images. The target texture image refers to the texture image corresponding to the input texture coordinates. The texel adjustment unit determines the second calculation result as the remainder of the texel index. The remainder of the texel index is used to determine the target texel from the multiple texels contained in the target texture image. The target texel refers to the texel corresponding to the input texture coordinates.

12. The method according to claim 10, characterized in that, The ALU further includes: a second divider; the method further includes: The second divider calculates a second ratio between the second calculation result and the texture size, the second ratio including the quotient and the remainder; The texture adjustment unit calculates the sum of the quotients of the first calculation result and the second ratio.

13. The method according to claim 12, characterized in that, The second ratio includes a quotient and a remainder, and the texel index includes an integer and a remainder; the method further includes: The texel adjustment unit determines the sum of the quotients of the first calculation result and the second ratio as the integer of the texel index. The integer of the texel index is used to determine the target texture image from multiple texture images. The target texture image refers to the texture image corresponding to the input texture coordinates. The texel adjustment unit determines the remainder of the second ratio as the remainder of the texel index. The remainder of the texel index is used to determine the target texel from the multiple texels contained in the target texture image. The target texel refers to the texel corresponding to the input texture coordinates.

14. The method according to claim 9, characterized in that, The ALU further includes: a comparator; the method further includes: The comparator compares the absolute value of the texture size with that of the maximum offset. The comparator determines the second value as the absolute value of the maximum offset when the texture size is greater than the absolute value of the maximum offset; or, when the texture size is less than or equal to the absolute value of the maximum offset, it determines the second value as the texture size.

15. The method according to claim 9, characterized in that, The method further includes: The texel adjustment unit determines the texel index corresponding to the input texture coordinates based on the addressing mode, the first calculation result, and the second calculation result, wherein the texel index corresponding to the input texture coordinates is different in different addressing modes.

16. The method according to claim 9, characterized in that, The input texture coordinates are floating-point numbers, and the ALU further includes a format conversion unit; the method further includes: The format conversion unit converts the input texture coordinates from floating-point format to fixed-point format, and the input texture coordinates in fixed-point format are used to determine the fractional and integer parts of the input texture coordinates.

17. A processor, characterized in that, The processor includes an ALU as described in any one of claims 1 to 8.

18. A chip product, characterized in that, The chip product includes a processor, the processor including an ALU as described in any one of claims 1 to 8.

19. A computer device, characterized in that, The computer device includes a processor, the processor including an ALU as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Incremental interlace interpolation for texture morphing

    CA2362148A1

  • Graphics processing architecture for an FPGA

    CA2826405A1