ALU, processor, chip, device, and texel index calculation methods

By designing the ALU, the product of the mantissa of the input texture coordinates in floating-point format and the texture size is directly calculated, and left and right shift operations are performed to reduce the number of rounding operations, improve the calculation accuracy of the texel index, and solve the problem of inaccurate texel index calculation.

CN121213334BActive Publication Date: 2026-05-26MOORE THREADS TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
MOORE THREADS TECH CO LTD
Filing Date
2025-09-24
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In the existing technology, the calculated texel index value is inaccurate, mainly due to the loss of precision caused by multiple rounding operations.

Method used

The design employs an ALU, which calculates the product of the mantissa of the input texture coordinates in floating-point format and the texture size through a multiplier. The first conversion unit shifts the input offset to the left, and the adder calculates the sum of the product and the shifted offset. Finally, the second conversion unit shifts the input offset to the right and rounds it to obtain the texel index, reducing the number of rounding operations.

Benefits of technology

The number of right shift operations is reduced, and the precision loss caused by rounding operations is reduced, making texel index calculation more accurate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121213334B_ABST
    Figure CN121213334B_ABST
Patent Text Reader

Abstract

An ALU, processor, chip, device, and texel index calculation method are disclosed, belonging to the field of chip technology. The ALU includes: a multiplier for calculating the product of the mantissa of the input texture coordinates in floating-point format and the texture size, obtaining a first product; a first conversion unit for shifting the input offset left by N bits, obtaining a shifted input offset; an adder for calculating the sum of the first product and the shifted input offset, obtaining a first calculation result; a second conversion unit for shifting the first calculation result right by M bits, obtaining a shifted first calculation result; and a second calculation result based on the shifted first calculation result and a rounding mode, the second calculation result being used to determine the texel index corresponding to the input texture coordinates. This method only requires one unified right shift operation to obtain the second calculation result in a preset floating-point format, reducing the number of right shift operations and thus making the determined texel index more accurate.
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 coordinate ALU TPU (Texture Processing Unit). The general calculation formula is: texel_index = coordinate * texture size + offset, where coordinate is the input texture coordinate, texture size is the size of the texture image, and offset is the input offset.

[0004] However, during the above texel index calculation process, the calculated texel index values ​​are often inaccurate. 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 conversion unit, an adder, and a second conversion unit;

[0007] The multiplier is used to calculate the product of the mantissa of the input texture coordinates in floating-point format and the texture size to obtain a first product, wherein the texture size is used to indicate the size of the texture image;

[0008] The first conversion unit is used to shift the input offset to the left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates;

[0009] The adder is used to calculate the sum of the first product and the shifted input offset to obtain a first calculation result;

[0010] The second conversion unit is used to right-shift the first calculation result by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, a second calculation result is obtained, and the second calculation result is used to determine the texel index corresponding to the input texture coordinates, where M is a positive integer and M is determined based on N.

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

[0012] The multiplier calculates the product of the mantissa of the floating-point format input texture coordinates and the texture size to obtain a first product, wherein the texture size is used to indicate the size of the texture image;

[0013] The first conversion unit shifts the input offset to the left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates;

[0014] The adder calculates the sum of the first product and the shifted input offset to obtain the first calculation result;

[0015] The second conversion unit shifts the first calculation result to the right by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, a second calculation result is obtained. The second calculation result is used to determine the texel index corresponding to the input texture coordinates, where M is a positive integer and M is determined based on N.

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

[0017] 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.

[0018] 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.

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

[0020] Instead of first shifting the input texture coordinates to the right by a fixed number of points, this method directly calculates the product of the mantissa of the input texture coordinates and the texture size. Furthermore, it avoids shifting this calculated product. This method requires only one uniform right shift operation to obtain the second calculation result in a preset point format. Compared to related techniques, this method reduces the number of right shift operations, minimizing the precision loss caused by rounding and thus making the determined texel index more accurate. Attached Figure Description

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

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

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

[0024] 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.

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

[0026] 1. TPU

[0027] 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.

[0028] 2. Texture

[0029] A texture is typically a two-dimensional image containing multiple texels, used to provide surface detail and color information for three-dimensional objects. In computer graphics, textures are mapped onto the surface of three-dimensional objects to enhance the realism and detail of a scene. The width of a texture image (also called the texture size) is denoted by the texture size and is measured in texels. Texture coordinates are a coordinate system used in computer graphics to locate the mapping of a texture onto an object's surface. The coordinates indicate where 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 values ​​of uv coordinates typically range from [0, 1].

[0030] 3. Texel

[0031] A texel is the smallest unit of texture that can be read or written, representing a single pixel in a texture image. A texel contains information such as chroma and transparency, which are used during graphics rendering to determine the appearance of an object's surface and to determine the detail and resolution of the texture image. A texel is the basic unit of a texture image; that is, a texture image is composed of multiple texels, equivalent to pixels in an image. A texel index is used to precisely locate texels within a texture image.

[0032] 4. Floating-point numbers

[0033] 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: .

[0034] 5. Integers

[0035] Integers are used to represent numerical values ​​without a decimal part. Integer values ​​can be integers, negative numbers, 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 can only represent non-negative integers. Because it has no sign bit, it can represent a larger range of positive numbers with the same number of bits.

[0036] 6. Fixed point number

[0037] Fixed-point (fxp) is a common numerical representation method used to represent decimals with a limited number of bits of storage. Fixed-point numbers typically consist of an integer part and a fractional part, and are commonly classified as signed fixed-point numbers and unsigned fixed-point numbers. Unlike floating-point numbers, fixed-point numbers pre-fix the position of the decimal point during storage, so their operations are generally faster and consume fewer resources than floating-point operations. However, because the decimal point position is fixed, their range and precision are limited, and more care must be taken to control the risk of overflow during calculations.

