A hardware system for format conversion
By using selectors, leading zeros, adders, and shift modules for format conversion, the problem of wasted hardware resources in GPU chips is solved, and flexibility and scalability are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- METAX INTEGRATED CIRCUITS (SHANGHAI) CO LTD
- Filing Date
- 2025-11-26
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies that design dedicated format conversion hardware units for each storage format in GPU chips lead to a waste of hardware resources and make it difficult to save resources when converting multiple formats.
The selector module, leading zero module, adder module, and shifter module are used to uniformly reuse these modules for format conversion, avoiding the need to design dedicated circuits for each format.
It reduces chip area footprint and wiring complexity, improves the flexibility and scalability of format conversion, and can quickly adapt to new graphics API standards or custom texture formats.
Smart Images

Figure CN121213336B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the GPU chip design technical field, in particular to a hardware system for format conversion. BACKGROUND
[0002] Currently, in the texture mapping scene of the GPU chip, it is usually needed to determine the color value corresponding to the position to be mapped on the three-dimensional model from the two-dimensional texture image, and in order to make the texture on the three-dimensional model more smooth, the color values corresponding to multiple coordinates in the two-dimensional texture image are often needed to be interpolated to obtain the color value corresponding to a single position to be mapped on the three-dimensional model.
[0003] In order to save the area of the GPU chip, the GPU chip can only support certain specific format numerical calculation, but the storage format of the color value of the two-dimensional texture image is various due to being stored in the external storage, in order to enable the GPU chip to normally perform interpolation calculation and then perform texture mapping, it is needed to pre-convert the input texture pixel value to obtain the target pixel value of the target pixel format which can be supported by the GPU chip.
[0004] Since the format conversion methods of different storage formats are different, the existing method usually designs a corresponding format conversion hardware unit for each storage format, however, a large number of special format conversion hardware units will consume a large amount of hardware resources.
[0005] Therefore, how to realize multi-format conversion while saving hardware resources has become a problem to be solved. SUMMARY
[0006] In view of the above technical problems, the technical scheme adopted by the present application is:
[0007] A hardware system for format conversion, the system comprises a selector module, a leading zero module, an adder module and a shift module.
[0008] The selector module is used to determine the target symbol bit information in the target pixel format according to the input texture pixel format and the input texture pixel value, and the texture pixel value is binary data.
[0009] The leading zero module is used to determine the first data bit from left to right which is 1 in the texture pixel value, and the first data bit from left to right which is 1 in the texture pixel value is used to determine the first shift value.
[0010] The adder module is used to determine the target exponent bit information in the target pixel format according to the first shift value and the offset value corresponding to the target pixel format.
[0011] The shift module is configured to shift the texture pixel value according to the first shift value, and determine target mantissa bit information in the target pixel format according to a result of the shift processing.
[0012] The target sign bit information, the target exponent bit information and the target mantissa bit information in the target pixel format form a target pixel value conforming to the target pixel format.
[0013] Compared with the prior art, the hardware system for format conversion provided by the present application has obvious beneficial effects, and has the following beneficial effects at least:
[0014] By using the unified multiplexing selector module, the leading zero module, the adder module and the shift module, special circuits are not designed for each format conversion, the chip area occupation and the wiring complexity are greatly reduced, special format conversion hardware resources can be saved in a GPU chip supporting multi-format conversion, and when a target pixel format is added or modified, the hardware structure does not need to be restructured, only parameter configuration adjustment is needed for each reusable module, so that the GPU chip can quickly adapt to new graphics API standards or custom texture formats, and the flexibility and expandability of format conversion are improved. BRIEF DESCRIPTION OF DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0016] Figure 1 A structural schematic diagram of the hardware system for format conversion provided by the present application is provided. DETAILED DESCRIPTION
[0017] The technical solutions in the embodiments of the present application will be described clearly and completely with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0018] The present embodiment provides a hardware system for format conversion, referring to Figure 1 A structural schematic diagram of the hardware system for format conversion provided by the present application is provided. The system comprises a selector module, a leading zero module, an adder module and a shift module.
[0019] The selector module is configured to determine target sign bit information in the target pixel format according to an input texture pixel format and an input texture pixel value, the texture pixel value being binary data.
[0020] The leading zero module is configured to determine a first data bit being 1 from left to right in the texture pixel value, the first data bit being 1 from left to right in the texture pixel value being used to determine a first shift value.
[0021] The adder module is configured to determine target exponent bit information in the target pixel format according to the first shift value and an offset value corresponding to the target pixel format.
[0022] The shift module is configured to perform shift processing on the texture pixel value according to the first shift value, and determine target mantissa bit information in the target pixel format according to a shift processing result.
[0023] The target sign bit information, the target exponent bit information and the target mantissa bit information in the target pixel format form a target pixel value conforming to the target pixel format.
[0024] The texture pixel value can be a color value to be converted in format, and the texture pixel value is stored in an external storage in a texture pixel format. After a GPU chip retrieves a texture image from the external storage, the texture pixel value in the texture image needs to be converted in format. The target pixel format is a data format supported by the GPU chip and is also a target format of the format conversion.
[0025] The offset value can be determined according to the target pixel format. For example, when the target pixel format is a single-precision floating-point number, the offset value is 127, when the target pixel format is a double-precision floating-point number, the offset value is 1023, and so on.
[0026] Specifically, determining the target exponent bit information in the target pixel format according to the first shift value and the offset value corresponding to the target pixel format can mean adding the first shift value and the offset value corresponding to the target pixel format, and using an addition result as the target exponent bit information in the target pixel format.
[0027] It can be known that, since the target pixel format includes sign bits, exponent bits and mantissa bits, the target pixel format in the embodiment is a floating-point number format, and the functions of each multiplexing module when converting an integer format to a floating-point number format are described in the embodiment.
[0028] In one specific implementation, the texture pixel format includes at least an unsigned integer format, a signed integer format, an unsigned normalized decimal format, a signed normalized decimal format, an unsigned scaled integer format, a signed scaled integer format, an unsigned floating-point format, and a signed floating-point format, and the target pixel format includes at least an unsigned floating-point format and a signed floating-point format;
[0029] When the texture pixel format is an unsigned normalized decimal format or a signed normalized decimal format, the shift module is also used to shift the texture pixel value to the left to obtain an approximate value corresponding to the texture pixel value;
[0030] Accordingly, the leading zero module is used to determine the first data bit that is 1 from left to right in the approximate value, and the first data bit that is 1 from left to right in the approximate value is used to determine the first shift value;
[0031] The shift module is used to shift the approximate value according to the first shift value, and determine the target mantissa information in the target pixel format according to the shift processing result.
[0032] The hardware system provided in this embodiment can support format conversion from unsigned integer format, signed integer format, unsigned normalized decimal format, signed normalized decimal format, unsigned scaled integer format, signed scaled integer format, unsigned floating-point format, and signed floating-point format to unsigned floating-point format and signed floating-point format.
[0033] It should be noted that since the only difference between the integer format and the scaled integer format is the additional scaling parameter, the default integer format and the scaled integer format are converted in the same way as other formats.
[0034] Specifically, when the texture pixel format is either unsigned normalized decimal or signed normalized decimal, let the actual value corresponding to the texture pixel value be x. Then, in the normalized decimal format, it can be represented as x / (2 n -1), where n is the bit width of the normalized decimal format. In this embodiment, x / (2 n -1) is approximately x / (2 n ), thus making x / (2 n You can directly shift the decimal point left of the texture pixel value in binary data form corresponding to x to obtain the normalized decimal format representation in binary data form.
[0035] After obtaining the approximate value corresponding to the texture pixel value, the approximate value can be treated as an integer and converted to obtain the target pixel value in floating-point format.
[0036] In a specific implementation, when the texture pixel format is an unsigned floating-point number format or a signed floating-point number format, the adder is further configured to calculate a second shift value according to reference exponent bit information corresponding to the texture pixel value and an offset value corresponding to the texture pixel format.
[0037] The shift module is further configured to perform shift processing on the texture pixel value according to the second shift value to obtain an intermediate value of the texture pixel value in an integer format.
[0038] Correspondingly, the leading zero module is configured to determine a first data bit being 1 from left to right in the intermediate value, and the first data bit being 1 from left to right in the intermediate value is used to determine a first shift value.
[0039] The shift module is configured to perform shift processing on the intermediate value according to the first shift value, and determine target mantissa bit information in the target pixel format according to a result of the shift processing.
[0040] When the format conversion is a floating-point number format conversion with different precisions, the embodiment converts the texture pixel value in the texture pixel format into an intermediate value in an integer format through an adder and a shift module, and then performs format conversion on the intermediate value in the integer format to obtain a target pixel value in a floating-point number format.
[0041] In a specific implementation, the determining of the target sign bit information in the target pixel format according to the input texture pixel format and the input texture pixel value includes:
[0042] When the texture pixel format is signed, a sign bit of the texture pixel value is selected as the target sign bit information in the target pixel format.
[0043] When the texture pixel format is unsigned, a highest bit of the texture pixel value is selected as the target sign bit information in the target pixel format.
[0044] The selector can be a two-way selector, and the selected content is determined according to the sign of the texture pixel. In general, the target pixel format is a signed floating-point number format to meet the IEEE754 standard and improve compatibility.
[0045] Specifically, when the signed format conversion is an unsigned format conversion, the implementer can perform sign processing in a manner such as offset mapping, truncation processing, and absolute value conversion according to requirements.
[0046] In a specific implementation, the specific manner of determining the first shift value according to the first data bit being 1 from left to right in the texture pixel value is that a position corresponding to the first data bit being 1 from left to right in the texture pixel value is subtracted by 1 to obtain the first shift value.
[0047] The position corresponding to the first data bit being 1 from left to right in the texture pixel value refers to the position of the first data bit being 1 from right to left.
[0048] For example, for the texture pixel value 001010, the position corresponding to the first data bit being 1 from left to right is the fourth data bit from left to right, and the first shift value is 3.
[0049] In a specific implementation, the shift processing of the texture pixel value according to the first shift value, and the determination of the target exponent information in the target pixel format according to the shift processing result, include:
[0050] adding a decimal point to the right of the texture pixel value to obtain a temporary value;
[0051] shift processing the decimal point in the first temporary value according to the first shift value to obtain the shift processing result;
[0052] using each data bit after the decimal point in the shift processing result as the target exponent information in the target pixel format.
[0053] The temporary value is the same as the real value represented by the texture pixel value, and the shift processing of the decimal point in the first temporary value according to the first shift value refers to left shift of the decimal point.
[0054] For example, for the texture pixel value 001010, the temporary value is 001010., and the shift processing result of left shift of the decimal point by 3 bits is 1.010 x 2 3 , and the target exponent information is 010.
[0055] In a specific implementation, the texture pixel format includes at least an unsigned floating-point number format and a signed floating-point number format, and the target pixel format includes at least an unsigned integer format, a signed integer format, an unsigned scaled integer format, and a signed scaled integer format.
[0056] The adder is further configured to calculate a second shift value according to reference exponent information corresponding to the texture pixel value and an offset value corresponding to the texture pixel format.
[0057] The shift module is further configured to perform shift processing on the texture pixel value according to the second shift value to obtain a target pixel value conforming to the target pixel format.
[0058] The second shift value can be calculated by subtracting the offset value corresponding to the texture pixel format from the reference exponent information corresponding to the texture pixel value.
[0059] The embodiment describes the functions of the adder module and the shift module when converting the floating-point number format into the integer format.
[0060] In a specific implementation, the texture pixel format at least includes an unsigned floating-point number format and a signed floating-point number format, and the target pixel format at least includes an unsigned normalized decimal format and a signed normalized decimal format.
[0061] The adder is further configured to calculate a second shift value according to the reference exponent bit information corresponding to the texture pixel value and the offset value corresponding to the texture pixel format.
[0062] The shift module is further configured to perform shift processing on the texture pixel value according to the second shift value to obtain an intermediate value of the texture pixel value in the integer format.
[0063] The shift module is further configured to perform shift processing on the intermediate value according to the bit width information corresponding to the target pixel format to obtain a target pixel value conforming to the target pixel format.
[0064] In the embodiment, the functions of the adder module and the shift module when converting the floating-point number format into the normalized decimal format are described.
[0065] In the embodiment, the unified multiplexing selector module, the leading zero module, the adder module and the shift module are used to avoid designing a special circuit for each format conversion, greatly reducing the chip area occupation and the wiring complexity, saving the special format conversion hardware resources in the GPU chip supporting the multi-format conversion, and without reconstructing the hardware structure when adding or modifying the target pixel format, only the parameter configuration adjustment of each reusable module is needed, so that the GPU chip can quickly adapt to the new graphics API standard or the custom texture format, improving the flexibility and scalability of the format conversion.
[0066] Although some specific embodiments of the present application have been described in detail by examples, those skilled in the art should understand that the above examples are only for illustration, but not for limiting the scope of the present application. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the present application. The scope of the present application is defined by the appended claims.
Claims
1. A hardware system for format conversion, characterized in that, The system includes: a selector module, a leading zero module, an adder module, and a shift module; When the target pixel format is an unsigned floating-point number format or a signed floating-point number format, and the input texture pixel format is an unsigned integer format, a signed integer format, an unsigned scaled integer format, or a signed scaled integer format, the selector module is used to determine the target sign bit information in the target pixel format according to the input texture pixel format and the input texture pixel value, where the texture pixel value is binary data; The leading zero module is used to determine the first 1 data bit from left to right in the texture pixel value, and the first 1 data bit from left to right in the texture pixel value is used to determine the first shift value; The adder module is used to determine the target exponent bit information in the target pixel format based on the first shift value and the offset value corresponding to the target pixel format; The shift module is used to shift the texture pixel value according to the first shift value, determine the target mantissa information in the target pixel format according to the shift processing result, and form a target pixel value that conforms to the target pixel format by the target sign bit information, target exponent bit information and target mantissa information in the target pixel format; When the target pixel format is an unsigned floating-point number format or a signed floating-point number format, and the input texture pixel format is an unsigned normalized decimal format or a signed normalized decimal format, the selector module is used to determine the target sign bit information in the target pixel format according to the input texture pixel format and the input texture pixel value; The shift module is used to shift the texture pixel value to the left to obtain an approximate value corresponding to the texture pixel value; The leading zero module is used to determine the first data bit that is 1 from left to right in the approximation value, and the first data bit that is 1 from left to right in the approximation value is used to determine the first shift value; The adder module is used to determine the target exponent bit information in the target pixel format based on the first shift value and the offset value corresponding to the target pixel format; The shift module is used to shift the approximate value according to the first shift value, and determine the target mantissa information in the target pixel format according to the shift processing result; A target pixel value conforming to the target pixel format is composed of the target sign bit information, the target exponent bit information, and the target mantissa bit information in the target pixel format. When the target pixel format is an unsigned floating-point number format or a signed floating-point number format, and the input texture pixel format is an unsigned floating-point number format or a signed floating-point number format, the selector module is used to determine the target sign bit information in the target pixel format according to the input texture pixel format and the input texture pixel value; The adder is used to calculate the second shift value based on the reference exponent bit information corresponding to the texture pixel value and the offset value corresponding to the texture pixel format; The shift module is used to shift the texture pixel value according to the second shift value to obtain the median value of the texture pixel value in integer format; The leading zero module is used to determine the first data bit that is 1 from left to right in the intermediate value, and the first data bit that is 1 from left to right in the intermediate value is used to determine the first shift value; The adder module is further configured to determine the target exponent bit information in the target pixel format based on the first shift value and the offset value corresponding to the target pixel format; The shift module is further configured to shift the intermediate value according to the first shift value, determine the target mantissa information in the target pixel format according to the shift processing result, and form a target pixel value conforming to the target pixel format by the target sign information, target exponent information and target mantissa information in the target pixel format.
2. The hardware system for format conversion according to claim 1, characterized in that, The step of determining the target sign bit information in the target pixel format based on the input texture pixel format and the input texture pixel value includes: When the sign of the texture pixel format is signed, the sign bit of the texture pixel value is selected as the target sign bit information in the target pixel format; When the sign of the texture pixel format is unsigned, the highest bit of the texture pixel value is selected as the target sign bit information in the target pixel format.
3. The hardware system for format conversion according to claim 1, characterized in that, The specific method for determining the first shift value based on the first 1 data bit from left to right in the texture pixel value is as follows: obtain the position corresponding to the first 1 data bit from left to right in the texture pixel value and subtract 1 as the first shift value.
4. The hardware system for format conversion according to claim 1, characterized in that, The step of shifting the texture pixel value according to the first shift value and determining the target mantissa information in the target pixel format according to the shifting result includes: Add a decimal point to the right of the texture pixel value to obtain a temporary value; The decimal point in the temporary value is shifted according to the first shift value to obtain the shifting result; Each data bit after the decimal point in the shifting result is used as the target mantissa information in the target pixel format.
5. The hardware system for format conversion according to claim 1, characterized in that, When the texture pixel format is an unsigned floating-point number format or a signed floating-point number format, and the target pixel format is an unsigned integer format, a signed integer format, an unsigned scaled integer format, or a signed scaled integer format, the adder is used to calculate the second shift value based on the reference exponent bit information corresponding to the texture pixel value and the offset value corresponding to the texture pixel format; The shift module is used to shift the texture pixel value according to the second shift value to obtain a target pixel value that conforms to the target pixel format.
6. The hardware system for format conversion according to claim 1, characterized in that, When the texture pixel format is an unsigned floating-point number format or a signed floating-point number format, and the target pixel format is an unsigned normalized decimal format or a signed normalized decimal format, the adder is used to calculate the second shift value based on the reference exponent bit information corresponding to the texture pixel value and the offset value corresponding to the texture pixel format; The shift module is used to shift the texture pixel value according to the second shift value to obtain the median value of the texture pixel value in integer format; The shifting module is further configured to shift the intermediate value according to the bit width information corresponding to the target pixel format to obtain a target pixel value that conforms to the target pixel format.
Citation Information
Patent Citations
Fixed point and floating point converter, processor, method and storage medium
CN111796798A
Data format conversion device and method, electronic equipment and computer storage medium
CN120848840A