[0038] 7. Texture Coordinate ALU

[0039] The arithmetic logic unit in the TPU is used to convert input texture coordinates into texel indices. The general formula for calculating universally normalized coordinates is:

[0040] `texel_index` = `coordinate * texture size + offset`, where `coordinate` is the input texture coordinates, `texture size` is the texture size, and `offset` is the configured or calculated input offset, typically including sampling offset, coordinate offset, pixel offset, etc. This offset usually does not apply to a single texture image, but rather to the entire screen (i.e., at least one texture image). `offset` is usually a series of non-normalized fixed-point numbers. The output texel index is in signed fixed-point number format.

[0041] In addition, the final texel may need to return different results depending on the configuration (point / bilinear). For input configured as point, only the integer part of the texel is returned, and the decimal part of the texel is directly erased. For input configured as bilinear, both the integer and decimal parts of the texel need to be retained for subsequent bilinear filtering calculations.

[0042] The following example uses a coordinate (input texture coordinates) format of fp32, a texture size of t bits (positive integer), an input offset of a high-precision signed fixed-point number s xy with a small absolute value, and a texel output format of s pq. The calculation process of the texel index can include steps 1 to 3. For the fixed-point number s xy, s stands for sign, i.e., the sign bit. x represents the number of bits occupied by the integer part of the fixed-point number, and y represents the number of bits occupied by the fractional part of the fixed-point number. It should be understood that the meaning of other fixed-point numbers in this application, such as the fixed-point number s pq, is explained in the same way, and will not be elaborated further below.

[0043] Step 1: Convert the input texture coordinates in fp32 format to fixed-point numbers and multiply them by the texture size to obtain the product. Then, convert the product to a fixed-point number in a specified format (such as s ab) to obtain the format-converted product.

[0044] Step 2: Convert the input offset to the fixed-point format (i.e., sab) indicated in Step 1 to obtain the format-converted input offset. Calculate the sum of the product of the above format conversions and the format-converted input offset to obtain the sum.

[0045] Step 3: Adjust the format of the summation result from Step 2 to the output SPQ format.

[0046] In a conventional design, in order to minimize precision loss, generally, the fixed-point digit width (a + b + 1) in Step 1 is greater than the width t of the texture size and the width (x + y + 1) of the input offset. At the same time, in order to reduce the area and power consumption overhead, the width (p + q + 1) of the final output texture element index is less than the fixed-point digit width (a + b + 1) in Step 1. Additionally, q < b <= 23, where 23 is the width of the fractional part 1.xxx of the mantissa of fp32.

[0047] In Step 1, generally, 2 rounding operations are involved. A rounding operation refers to the operation of approximating a number according to specific rules to make it into a specified precision or format when performing numerical calculations or data processing, because all digit positions cannot be precisely retained due to storage or representation limitations. Among them, the first rounding operation in Step 1 is: converting the input texture coordinates in fp32 format into fixed-point numbers. The second rounding operation in Step 1 is: converting the product result into a fixed-point number of a certain specified format. In Step 3, 1 rounding operation is involved: adjusting the format of the addition result in Step 2 to the output s p.q format. It is easy to understand that the above rounding operations mean that precision loss may occur, which will make the calculated value of the texture element index inaccurate.

[0048] Therefore, we further study the calculation method of the texture element index, and improve the precision of the calculated texture element index result by reducing the number of rounding operations.

[0049] Please refer to Figure 1 , which shows a schematic diagram of an ALU provided in a possible implementation manner of the present application. The ALU 10 includes: a multiplier 11, a first conversion unit 12, an adder 13, and a second conversion unit 14.

[0050] The multiplier 11 is used to calculate the product of the mantissa of the input texture coordinates in floating-point format and the texture size, and obtain a first product, where the texture size is used to indicate the size of the texture image.

[0051] The first conversion unit 12 is used to shift the input offset left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates.

[0052] The adder 13 is used to calculate the sum of the first product and the shifted input offset, and obtain a first calculation result.

[0053] The second conversion unit 14 is used to shift the first calculation result right by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, obtain a second calculation result, where the second calculation result is used to determine the texture element index corresponding to the input texture coordinates, M is a positive integer, and M is determined based on N.

[0054] Texture images typically contain information such as color, material, and lighting to enhance the visual effect of 3D models. Texture images can be photographs, paintings, or other forms of images. For example, a texture image refers to an image used for mapping onto the surface of a 3D model. 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 of the texture image is 1024 texels in both the horizontal and vertical directions. A texture image can also be a 512×2048 texel rectangular image, indicating that the texture size of the texel image is 512 texels in the horizontal direction and 2048 texels in the vertical direction.

[0055] The input texture coordinates are floating-point numbers, including single-precision floating-point numbers (fp32). The highest bit of the fp32 is the sign bit, where 0 represents a positive number and 1 represents a negative number; the middle 8 bits represent the exponent, ranging from 0 to 255, corresponding to the true exponent range of -126 to 127; the lower 23 bits represent the mantissa. In some embodiments, the input texture coordinates can also be double-precision floating-point numbers (fp64), in which case the mantissa can be the numerical part represented by the lower 52 bits; this application does not limit this.

[0056] In some embodiments, the input texture coordinates can be either normalized floating-point numbers or denormalized floating-point numbers. The exponent portion of a normalized floating-point number is not all zeros. Denormalized floating-point numbers are designed to represent numbers very close to zero. In floating-point representation, a floating-point number is a denormalized floating-point number when the exponent portion is all zeros. It should be noted that because adding the offset to the original mantissa after left shifting involves an addition operation, if this scheme is used with denormalized floating-point numbers, the area overhead caused by the adder's bit width increases significantly. Unless extremely high precision is required, this scheme is not recommended.

[0057] When the input texture coordinates are normalized floating-point numbers, the decimal value represented by the fp32 number can be calculated by the following expression: (-1) sign * 2 (exponent-127) * (1. mantissa When the input texture coordinates are denormalized floating-point numbers, exponent=0.

[0058] In some embodiments, the input texture coordinates range from (-2, 2).

[0059] The range of input texture coordinates refers to the range of values ​​for each component of the input texture coordinates. For example, the input texture coordinates can be uv coordinates, where the u component and v component correspond to the width and height directions of the texture, respectively. If the range of input texture coordinates is (-2, 2), then the range of values ​​for the u component and v component is (-2, 2).

[0060] When the input texture coordinates are normalized floating-point numbers, the decimal value of the input texture coordinates is represented as: (-1) sign * 2 (exponent-127) * (1. mantissa When the input texture coordinates range from (-2, 2), in order to make 2 (exponent-127) * (1.mantissa) < 2, that is, 2 (exponent-127) < 2 / (1.mantissa). Since 1 ≤ (1.mantissa) < 2, therefore 1 < 2 / (1.mantissa) ≤ 2. To make 2 (exponent-127) <2 / (1.mantissa), according to the property of exponent, exponent-127≤0, that is, when the range of the input texture coordinates is (-2, 2), the exponent of the input texture coordinates in floating-point format is ≤0. When the input texture coordinates are denormalized floating-point numbers, exponent is always equal to 0, so the exponent of the input texture coordinates in floating-point format can be -126.

[0061] In some embodiments, when exponent - 127 ≤ 0 or exponent = 0, the input texture coordinates in floating-point format should be right-shifted when converting to fixed-point numbers. Converting a floating-point number to a fixed-point number means adjusting the value of the floating-point number to within the range and precision that a fixed-point number can represent. During the conversion, a shift operation is required to match the format of the fixed-point number. In normalized floating-point numbers, if exponent - 127 ≤ 0, the exponent of the floating-point number is ≤ 0. To convert it to a fixed-point number, the floating-point number needs to be right-shifted. The right shift operation is equivalent to shrinking the value so that the significant bits of the floating-point number can fit the fractional part of the fixed-point number, thus achieving a proper conversion from floating-point to fixed-point. In denormalized floating-point numbers, when exponent = 0, its exponent can be -126. This value is very small and needs to be adjusted to within the range and precision that a fixed-point number can represent through a right shift operation.

[0062] It should be understood that the aforementioned right shift operation typically involves rounding, which leads to a loss of precision in the calculation result. By limiting the range of the input texture coordinates to (-2, 2), the exponent of the input texture coordinates can be ≤0, ensuring that a right shift operation is performed when converting the floating-point number to a fixed-point number, thus guaranteeing the necessity of the method execution. In other words, when the range of the input texture coordinates is not (-2, 2), a left shift operation will be performed when converting the floating-point number to a fixed-point number, and the left shift operation does not involve rounding. In this case, it is not within the scope of the optimization scheme of this application.

[0063] A multiplier is a hardware unit in the ALU used to perform multiplication operations. In this case, it calculates the product of the mantissa of the input texture coordinates and the texture size to obtain the first product. In this method, the input texture coordinates are not first right-shifted to convert them to fixed-point numbers; instead, the product of the mantissa of the input texture coordinates and the texture size is directly calculated, thus avoiding the precision loss caused by rounding operations.

[0064] The first conversion unit 12 is used to left-shift the input offset by N bits, where N is determined based on the exponent of the input texture coordinates. It can be understood that N refers to the absolute value of the exponent of the input texture coordinates. If the exponent of the input texture coordinates is ≤0, a right shift operation is required when converting the input texture coordinates from floating-point format to fixed-point format. Optionally, when the input texture coordinates are normalized floating-point numbers, N is the absolute value of exponent – ​​127. Optionally, when the input texture coordinates are denormalized floating-point numbers, N can be the absolute value of -126 (i.e., 126).

[0065] Shifting the input offset to the left by N bits can be an arithmetic shift operation or a logical shift operation. It's understandable that in the above steps, the input texture coordinates weren't first converted to fixed-point numbers; instead, the mantissa of the input offset was directly multiplied by the texture size. This leads to a mismatch in the magnitude of the data during subsequent addition operations. To ensure that the first product and the input offset are of appropriate magnitude during addition operations in adder 13, the input offset needs to be shifted to the left by N bits. This makes the magnitude of the shifted input offset match the magnitude of the first product, ensuring that each data bit participates appropriately in the addition operation, thereby guaranteeing the accuracy of the first calculation result determined by adder 13.

[0066] An adder is a hardware unit in the ALU used to perform addition operations. Adder 13 is used to calculate the sum of the first product and the shifted input offset to obtain the first calculation result.

[0067] In some embodiments, on the one hand, the first calculation result is right-shifted because, in the above process, the input texture coordinates were not right-shifted first, and the first conversion unit 12 shifted the input offset to the left by N bits. The left shift operation changed the original data magnitude of the input offset. Therefore, one purpose of right-shifting the first calculation result is to restore the data to a suitable magnitude. By right-shifting, the influence of the previous left shift operation on the data magnitude can be eliminated, allowing the result to return to the actual value. On the other hand, right-shifting the first calculation result is to convert the first calculation result into a second calculation result that conforms to a preset format (such as a preset point number format). By right-shifting, the binary representation of the first calculation result can be adjusted to meet the requirements of the preset format.

[0068] In some embodiments, the second conversion unit 14 is further configured to determine the value of M based on the number of decimal places q in the preset point format, the number of decimal places j indicated by the mantissa of the input texture coordinates, and N, wherein M = j – q + N.

[0069] A preset decimal point format refers to a pre-defined format for representing fixed-point numbers, in which the position of the decimal point is fixed, predetermined, and remains unchanged throughout the data representation. It divides a number into an integer part and a decimal part, representing these two parts separately through a specific allocation of digits. For example, a preset decimal point format could be s pq, where p ≥ t + 2; otherwise, precision loss in the integer part would occur.

[0070] Shifting the first calculation result right by j – q bits is to match the number of decimal places in the first calculation result with the number of decimal places q in the preset point format. The number of bits indicated by the mantissa of the input texture coordinates is j. Shifting the first calculation result right by j - q bits is equivalent to adjusting the decimal part of the first calculation result. Optionally, if j > q, the right shift operation will reduce the number of decimal places, removing unnecessary precision and making the data format more consistent with the preset point format. This ensures that subsequent processing can be performed according to the predefined format, avoiding calculation errors or precision loss due to inconsistent decimal places. For example, if j = 10 and q = 8, shifting right by 10 - 8 = 2 bits will adjust the original 10-decimal-place first calculation result to 8 decimal places, consistent with the preset point format.

[0071] Shifting the first calculation result to the right by N bits is to restore the first calculation result to an appropriate magnitude. The right shift operation eliminates the impact of the previous left shift operation on the data magnitude, allowing the result to return to its actual value.

[0072] The above method only requires one right shift operation to convert the first calculation result into a second calculation result in a preset point format, reducing the number of right shift operations and improving the accuracy of the second calculation result.

[0073] Rounding mode refers to the method of approximating a value according to different rules when processing the first calculation result after shifting to obtain the second calculation result. Rounding modes can include rounding to the nearest, rounding up, rounding down, and rounding to even numbers, etc., and this application does not limit this. Different rounding modes are suitable for different application scenarios to meet different requirements for calculation accuracy and error. Please refer to the description below for the specific rounding process.

[0074] In summary, the technical solution provided in this application does not first shift the input texture coordinates to the right by a fixed number of points, but directly calculates the product of the mantissa of the input texture coordinates and the texture size. Furthermore, it does not perform a shift operation on the calculated product. This method only requires one uniform right shift operation to obtain the second calculation result in a preset point format. Compared with related technologies, this method reduces the number of right shift operations, thereby reducing the precision loss caused by rounding operations and making the determined texel index more accurate.

[0075] The following describes the specific implementation method for determining the first calculation result.

[0076] In some embodiments, the data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits, where j is the number of bits indicated by the mantissa of the input texture coordinates.

[0077] The first conversion unit is used to convert the input offset into an input offset of a first extended format according to the data format of the first product. The first extended format refers to a signed fixed-point number with an integer part of t bits and a fractional part of j bits. The input offset of the first extended format is shifted left by N bits to obtain the shifted input offset.

[0078] Optionally, when the input texture coordinates are in fp32 floating-point format, j = 23. t is the percentage of bits used to represent the input offset.

[0079] The first extended format is also a fixed-point number in s tj format. Optionally, the input offset can be a signed fixed-point number in s xy format. The first conversion unit 12 is used to convert the input offset in s xy format to an input offset in s tj format. The integer part x of the input offset in s xy format may not match t, ​​and the fractional part y of the input texture coordinate may not match y. For example, x can be less than t, and y can be less than j. The first conversion unit performs extension operations on the integer and fractional parts respectively. Based on the sign of the input offset and the code system of the input offset, it can be determined whether to pad the high bits of the integer part and the low bits of the fractional part with 1s or 0s. The code system can include: sign-magnitude, two's complement, one's complement, etc. For example, when the input offset is in two's complement format and the input offset is negative, 1 bits can be padded to the high-order bits of the integer part to reach t bits, and 0 bits can be padded to the low-order bits of the fractional part to reach j bits, thereby converting the input offset in s xy format to the input offset in s tj format. In some embodiments, the input offset can also be in original code format. When the input offset is positive, when converting the input offset in s xy format to the input offset in s tj format, 0 bits can be padded to the high-order bits of the integer part to reach t bits, and 0 bits can be padded to the low-order bits of the fractional part to reach j bits. This application does not limit this.

[0080] The above method unifies the format of the input offset and the first product to a fixed-point number format with the integer part being t bits and the fractional part being j bits, facilitating accurate addition operations by the subsequent adder. Specifically, after unifying the format, the adder can directly sum the data, avoiding errors caused by format mismatch.

[0081] In some embodiments, the first product is in sign-magnitude format, and the shifted input offset is in two's complement format; the data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits. The first conversion unit 12 is used to convert the format of the first product from sign-magnitude format to two's complement format based on the sign bit of the input texture coordinates, obtaining a first product in two's complement format; the sign bit and the first product in two's complement format are extended by 1 bit to the higher bits to obtain a first product in a second extended format, where the first product in the second extended format is a signed fixed-point number with an integer part of t+1 bits and a fractional part of j bits.

[0082] The first conversion unit 12 is used to extend the shifted input offset by 1 bit to the higher bit to obtain the input offset in the third extended format.

[0083] Adder 13 is used to calculate the sum of the first product of the second extended format and the input offset of the third extended format to obtain the first calculation result.

[0084] In some embodiments, the first product of the second extended format is also a fixed-point number in the s(t+1).j format.

[0085] The aforementioned sign-magnitude and two's complement are different binary code systems, meaning different representations of binary. Sign-magnitude and two's complement are two distinct encoding methods. In sign-magnitude representation, the highest bit is used as the sign bit, where 0 represents a positive number and 1 represents a negative number, while the remaining bits represent the absolute value of the number. For example, for an 8-bit binary number, the sign-magnitude representation of +5 is 00000101, and the sign-magnitude representation of -5 is 10000101. The advantage of sign-magnitude is its intuitiveness; the magnitude and sign of the value are immediately apparent. However, it is more complex when performing addition and subtraction operations because the sign bit is needed to determine whether to perform addition or subtraction. Two's complement has a significant advantage in addition and subtraction operations. The two's complement of a positive number is the same as its sign-magnitude representation, while the two's complement of a negative number is obtained by inverting all the numerical bits of its sign-magnitude representation and then adding 1. Taking an 8-bit binary number as an example, the two's complement of +5 is also 00000101, while the original code of -5 is 10000101. Its two's complement is obtained by first inverting the value bits 0000101 to get 1111010, and then adding 1 to get 1111011. Using two's complement can convert subtraction into addition, simplifying the computer's calculation logic, improving calculation efficiency, and also avoiding the problem of having two representations of "+0" and "-0" in the original code.

[0086] In some embodiments, the sign of the input offset is used to determine whether a bit 1 or a bit 0 is added to the higher bits during the first product extension. For example, suppose the first product in two's complement format is a 4-bit positive binary number, such as the two's complement of +3 (0011). When extending by one bit to the higher bits, the sign bit is 0, and the 0 is copied to the new highest bit, resulting in the extended 5-bit binary number 00011. If the first product in two's complement format is a 4-bit negative binary number, such as the two's complement of -3 (1101), the sign bit 1 is copied to the new highest bit during extension, resulting in the extended 5-bit binary number 11101. The sign bit of a negative number is 1, so it still represents a negative number after extension, and the characteristics of two's complement ensure that the value remains unchanged after extension. The specific implementation of extending the shifted input offset by one bit to the higher bits to obtain the input offset in the third extended format is similar and will not be elaborated here.

[0087] In some embodiments, the first conversion unit 12 is further configured to convert the format of the input offset from the original code format to the two's complement format based on the sign bit of the input offset. For specific conversion methods, please refer to the corresponding description above.

[0088] The above method, when performing addition, will overflow if the sum of the two numbers exceeds the range that the current data bits can represent, leading to an incorrect calculation result. By extending the input offset of the first extended format and the first product by one bit to the higher bits, the range of data representation can be increased, the risk of overflow can be reduced, and subsequent addition operations can be made more reliable.

[0089] The specific implementation method for determining the second calculation result is described below.

[0090] In some embodiments, the second conversion unit 14 is used to extend the first calculation result by 1 bit to the higher bits to obtain the first calculation result in an extended format; and to right-shift the first calculation result in an extended format by M bits to obtain the first calculation result after shifting.

[0091] During computation, if a carry operation is required and bit extension is not performed, data overflow may occur. For example, a 4-bit signed integer represented in two's complement is binary 0111 (corresponding to decimal 7). When a carry operation is performed, that is, adding 1 to the least significant bit, the result becomes 1000 (decimal -8). Originally, positive numbers were added, but the result became negative, which clearly does not conform to normal mathematical operation logic; this is an overflow. Extending the high-order bits of the first calculated result after shifting can prevent this overflow from occurring.

[0092] In some embodiments, the first calculation result after shifting is a two's complement. The sign of the sign bit of the first calculation result after shifting is used to determine whether to pad the higher-order bits with a 1 or a 0. For example, if the sign bit of the first calculation result after shifting is 0, it indicates that the number is positive, and when extending it by 1 bit, a 0 should be added to the extension bit. For example, if the sign bit of the first calculation result after shifting is 1, it indicates that the number is negative, and when extending it by 1 bit, a 1 should be added to the extension bit.

[0093] In some embodiments, the first calculation result may be shifted right by M bits and then extended by 1 bit to the higher bits. This application does not limit this.

[0094] The above method ensures the accuracy of the second calculation result by extending the high-order bits of the first calculation result by 1 bit to avoid overflow that may be caused by subsequent carry operations.

[0095] In some embodiments, the second conversion unit 14 is used to determine the carry character based on the rounding mode and the lower M bits of the first calculation result; and to determine the second calculation result based on the carry character and the shifted first calculation result.

[0096] Rounding is a common method used when truncating or approximating numerical values. Its purpose is to reduce the number of digits while minimizing the error caused by truncation. Different rounding modes (such as rounding up, rounding down, rounding to the nearest even number, truncation, rounding to the nearest even number, etc.) require certain rules to determine whether to carry over. Since the first calculation result is shifted right by M bits, the lower M bits of the first calculation result contain the truncated part of the data. By analyzing this truncated part of the data, it can be determined whether to carry over.

[0097] Here, the carry character (rnd) refers to the binary carry character. For example, suppose the first calculation result is an 8-bit binary number 10111111. Assuming precision control is needed, only the high 4 bits are retained, i.e., M = 4. Using rounding mode, the low 4 bits are 1111. Since the highest bit of the low 4 bits is 1, and there are subsequent non-zero bits, according to the rounding rules, a carry is needed, so the carry character is determined to be 1. For example, suppose the first calculation result is an 8-bit binary number 10110101. Assuming precision control is needed, only the high 4 bits are retained, i.e., M = 4. Using rounding mode, the low 4 bits are 0101. Since the highest bit of the low 4 bits is 0, and there are subsequent non-zero bits, according to the rounding rules, no carry is needed, so the carry character is determined to be 0.

[0098] The above method can flexibly and accurately determine the carry based on the lower M bits of the first calculation result, thereby reducing the rounding error caused by the right shift operation.

[0099] In some embodiments, the second conversion unit 14 is configured to perform a carry operation on the shifted first calculation result to obtain a second calculation result when the carry sign is equal to 1; or, the second conversion unit 14 is configured to determine the shifted first calculation result as the second calculation result when the carry sign is equal to 0.

[0100] In some embodiments, the second conversion unit 14 is used to add 1 to the least significant bit of the first calculation result in the extended format when the carry symbol is equal to 1, to obtain the second calculation result.

[0101] When the carry sign is 1, it indicates that based on the rounding mode and the lower M bits of the first calculation result, a carry operation needs to be performed on the shifted first calculation result. A carry operation typically involves adding 1 to the higher bit in binary arithmetic. For example, in an 8-bit binary arithmetic operation, if the first calculation result after shifting is 01111110, and the carry sign is 1, performing a carry operation means adding 1 to 01111110, resulting in 01111111. This method yields the final second calculation result, demonstrating the carry-up situation in rounding operations.

[0102] When the carry sign is 0, it means that no carry is needed. In this case, the second conversion unit 14 directly determines the first calculation result after shifting as the second calculation result. That is, in the rounding judgment, the current shifted result already meets the precision requirements or does not need to be adjusted, so it is directly used as the final result. For example, if the first calculation result after shifting is 10101010 with a carry sign of 0, then the second calculation result is 10101010.

[0103] The above method can accurately determine the second calculation result based on the carry sign.

[0104] The following describes the specific implementation method for determining the texel index.

[0105] In some embodiments, the second calculation result includes an integer part and a fractional part. When the sampling mode of the input texture coordinates is configured as a single-point sampling mode, the texel index is determined based on the integer part; or, when the sampling mode of the input texture coordinates is configured as a bilinear sampling mode, the texel index is determined based on the integer part and the fractional part.

[0106] Tessellation indexing is used to accurately locate texels in a texture image. Point sampling, also known as single-point sampling, is a simple and direct texture sampling method. When the input texture coordinates are configured for point sampling, the system ignores the decimal part of the texture coordinates and determines the texel index based solely on the integer part. Optionally, the integer part can be divided by the texture size to obtain the texel index.

[0107] Bilinear sampling, or bilinear interpolations sampling, is a method used to improve texture sampling quality. When the sampling mode of the input texture coordinates is configured for bilinear sampling, the determination of the texel index depends not only on the integer part of the texture coordinates but also on the fractional part. Specifically, the integer part can be used to determine the position of at least one (e.g., two) texels around the current sampling point. For example, for the u direction, if the integer part of the second calculation result is (u = 100), then texels u = 100 and u = 101 can be selected as references; for the v direction, if the integer part is (v = 150), then texels v = 150 and v = 151 can be selected as references. Thus, the integer part determines the four texels surrounding the current sampling point: (u = 100, v = 150), (u = 100, v = 151), (u = 101, v = 150), and (u = 101, v = 151). The fractional part determines the weight of these four reference texels in the final sampling result. Taking the u direction as an example, assuming the fractional part of the second calculation result is u_1, u_1 represents the relative position of the current sampling point between the texels u = 100 and u = 101. The closer u_1 is to 0, the closer the sampling point is to the texel u = 100, and the greater the weight of the texel u = 100 in the final sampling result; conversely, the closer u_1 is to 1, the closer the sampling point is to the texel u = 101, and the greater the weight of the texel u = 101. Specifically, the weight of a texel of u = 100 can be represented as 1 - u_1, and the weight of a texel of u = 101 can be represented as u_1. Similarly, the same applies to the v direction. During bilinear interpolation, linear interpolation is first performed in the u direction for the texels (u = 100, v = 150) and (u = 101, v = 150), and for the texels (u = 100, v = 151) and (u = 101, v = 151), respectively, to obtain two intermediate values. Then, linear interpolation is performed in the v direction on these two intermediate values ​​to finally obtain the texture index of the current sampling point.

[0108] The above method and the calculation scheme of this application are applicable to both single-point and dual-line configurations. The configuration method can be flexibly selected according to requirements to determine the texel index.

[0109] In some embodiments, such as Figure 2 As shown, it illustrates a schematic diagram of the ALU in another possible implementation of this application.

[0110] The ALU 10 also includes a third conversion unit 15.

[0111] The third conversion unit 15 is used to extend the high-order bits of the mantissa of the input texture coordinates by 1 bit to obtain the mantissa in the extended format.

[0112] Multiplier 11 is used to calculate the product of the mantissa of the extended format and the texture size to obtain the first product.

[0113] In some implementations, the high-order bits of the mantissa of the input texture coordinates are extended by 1 bit, that is, bit 1 is added to the high-order bits, so the mantissa of the extended format is an unsigned fixed-point number of 1.j.

[0114] The first, second, and third conversion units mentioned above can be the same conversion unit or they can be different; this application does not limit this.

[0115] The above method, before performing a multiplication operation, will cause an overflow if the result of multiplying the two numbers exceeds the range that the current data bits can represent, leading to an incorrect calculation result. By extending the mantissa of the input texture coordinates by one bit to the higher bits, the range of data representation can be increased, the risk of overflow can be reduced, and subsequent multiplication operations can be made more reliable.

[0116] The following example illustrates the calculation method of texel index, using an input texture coordinate format of fp32, a texture size of t-bit positive integer, an input offset of signed fixed-point number s xy, and a preset fixed-point format of the second calculation result of s pq. For the fp32 input texture coordinates, sign (sign bit) = coordinate

[31] , exponent (exponent) = coordinate[30:23], and mantissa (mantissa) = {|exponent, coordinate[22:0]}. The above method may include the following steps S1~S7.

[0117] In step S1, the third conversion unit extends the high-order bits of the mantissa of the input texture coordinates by 1 bit to obtain the mantissa in the extended format.

[0118] The mantissa of the input texture coordinates corresponds to coordinate[22:0] above. Extend the high bit of the mantissa of the input texture coordinates by 1 bit, and the mantissa of the extended format is an unsigned fixed-point number in the format of 1.23.

[0119] In step S2, the multiplier calculates the product of the mantissa of the extended format and the texture size to obtain the first product.

[0120] The texture size is a positive integer of t bits. The product of the mantissa of the extended format and the texture size, i.e. the first product, is an unsigned fixed-point number in t.23 format.

[0121] Step S3: The first conversion unit converts the input offset into a signed fixed-point number with an integer part of t bits and a fractional part of j bits according to the data format of the first product, to obtain the input offset in the first extended format; the input offset in the first extended format is shifted left by N bits to obtain the shifted input offset.

[0122] When j=23, the first conversion unit converts the input offset into a signed fixed-point number with an integer part of t bits and a fractional part of 23 bits. Therefore, the input offset in the first extended format is an unsigned fixed-point number in the t.23 format. Furthermore, the first conversion unit shifts the input offset in the first extended format left by N bits to obtain the shifted input offset.

[0123] Alternatively, N = the absolute value of exponent - 127. Alternatively, N = the absolute value of -126, which is 126.

[0124] In step S4, the first conversion unit converts the format of the first product from the original code format to the two's complement format based on the sign bit of the input texture coordinates, and obtains the first product in two's complement format; the sign bit and the first product in two's complement format are extended by 1 bit to the higher bits to obtain the first product in the second extended format.

[0125] The first conversion unit extends the shifted input offset by 1 bit to the higher bit to obtain the input offset in the third extended format.

[0126] The adder calculates the sum of the first product of the second extended format and the input offset of the third extended format to obtain the first calculation result.

[0127] The first conversion unit extends the product of the shifted input offset and the first product in two's complement format by one bit to the higher bits, thus obtaining the first calculation result in the format s(t+1).23. The shifted input offset is in two's complement format.

[0128] Step S6: The second conversion unit extends the first calculation result by 1 bit to the higher bits to obtain the first calculation result in extended format; and shifts the first calculation result in extended format to the right by M bits to obtain the first calculation result after shifting.

[0129] The first calculation result of the extended format is a fixed-point number in the format s(t+2).23. In some embodiments, the second conversion unit determines the value of M based on the number of decimal places q in the preset fixed-point format, the number of decimal places j indicated by the mantissa of the input texture coordinates, and N, where M = j – q + N. By right-shifting the first calculation result of the extended format by M bits, it can be ensured that the second calculation result is a fixed-point number in the format s(t+2).q.

[0130] Step S7: Determine the texel index based on the second calculation result.

[0131] In some embodiments, when the sampling mode of the input texture coordinates is configured as single-point sampling, the texel index is determined based on the integer part; or, when the sampling mode of the input texture coordinates is configured as bilinear sampling, the texel index is determined based on both the integer and fractional parts.

[0132] For details not covered above, please refer to the corresponding descriptions above; they will not be elaborated upon here.

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

[0134] Please refer to Figure 3 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 conversion unit, an adder, and a second conversion unit. The method may include at least one of steps 310-340. It should be noted that this application does not limit the execution order of steps 310-340.

[0135] Step 310: The multiplier calculates the product of the mantissa of the input texture coordinates in floating-point format and the texture size to obtain the first product, whereby the texture size is used to indicate the size of the texture image.

[0136] Step 320: The first conversion unit shifts the input offset to the left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates.

[0137] Step 330: The adder calculates the sum of the first product and the shifted input offset to obtain the first calculation result.

[0138] Step 340: The second conversion unit shifts the first calculation result to the right by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, a second calculation result is obtained. The second calculation result is used to determine the texel index corresponding to the input texture coordinates, where M is a positive integer and is determined based on N.

[0139] In some embodiments, the data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits, where j is the number of bits indicated by the mantissa of the input texture coordinates; the first conversion unit shifts the input offset to the left by N bits to obtain the shifted input offset, including: the first conversion unit converts the input offset into an input offset of a first extended format according to the data format of the first product, wherein the first extended format refers to a signed fixed-point number with an integer part of t bits and a fractional part of j bits; and shifts the input offset of the first extended format to the left by N bits to obtain the shifted input offset.

[0140] In some embodiments, the format of the first product is original code, the format of the shifted input offset is two's complement, and the data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits. The method further includes: the first conversion unit converts the format of the first product from the original code to the two's complement based on the sign bit of the input texture coordinates to obtain the first product in the two's complement format; the first product in the two's complement format is extended by 1 bit to the higher bits to obtain the first product in the second extended format, wherein the first product in the second extended format is a signed fixed-point number with an integer part of t+1 bits and a fractional part of j bits; the first conversion unit extends the shifted input offset by 1 bit to the higher bits to obtain the input offset in the third extended format; the adder calculates the sum of the first product and the shifted input offset to obtain a first calculation result, including: the adder calculates the sum of the first product in the second extended format and the input offset in the third extended format to obtain the first calculation result.

[0141] In some embodiments, the first conversion unit shifts the input offset to the left by N bits to obtain the shifted input offset, including: the second conversion unit extends the first calculation result by 1 bit to the higher bits to obtain the first calculation result in an extended format; and shifts the first calculation result in the extended format to the right by M bits to obtain the shifted first calculation result.

[0142] In some embodiments, obtaining a second calculation result based on the shifted first calculation result and the rounding mode includes: the second conversion unit determining a carry character based on the rounding mode and the lower M bits of the first calculation result; and determining the second calculation result based on the carry character and the shifted first calculation result.

[0143] In some embodiments, determining the second calculation result based on the carry symbol and the shifted first calculation result includes: the second conversion unit performing a carry operation on the shifted first calculation result when the carry symbol is equal to 1 to obtain the second calculation result; or, the second conversion unit determining the shifted first calculation result as the second calculation result when the carry symbol is equal to 0.

[0144] In some embodiments, the second conversion unit determines the value of M based on the number of decimal places q in the preset point format, the number of decimal places j indicated by the mantissa of the input texture coordinates, and N, where M = j – q + N.

[0145] In some embodiments, the second calculation result includes an integer part and a fractional part; when the sampling mode of the input texture coordinates is configured as a single-point sampling mode, the texel index is determined based on the integer part; or, when the sampling mode of the input texture coordinates is configured as a bilinear sampling mode, the texel index is determined based on the integer part and the fractional part.

[0146] In some embodiments, the method further includes: the third conversion unit extends the high-order bits of the mantissa of the input texture coordinates by 1 bit to obtain an extended format mantissa; the multiplier calculates the product of the mantissa of the input texture coordinates and the texture size to obtain a first product, including: the multiplier calculates the product of the extended format mantissa and the texture size to obtain the first product.

[0147] 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.

[0148] 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.

[0149] 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.

[0150] 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 conversion unit, an adder, and a second conversion unit; The multiplier is used to calculate the product of the mantissa of the input texture coordinates in floating-point format and the texture size to obtain a first product, wherein the texture size is used to indicate the size of the texture image; The first conversion unit is used to shift the input offset to the left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates; The adder is used to calculate the sum of the first product and the shifted input offset to obtain a first calculation result; The second conversion unit is used to right-shift the first calculation result by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, a second calculation result is obtained, and the second calculation result is used to determine the texel index corresponding to the input texture coordinates, where M is a positive integer and M is determined based on N.

2. The ALU according to claim 1, characterized in that, The data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits, where j is the number of bits indicated by the mantissa of the input texture coordinates; The first conversion unit is used to convert the input offset into an input offset of a first extended format according to the data format of the first product. The first extended format refers to a signed fixed-point number with an integer part of t bits and a fractional part of j bits. The input offset of the first extended format is then shifted left by N bits to obtain the shifted input offset.

3. The ALU according to claim 1, characterized in that, The first product is in sign-magnitude format, the shifted input offset is in two's complement format, and the data format of the first product is an unsigned fixed-point number with an integer part of t bits and a fractional part of j bits. The first conversion unit is configured to convert the format of the first product from the original code format to the two's complement format based on the sign bit of the input texture coordinates, to obtain the first product in the two's complement format; and to extend the sign bit and the first product in the two's complement format by 1 bit to the higher bits, to obtain the first product in the second extended format, wherein the first product in the second extended format is a signed fixed-point number with an integer part of t+1 bits and a fractional part of j bits. The first conversion unit is used to extend the shifted input offset by 1 bit to the higher bit to obtain the input offset in the third extended format; The adder is used to calculate the sum of the first product of the second extended format and the input offset of the third extended format to obtain the first calculation result.

4. The ALU according to claim 1, characterized in that, The second conversion unit is used to extend the first calculation result by 1 bit to the higher bit to obtain the first calculation result in an extended format; and to right-shift the first calculation result in the extended format by M bits to obtain the first calculation result after shifting.

5. The ALU according to claim 4, characterized in that, The second conversion unit is used to determine the carry character based on the rounding mode and the lower M bits of the first calculation result; and to determine the second calculation result based on the carry character and the shifted first calculation result.

6. The ALU according to claim 5, characterized in that, The second conversion unit is configured to perform a carry operation on the shifted first calculation result when the carry symbol is equal to 1, to obtain the second calculation result; or, The second conversion unit is used to determine the shifted first calculation result as the second calculation result when the carry symbol is equal to 0.

7. The ALU according to claim 1, characterized in that, The second conversion unit is further configured to determine the value of M based on the number of decimal places q in the preset point format, the number of decimal places j indicated by the mantissa of the input texture coordinates, and N, wherein M = j – q + N.

8. The ALU according to claim 1, characterized in that, The second calculation result includes an integer part and a decimal part; When the sampling mode of the input texture coordinates is configured as single-point sampling, the texel index is determined based on the integer part; or, When the sampling mode of the input texture coordinates is configured as bilinear sampling, the texel index is determined based on the integer part and the fractional part.

9. The ALU according to claim 1, characterized in that, The ALU also includes: a third conversion unit; The third conversion unit is used to extend the high-order bits of the mantissa of the input texture coordinates by 1 bit to obtain the mantissa of the extended format. The multiplier is used to calculate the product of the mantissa of the extended format and the texture size to obtain the first product.

10. A method for calculating texel indexes applied to an arithmetic logic unit (ALU), characterized in that, The ALU includes: a multiplier, a first conversion unit, an adder, and a second conversion unit; the method includes: The multiplier calculates the product of the mantissa of the floating-point format input texture coordinates and the texture size to obtain a first product, wherein the texture size is used to indicate the size of the texture image; The first conversion unit shifts the input offset to the left by N bits to obtain the shifted input offset, where N is determined based on the exponent of the input texture coordinates; The adder calculates the sum of the first product and the shifted input offset to obtain the first calculation result; The second conversion unit shifts the first calculation result to the right by M bits to obtain the shifted first calculation result; based on the shifted first calculation result and the rounding mode, a second calculation result is obtained. The second calculation result is used to determine the texel index corresponding to the input texture coordinates, where M is a positive integer and M is determined based on N.

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

12. 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 9.

13. 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 9.