Color value determination method and apparatus, electronic device, computer storage medium and computer program product
By obtaining the shift color value of the texel and performing the reduction processing, the problem that the graphics processor needs to configure multiple filtering units during texture filtering is solved, and efficient filtering of different texture formats is achieved, saving hardware space.
Patent Information
- Application Number
- PCT/CN2024/129965
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-15
- Filing Date
- 2024-11-05
- Publication Date
- 2025-06-19
AI Technical Summary
When performing texture filtering, existing graphics processors need to configure different filtering units to adapt to different texture formats, resulting in a large space occupancy.
By obtaining the shift color value of each texel, determining the pixel color value based on the influence factor and shift color value, and restoring the texture format according to the texture format, the texture filtering of different texture formats is achieved.
Reduces the footprint of the hardware module during texture filtering, thereby saving the footprint of the graphics processor.
Smart Images

Figure CN2024129965_19062025_PF_FP_ABST
Abstract
Description
Color value determination method and device, electronic device, computer storage medium, and computer program product
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] The embodiments of the present disclosure are based on Chinese patent application number 202311733451.1, application date December 15, 2023, and application name “Method and device for determining color value, electronic device, and computer storage medium”, and claim the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into the present disclosure as a reference. Technical Field
[0003] The present disclosure relates to, but is not limited to, the field of image processing technology, and in particular to a method and device for determining a color value, an electronic device, a computer storage medium, and a computer program product. Background Art
[0004] For pixels using texture maps, the graphics processing unit (GPU) typically determines their color values through texture filtering. Due to the variety of texture formats available, the structures of the filtering units used for texture filtering vary. To meet the texture filtering requirements for different texture formats, the GPU's filtering module must be configured with different filtering units, resulting in a large GPU footprint.
[0005] Summary of the Invention
[0006] Embodiments of the present disclosure provide a method and apparatus for determining a color value, an electronic device, a computer storage medium, and a computer program product.
[0007] The technical solution of the present disclosure is achieved as follows:
[0008] The present disclosure provides a method for determining a color value, including:
[0009] Obtain a shifted color value of each texel among multiple texels that affect a target pixel; the shifted color value of each texel is obtained by performing a first shift processing on the texel color value of the texel according to the texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same; based on the influence factor of each texel on the target pixel and the shifted color value of each texel, determine the pixel color value of the target pixel; restore the pixel color value according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel.
[0010] The present disclosure provides a device for determining a color value, including:
[0011] an acquisition module, configured to acquire a shifted color value of each texel among a plurality of texels affecting a target pixel; the shifted color value of each texel is obtained by performing a first shift processing on the texel color value of the texel according to a texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same;
[0012] a determination module, configured to determine a pixel color value of a target pixel based on an influence factor of each texel on the target pixel and a shifted color value of each texel;
[0013] The restoration module is used to restore the pixel color value according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel.
[0014] An embodiment of the present disclosure provides an electronic device, including:
[0015] Memory for storing computer programs;
[0016] The processor is configured to execute the above-mentioned method for determining the color value when the computer program is running.
[0017] An embodiment of the present disclosure provides a computer storage medium having executable instructions stored thereon, which are used to implement the above-mentioned method for determining the color value when executed by a processor.
[0018] An embodiment of the present disclosure provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are run on an electronic device, the electronic device executes the above-mentioned method for determining a color value.
[0019] The disclosed embodiments provide a method and apparatus for determining color values, an electronic device, a computer storage medium, and a computer program product. Since the shifted color value is obtained by performing a first shift process on the original texture color value extracted from the texel by the electronic device, the decimal and integer digits of the decimal values of the shifted color values of texels of different texture formats are the same; thus, the electronic device can use a hardware module of the same structure when processing the shifted color value, and then configure a hardware module for restoration processing for different texture formats, thereby achieving texture filtering for different texture formats. This can reduce the space occupied by the hardware module during texture filtering, thereby saving space occupied by the graphics processor in the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings required for use in the embodiments of the present disclosure will be described below.
[0021] The accompanying drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to explain the technical solutions of the present disclosure.
[0022] FIG1 shows a schematic diagram of relative positions of pixels and texels provided by an embodiment of the present disclosure;
[0023] FIG2 shows a schematic diagram of the hardware structure of a texture filtering unit in a floating-point format in a related art provided by an embodiment of the present disclosure;
[0024] FIG3 shows a schematic diagram of the hardware structure of a texture filtering unit in a normalized format in a related art provided by an embodiment of the present disclosure;
[0025] FIG4 shows a schematic structural diagram of a texture filtering unit provided by an embodiment of the present disclosure;
[0026] FIG5 shows a first flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0027] FIG6 shows a second flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0028] FIG7 shows a third flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0029] FIG8 shows a fourth flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0030] FIG9 shows a fifth flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0031] FIG10 shows a sixth flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0032] FIG11 shows a seventh flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0033] FIG12 shows a flowchart of a method for determining a color value according to an embodiment of the present disclosure;
[0034] FIG13 shows a ninth flow chart of a method for determining a color value provided by an embodiment of the present disclosure;
[0035] FIG14 shows a flowchart diagram 10 of a method for determining a color value provided by an embodiment of the present disclosure;
[0036] FIG15 shows a first structural diagram of a device for determining a color value provided by an embodiment of the present disclosure;
[0037] FIG16 shows a second structural diagram of a device for determining a color value provided by an embodiment of the present disclosure;
[0038] FIG17 shows a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0039] In order to make the purpose, technical solutions and advantages of the present disclosure clearer, the present disclosure will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limiting the present disclosure. All other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0040] In the following description, reference is made to “some embodiments”, which describes a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0041] In the following description, the terms "first\second\third" are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with the specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0042] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art in the art of the present disclosure. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0043] To facilitate understanding of the present solution, before describing the embodiments of the present disclosure, the application background of the embodiments of the present disclosure will be described.
[0044] Texture filtering is a method of calculating the color value of a pixel using a material map using one or more adjacent texels. Texture filtering includes linear filtering and nonlinear filtering. Since pixels and texels often do not completely overlap, the center point of a pixel may not be the center point of a texel, and the texels that affect the texture of a pixel may include one or more texels. Taking bilinear filtering as an example, the relative positions of pixels and texels are shown in Figure 1. The 16 texels include texel 0-texel 15. The box surrounded by dotted lines represents a pixel. The color value C of the pixel can be generated based on the color value C0 of texel 5, the color value C1 of texel 6, the color value C2 of texel 9, and the color value C3 of texel 10, as shown in formula (1). C=C0×W0+C1×W1+C2×W2+C3×W3 Formula (1)
[0045] Among them, W i For the corresponding C i The weighted coefficient represents the color value C of the pixel i The size of the influence, i is any one of 0-3. Based on formula (1), the texture filter unit may include an adder and a multiplier. Due to the diversity of texture formats, the composition of color values of different texture formats may be different, and the number of bits may also be different. In this way, in texture filter units of different texture formats, the preset number of bits of adders and multipliers may be different, and a shifter is also required for texture filter units containing exponents. Therefore, the hardware structure of texture filter units of different texture formats may be different.
[0046] As an example, the hardware structure of a texture filter unit in a floating-point format in the related art is shown in FIG2 . The texture filter unit is used to perform texture filtering on a 32-bit floating-point format. The texture filter unit includes an acquisition module 2001 (including acquisition units 1-4), a multiplier module 2002 (including multipliers 1-4), an exponent comparator 2003, a right shifter module 2004 (including right shifters 1-4), an adder 2005, and an exponent normalization module 2006. The acquisition module 2001 is used to extract color information from the corresponding texel; the color information includes color values s1-s4; the multiplier module 2002, the exponent comparator 2003, the right shifter module 2004, and the adder 2005 are used to perform an operation based on formula (1), and then convert the operation result into a floating-point format through the exponent normalization module 2006.
[0047] FIG3 shows a hardware structure of a texture filter unit in a normalized format in a related art. The texture filter unit is used to perform texture filtering on unorm24. As shown in FIG3 , the texture filter unit includes an acquisition module 3001 (including acquisition units 5-8), a multiplier module 3002 (including multipliers 5-8), an adder 3003, and a rounding module 3004. The acquisition module 3001 is used to extract the color value (including s5-s8) from the corresponding texel; the multiplier module 3002 and the adder 3003 are used to perform the operation based on formula (1), and then the operation result is converted into a normalized format through the rounding module 3004.
[0048] The structure of a texture filter unit in the related art is shown in Figure 4. The texture filter unit includes: a multiplexer 4001, an integer texture filter unit 4002, and a floating-point texture filter unit 4003. Specifically, the multiplexer 4001 is used to transmit the color value of the texture format to the filter unit corresponding to the texture format (integer texture filter unit 4002 or floating-point texture filter unit 4003) based on the texture format of the texel; the integer texture filter unit 4002 is used to process the integer format color value of at least one texel to generate the integer format color value of the pixel; and the floating-point texture filter unit 4003 is used to process the floating-point format color value of at least one texel to generate the floating-point format color value of the pixel. It can be seen that in the related art, in order to meet the texture filtering requirements for multiple texture formats, the filtering module needs to be configured with texture filter units for multiple texture formats, resulting in a large space occupied by the graphics processor.
[0049] In order to solve the above problem, an embodiment of the present disclosure provides a method for determining a color value. As shown in FIG5 , the method may include: S101 - S103 .
[0050] S101. Obtain a shifted color value of each texel among a plurality of texels that affect a target pixel; the shifted color value of each texel is obtained by performing a first shift processing on the texel color value of the texel according to a texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same.
[0051] In an embodiment of the present disclosure, the electronic device needs to determine the shifted color value of each texel from the multiple texels that affect the target pixel, input the shifted color value of each texel into the texture filtering unit, and obtain the color value of the target pixel. The number of the multiple texels that affect the target pixel can be set as needed, and the embodiment of the present disclosure does not limit this. As shown in Figure 1, the multiple texels that affect the target pixel may include 9 texels: texels 0-2, texels 4-6, and texels 8-10, or may include 4 texels: texel 5, texel 6, texel 9, and texel 10, etc. In some embodiments of the present disclosure, the electronic device may determine the multiple texels based on the distance from the target pixel. For example, the electronic device may regard the texels whose distance from the target pixel is less than a preset distance threshold as the multiple texels that affect the target pixel; the preset distance threshold can be set as needed, and the embodiment of the present disclosure does not limit this.
[0052] In the embodiment of the present disclosure, after the electronic device extracts the original texture color value from the texel, it can perform a first shift process on the texture color value of different texture formats to obtain a shifted color value, where the shifted color value is the product of the decimal value and the power of the exponential value of the base number; here, the shifted color value C of the texel of different texture formats y Expressed as formula (2). Cy =P×b Q Formula (2)
[0053] Where P is a decimal value, b is the base 2, and Q is the exponent value. The number of decimal places and integer places in P for different texture formats are the same. Both the number of decimal places and the number of integer places can be set as needed and are not limited in the present embodiment.
[0054] Table 1
[0055] Table 1 shows the numerical composition of the 32-bit floating-point format. As shown in Table 1, the highest bit of the value in the 32-bit floating-point format is the sign bit, the 8 bits after the sign bit are the exponent bits, and the last 23 bits are the mantissa bits. The integer bit of the decimal value defaults to 1.
[0056] For example, the exponent bit of the texel color value in 32-bit floating point format is 0b10000010, which represents the decimal value 130, as shown in formula (3); the mantissa bit is 0b11100000000000000000000, which represents the decimal value 0.875, as shown in formula (4); the sign bit is 0, which represents a positive number. Its texture color value C w The decimal value of is calculated by formula (5). 7 +1×2 1 =130 Formula (3) 1×2 -1 +1×2 -2 +1×2 -3 =0.875 Formula (4) C w =1.875×2(130-bias)=1.875×2 3 =15 Formula (5)
[0057] Among them, the bias number bias is 127.
[0058] In some embodiments, P is a preset integer 1 combined with 23 mantissa bits, a total of 24 bits, represented as "1.23", and Q is 3. Then the shifted color value in 32-bit floating point format can be represented as "1.23"×2 3 The texture color value in formula (5) can be expressed as “1.111000000000000000000000”×2 3 , that is, 1.875×2 3 For texture color values whose texture format is unorm24, the electronic device can shift its decimal point to the left after the value T of the highest bit, and the resulting decimal value P can be expressed as "T.23", and Q is 23. The texture color value of unorm24 can be expressed as "T.23" × 23 The number of decimal places in the unorm24 and 32-bit floating-point formats is 23, and the number of integer places is 1.
[0059] In some embodiments, P is 25 bits in total, with 1 integer bit and 24 decimal bits. The texture color value in 32-bit floating point format can also be represented as "0.24" × 2 4 In this way, the electronic device can move the decimal point of the color value in the unorm24 format to the left before T, and the resulting decimal value P can be expressed as "0.24", and Q is 24. The texture color value of unorm24 can be expressed as "0.24" × 2 24 Thus, the number of decimal places of the decimal value P in both unorm24 and 32-bit floating-point formats is 24, and the number of integer places is 1.
[0060] In some embodiments of the present disclosure, if the texture format of the texel is a floating-point format, the texel color value is a binary original code. If the texel color value is a negative number, the electronic device needs to take the complement of the texel color value before calculating the binary original code, and then shift it to obtain the shifted color value.
[0061] In some embodiments of the present disclosure, if the texture format of a texel is a signed normalized snorm format, and the texel color value is a positive number, it is a binary original code. The electronic device can directly shift it to obtain the shifted color value and then perform calculations. If the texel color value is a negative number, it is a two's complement code. The electronic device can first calculate the two's complement code of the texel color value to obtain the binary original code, and then shift it to obtain the shifted color value.
[0062] It should be noted that before performing shifting, multiplication, or other calculations on various color values, the original code must be used; and before performing addition calculations, the two's complement code must be used. For color values in different formats, the conversion between original code and two's complement code can be configured as needed; this is not limited in the embodiments of the present disclosure.
[0063] S102 : Determine a pixel color value of the target pixel based on an influence factor of each texel on the target pixel and a shifted color value of each texel.
[0064] In an embodiment of the present disclosure, after determining the shifted color value of each texel, the electronic device may perform a weighted summation of the shifted color values based on the influencing factor of the target pixel to obtain the pixel color value. Because the exponent values in the shifted color values of each texel may be different, when performing the summation through the adder, it is necessary to first perform a second shift on the weighted color values to obtain second shifted color values with the same exponent value. The second shifted color values of multiple texels are then added together to obtain the pixel color value of the target pixel.
[0065] S103 , performing restoration processing on the pixel color value according to the restoration method corresponding to the texture format to obtain a target color value of the target pixel.
[0066] In the embodiment of the present disclosure, after obtaining the pixel color value, the electronic device also needs to restore the pixel color value to the color value of the texture format of multiple texels. Here, the restoration method may be different for different texture formats.
[0067] In some embodiments of the present disclosure, when the texture format is a floating-point format, the electronic device needs to perform floating-point restoration processing on the pixel color value, that is, shift the pixel color value to obtain the value of the exponent bit and the value of the mantissa bit of the target color value.
[0068] In some embodiments of the present disclosure, when the texture format is a signed normalized format, the electronic device can first obtain the color value to be restored that does not include the sign from the pixel color value, and then round it off according to the positive and negative of the pixel color value and the color value to be restored to obtain the target color value.
[0069] In some embodiments of the present disclosure, when the texture format is an unsigned normalized format, the electronic device may round off the color value to be restored to obtain a target color value. Here, the electronic device may intercept the value of the highest preset mantissa digit from the color value to be restored as the integer digit of the target color value, and the digit after the highest preset mantissa digit as the decimal digit to obtain a normalized color value, and then round off the normalized color value to obtain the target color value.
[0070] It is understandable that because the shifted color value is obtained by the electronic device performing a first shift on the original texture color value extracted from the texel, the decimal and integer digits of the decimal value of the shifted color value of the texel in different texture formats are the same; thus, the electronic device can use the same hardware module structure when processing the shifted color value, and then configure hardware modules for restoration processing for different texture formats to achieve texture filtering for different texture formats. This can reduce the space occupied by the hardware module during texture filtering, thereby saving space occupied by the graphics processor in the electronic device.
[0071] In some embodiments of the present disclosure, the implementation of determining the pixel color value of the target pixel based on the influence factor of each texel on the target pixel and the shifted color value of each texel in S102 may include:
[0072] S1021 . Perform weighted summation processing on the shifted color values of multiple texels based on the influence factor of each texel on the target pixel and the index values of the multiple texels to obtain the pixel color value of the target pixel.
[0073] In an embodiment of the present disclosure, an electronic device first performs weighted processing on the shifted color values of multiple texels. After obtaining the weighted color values, it is necessary to perform a second shift processing on the weighted color values based on the exponential values of the multiple texels. The second shift processing is the process of shifting the decimal point of the weighted color value to the left while increasing the exponential value. For each shifted color value, the number of digits the decimal point is shifted to the left is the same as the value of the increase in the exponential value; for shifted color values with different exponential values, the number of digits the decimal point is shifted to the left varies. The number of digits the decimal point is shifted to the left can be set as needed and is not limited by the embodiment of the present disclosure.
[0074] In an embodiment of the present disclosure, when the exponent values of the shifted color values of multiple texels are different, the number of digits by which the decimal point is shifted to the left is greater than or equal to the difference between the maximum value of the exponent values among the multiple shifted color values and the exponent value of the corresponding shifted color value; when the exponent values of the shifted color values of multiple texels are the same, the number of digits by which the decimal point is shifted to the left is greater than or equal to zero.
[0075] It is understandable that, through weighted summation processing, a second shift processing can be performed according to the exponent values of the color values of different texture formats to adjust the exponent values of the color values of different texture formats to be the same, thereby facilitating the adder processing of the color values.
[0076] In some embodiments of the present disclosure, the implementation of obtaining the shifted color value of each texel among a plurality of texels affecting the target pixel in S101 may include: S201 - S202 , as shown in FIG6 .
[0077] S201. Obtain color information of each texel; the color information of each texel includes a texel color value and a texture format.
[0078] In an embodiment of the present disclosure, the electronic device can extract color information of each texel from multiple texels that affect the target pixel, where the color information includes the texel color value and its texture format. In this way, the electronic device can determine the shifted color value of each texel based on the color information.
[0079] S202 : Perform a first shift process on the texel color value of each texel according to the texture format to obtain a shifted color value of each texel.
[0080] In an embodiment of the present disclosure, after determining the color information of each texel, the electronic device may perform a first shift process on the texel color value in the color information according to a texture format in the color information to obtain a shifted color value.
[0081] It is understandable that the electronic device can obtain the texel color value and texture format of each texel, so that the electronic device can perform a first shift processing on the texel color value according to the texture format of the texel to obtain a shifted color value.
[0082] In some embodiments of the present disclosure, the texture format of the texel is a floating-point format; in S202, the texel color value of each texel is first shifted according to the texture format to obtain the shifted color value of each texel, as shown in Figure 7, which may include: S301-S303.
[0083] S301 : Determine the exponent value of the corresponding shifted color value according to the value of the exponent bit of the texel color value of each texel.
[0084] S302: Use a preset integer as the value of the integer position of the decimal value in the shifted color value.
[0085] S303 : Determine the value of the mantissa of the texel color value as the value of the decimal place of the decimal value in the shifted color value.
[0086] In an embodiment of the present disclosure, after obtaining the texel color value in floating-point format, the electronic device can extract the exponent bit and the mantissa bit from the texel color value, and determine the shift color value according to the value of the exponent bit and the value of the mantissa bit.
[0087] In an embodiment of the present disclosure, the electronic device may determine the difference between the value of the exponent bit of the texel color value and the bias value as the exponent value of the shifted color value, use a preset integer as the value of the integer bit of the decimal value in the shifted color value, and use the value of the mantissa bit of the texel color value as the value of the decimal bit of the decimal value in the shifted color value. In an embodiment of the present disclosure, if the electronic device does not shift the texel color value, it means that the decimal point of the texel color value is shifted to zero.
[0088] For example, the sign bit of the texel color value is 0, which indicates that the texel color value is a positive number; the sign bit of the texel color value is 1, which indicates that the texel color value is a negative number. 01000001011100000000000000000000 is a texel color value in 32-bit floating point format, and its shifted color value is "1.11100000000000000000000" × 2 3 1100000101110000000000000000000000 is the texel color value in 32-bit floating point format, and its shifted color value is also "1.11100000000000000000000" × 2 3 .
[0089] It is understandable that the texel color value in floating point format includes an exponent bit and a mantissa bit, and the electronic device can quickly determine the value of the exponent bit and the decimal value directly based on the texel color value without shifting them.
[0090] In some embodiments of the present disclosure, the texture format of the texel is a normalized format; in S202, the texel color value of each texel is first shifted according to the texture format to obtain the shifted color value of each texel, as shown in Figure 8, which may include: S401-S403.
[0091] S401. Determine a normalized color value of the corresponding texel according to the texel color value of each texel; the normalized color value is the original color value excluding the sign value; the sign value represents whether the texel color value is a positive number or a negative number.
[0092] In the disclosed embodiments, the normalized format includes a signed normalized format and an unsigned normalized format. In the unsigned normalized format, the texel color value does not include a sign value, while in the signed normalized texel color value, the highest bit value is the sign value. Depending on the situation in which the texel color value includes a sign value, the electronic device determines the normalized color value in different ways.
[0093] In some embodiments of the present disclosure, the normalized format is an unsigned normalized format, and the texel color value does not include a signed value. The electronic device can use the texel color value as a normalized color value. For example, if the texel color value is 10110001 and the unorm8 format is used, the normalized color value is 10110001.
[0094] In some embodiments of the present disclosure, the normalization format is a signed normalization format. When the sign value of the texel color value represents that the texel color value is a positive number, the electronic device can use other values in the texel color value except the sign value as the normalized color value.
[0095] In some embodiments of the present disclosure, the normalization format is a signed normalization format. When the sign value of the texel color value represents that the texel color value is a negative number, the electronic device can use the complement of other values in the texel color value except the sign value as the normalized color value; since when the texel color value is a negative number, the texel color value itself is a complement color value, it needs to be converted into the original color value before the shift processing to obtain the normalized color value.
[0096] In an embodiment of the present disclosure, the sign bit of the texel color value is the high bit of the texel color value, and the number of the sign bit can be set as needed. In some embodiments, the number of the sign bit is 1, and the most significant bit of the texel color value is the sign bit.
[0097] For example, the texel color value is 10110001 in snorm8 format. The sign bit is the highest bit "1" indicating that the texel color value is negative, and the normalized color value is the complement of the texel color value 0b0110001, 0b1001111.
[0098] S402 , shifting the decimal point of the normalized color value to the left by a first shift number to obtain a decimal value of the shifted color value; the first shift number is the number of mantissa bits in the shifted color value in a floating-point format.
[0099] S403: Use the first shift value as the exponent value of the shifted color value.
[0100] In an embodiment of the present disclosure, after obtaining a normalized color value, the electronic device may shift the decimal point of the normalized color value to the left by a first shift amount to obtain a decimal value of the shifted color value; and use the first shift amount as an exponent value of the shifted color value. The first shift amount is a preset number of mantissa bits, which can be set as needed. In some embodiments, the preset number of mantissa bits can be the number of mantissa bits in the shifted color value in floating-point format.
[0101] Exemplarily, the floating-point format includes 23 mantissa bits, and the decimal value in the shifted color value of the floating-point format includes 1 integer bit and 23 decimal bits. The texel color value of unorm24 is 24 bits, and the decimal point needs to be shifted left by 23 bits to obtain a decimal value with 23 decimal bits, the integer bit is the highest bit of the texel color value, and the exponent value is 23. The texel color value of snorm24 is 24 bits, and the highest bit is the sign bit. If the sign bit has a sign value of 0, the decimal point of the two's complement of the lower 23 bits needs to be shifted left by 23 bits, and the integer bit needs to be padded with 0 to obtain the decimal value of the shifted color value.
[0102] It can be understood that after the electronic device determines the normalized color value based on the pixel color value, it can shift the normalized color value to the left to obtain the shifted color value; when the first shift number of the left shift is the same as the number of mantissa bits of the floating-point format, the electronic device can use the same hardware module to perform weighted summation processing on the color values in the floating-point format and the normalized format, saving the space occupied by the hardware module used for the weighted summation.
[0103] In some embodiments of the present disclosure, in S1021, based on the influence factor of each texel on the target pixel and the index values of the multiple texels, the shifted color values of the multiple texels are weighted and summed to obtain the pixel color value of the target pixel, as shown in Figure 9, which may include: S501-S503.
[0104] S501 : Based on an influence factor of each texel on a target pixel, weighted processing is performed on the shifted color values of a plurality of texels to obtain a weighted color value of each texel.
[0105] In an embodiment of the present disclosure, the electronic device may multiply the influence factor of each texel on the target pixel and the shifted color value of the corresponding texel to obtain a weighted color value of each texel.
[0106] S502 : Perform a second shift process on each weighted color value based on the index values of the plurality of texels to obtain a second shifted color value of each texel.
[0107] In an embodiment of the present disclosure, the electronic device may perform a second shift process on the weighted color value to obtain a second shifted color value; the exponent value of the second shifted color value for each texel is the same. Here, the second shift process may be to shift the decimal point of the weighted color value to the right or to the left; the number of digits of the left shift or the right shift may be determined based on the number of decimal places of the decimal value in the second shifted color value.
[0108] S503 : Sum the second shifted color values of the plurality of texels to obtain a pixel color value of the target pixel.
[0109] In an embodiment of the present disclosure, after obtaining the second shifted color value for each texel, the electronic device may add the plurality of second shifted color values to obtain the pixel color value of the target pixel. The electronic device may determine the sign of the pixel color value based on the highest bit of the pixel color value; a highest bit of 1 indicates a negative number, and a highest bit of 0 indicates a positive number.
[0110] In some embodiments of the present disclosure, the implementation of summing the second shifted color values of the plurality of texels to obtain the pixel color value of the target pixel in S503 may include: S5031 - S5032.
[0111] S5031. Update the decimal value of each second shifted color value to the complement of the decimal value of the corresponding second shifted color value to obtain a plurality of summed color values.
[0112] S5032: Taking the sum of the multiple summed color values as the pixel color value of the target pixel.
[0113] In the embodiment of the present disclosure, the color value is in the original code when the shift processing is performed, and the second shifted color value obtained is the original code. If the texel color value is a negative number, when performing the summation, the original code needs to be converted to the complement code and added using the complement code.
[0114] In an embodiment of the present disclosure, after obtaining the second shifted color value, the electronic device can take the complement of the decimal value of each second shifted color value to obtain each summed color value, and then use the sum of each summed color value as the pixel color value of the target pixel.
[0115] It is understandable that after the electronic device performs weighted processing on the shifted color values to obtain weighted color values, it can perform a second shift processing to align the exponent bits of multiple weighted color values and then sum them to improve the accuracy of the pixel color value.
[0116] In some embodiments of the present disclosure, in S502, based on the index values of multiple texels, a second shift processing is performed on each weighted color value to obtain the second shifted color value of each texel, as shown in Figure 10, which may include: S601-S602.
[0117] S601. Shift the decimal point of the decimal value in the weighted color value to the left by a second shift number to obtain a decimal value of the second shifted color value; the sum of the exponents of the second shift number and the weighted color value is greater than or equal to the maximum exponent value among the exponent values of the multiple texels.
[0118] S602: Increase the exponent value in the weighted color value by a second shift number to obtain the exponent value of the second shifted color value.
[0119] In an embodiment of the present disclosure, the electronic device may shift the decimal point of the weighted color value to the left by a second shift number to obtain a decimal value of the second shifted color value. The exponent value of the second shifted color value is the sum of the second shift number and the exponent of the weighted color value. The exponent value of the second shifted color value may be greater than or equal to the maximum exponent value among the exponent values of the multiple weighted color values.
[0120] In some embodiments of the present disclosure, the texture format is a floating point format, and the exponent value of the second shifted color value is equal to the maximum exponent value. For example, the plurality of weighted color values include: 1.10×2 3 and 1.01×2 5 , then the exponent value of the second shifted color value is 5. The electronic device can convert 1.10×2 3 Shift the decimal point of 1.10 2 places to the left to get 0.011×2 5 The second shift color value includes: 0.011×2 5 and 1.01×2 5 .
[0121] In some embodiments of the present disclosure, the texture format is a normalized format, and the exponent value of the second shifted color value is equal to the number of decimal places in the texel color value.
[0122] In the embodiment of the present disclosure, the number of decimal places in the texel color values in the normalized format is the same, and the second shift number for the electronic device to left-shift the weighted color value is 0.
[0123] In some embodiments of the present disclosure, the texture format of the texel is a floating-point format; in S103, the pixel color value is restored according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel, as shown in Figure 11, which may include: S701-S703.
[0124] S701: Convert the pixel color value into a floating-point color value to be restored; the floating-point color value to be restored is the original color value.
[0125] In the disclosed embodiment, if the texel color value is a positive number and the pixel color value itself is an original color value, the electronic device can use the pixel color value as the floating-point color value to be restored. If the texel color value is a negative number and the pixel color value itself is a two's complement color value, the electronic device needs to restore the decimal value of the decimal value in the texel color value to the original format, and then set the highest bit sign bit to 1 to obtain the floating-point color value to be restored.
[0126] S702 : Perform a third shift process on the floating-point color value to be restored to obtain a floating-point color value.
[0127] In an embodiment of the present disclosure, after determining the floating-point color value to be restored, the electronic device needs to perform a third shift process on the floating-point color value to be restored to obtain a floating-point color value so that the integer bit of the decimal value of the floating-point color value is a preset integer corresponding to the floating-point format.
[0128] In some embodiments of the present disclosure, performing the third shift processing on the floating-point color value to be restored in S702 to obtain the floating-point color value may include: S7021-S7022.
[0129] S7021. Shift the decimal point of the decimal value in the floating-point color value to be restored rightward by a third shift position to obtain the decimal value of the floating-point color value; the integer digit of the decimal value in the floating-point color value is a preset integer.
[0130] In an embodiment of the present disclosure, the electronic device may shift the decimal point of the decimal value in the floating-point color value to be restored to the right by a third shift number, and the resulting decimal value is the decimal value of the floating-point color value. In an embodiment of the present disclosure, the electronic device may shift the decimal point of the decimal value in the floating-point color value to the right until a preset integer is the value of the integer digit of the decimal value, and the number of bits shifted right is the third shift number.
[0131] S7022. Subtract the third shift bit from the exponential value of the pixel color value to obtain the exponential value of the floating-point color value.
[0132] In the disclosed embodiment, after the decimal point of the floating-point color value to be restored is shifted right, its exponent value must be reduced to maintain the color value unchanged. The decimal point of the floating-point color value to be restored is shifted right by a third shift amount, and the electronic device can subtract the third shift amount from the exponent value of the pixel color value to obtain the exponent value of the floating-point color value.
[0133] For example, the pixel color value is: 0.00101×2 30 , then the third shift position is 3, which can be shifted to a value where "1" is an integer. After the decimal point is shifted three places to the right, the floating point color value is: 1.01×2 27 .
[0134] S703: Determine a target color value according to the pixel color value and the floating-point color value.
[0135] In an embodiment of the present disclosure, after obtaining the decimal value and exponent value of a floating-point color value, the electronic device can determine a target color value based on the positive or negative nature of the pixel color value, the decimal value, and the exponent value of the floating-point color value. The decimal value of the floating-point color value is used to determine the value of the mantissa bit of the target color value, the exponent value of the floating-point color value is used to determine the value of the exponent bit of the target color value, and whether the pixel color value is positive or negative is used to determine the value of the sign bit of the target color value.
[0136] In some embodiments of the present disclosure, the implementation of determining the target color value according to the texel color value and the floating-point color value in S703 may include: S7031-S7033.
[0137] S7031. Determine the decimal place of the floating-point color value as the mantissa of the target color value.
[0138] S7032. Use the exponent value of the floating-point color value as the value of the exponent bit of the target color value.
[0139] In an embodiment of the present disclosure, the electronic device may use the decimal value of the floating-point color value as the mantissa value of the target color value; and use the exponent value of the floating-point color value as the exponent value of the target color value.
[0140] S7033. Determine a preset sign value corresponding to the positive or negative property of the pixel color value as the value of the sign bit of the target color value.
[0141] In the embodiment of the present disclosure, if the pixel color value is a positive number, the preset sign value is 0; if the pixel color value is a negative number, the preset sign value is 1.
[0142] It is understandable that when the texel color value is in floating point format, the electronic device can perform exponential normalization on the pixel color value according to the positive and negative properties of the pixel color value to obtain a target color value consistent with the texture format of multiple texels.
[0143] In some embodiments of the present disclosure, the texture format of the texel is a normalized format; in S103, the pixel color value is restored according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel, as shown in Figure 12, which may include: S801-S803.
[0144] S801. Perform a fourth shift process on the pixel color value according to the positive and negative properties of the pixel color value to obtain a normalized color value to be restored; the normalized color value to be restored is the original color value.
[0145] In an embodiment of the present disclosure, if the texel color value is in a normalized format, the electronic device needs to round the pixel color value after obtaining the pixel color value to obtain the target color value. Rounding needs to be performed on the original code. Therefore, the electronic device needs to perform a fourth shift processing based on the positive and negative properties of the pixel color value to obtain the normalized color value to be restored. Among them, the fourth shift processing needs to make the integer number of bits of the normalized color value to be restored the same as the integer number of bits of the texel color value. Exemplarily, the format of the texel color value is unorm24, and the integer number of bits of the normalized color value to be restored is 24.
[0146] In some embodiments of the present disclosure, when the positive and negative properties of the pixel color value represent that the pixel color value is a positive number, the electronic device can shift the decimal point of the pixel color value to the right by a first shift number to obtain the normalized color value to be restored.
[0147] In an embodiment of the present disclosure, if the pixel color value is a positive number, the pixel color value itself is the original color value. The electronic device can perform the inverse processing of the first shift processing on the pixel color value, shift the decimal point of the pixel color value right by the first shift number, and obtain the normalized color value to be restored.
[0148] In some embodiments of the present disclosure, when the positive and negative properties of the pixel color value indicate that the pixel color value is a negative number, the value of the decimal place of the pixel color value is updated to the value of the complement of the decimal place of the pixel color value to obtain a negative color value; the decimal point of the negative color value is shifted to the right by a preset number of digits to obtain the normalized color value to be restored.
[0149] In the disclosed embodiment, if the pixel color value is a negative number, then the pixel color value is a two's complement color value, and the electronic device needs to take the two's complement of the pixel color value to restore it to the original color value. Here, the electronic device can update the decimal place value of the decimal value in the pixel color value to its two's complement, and the resulting negative color value is the original color value. Then, the negative color value is subjected to the inverse of the first shift process, shifting the decimal point of the pixel color value right by the first shift amount to obtain the normalized color value to be restored.
[0150] S802: intercept the value of the first shift number of the highest bit from the normalized color value to be restored as the value of the normalized integer bit, and intercept the value of the bit after the first shift number from the normalized color value to be restored as the value of the normalized decimal bit.
[0151] In an embodiment of the present disclosure, after obtaining the normalized color value to be restored, the electronic device can intercept the value of the normalized integer bit and the value of the normalized decimal bit from the normalized color value to be restored; wherein the normalized decimal bit is the bit after the normalized integer bit.
[0152] S803 : Determine a target color value according to the format of the texel color value, the value of the normalized integer bit, and the value of the normalized decimal bit.
[0153] In the disclosed embodiments, the electronic device needs to determine the format of the target color value based on the format of the texel color value. If the texel color value is a true color value, the target color value should also be a true color value. If the texel color value is a two's complement color value, the target color value should also be a two's complement color value.
[0154] In an embodiment of the present disclosure, the electronic device can determine whether to keep the value of the normalized integer bit original or add one to obtain an unsigned color value based on whether the value of the normalized decimal bit is greater than or equal to half the base of the base. The unsigned color value format is then converted to a texel color value format to obtain a target color value.
[0155] For example, the format of the texel color value is unorm4. To restore the normalized color value 1.00110, the first shift is 3, and after the shift, the value is 1001.10. This results in a normalized integer of 1001 and a normalized decimal of 1. Since the normalized decimal of 1 is equal to half the base of 2, the unsigned color value should be 1001 + 1 = 1010.
[0156] It is understood that for a normalized texel color value, the electronic device can round the pixel color value to restore it to a normalized color value to obtain the target color value. By rounding to maintain the original normalized format, the accuracy of the target color value can be improved.
[0157] In some embodiments of the present disclosure, S803 determines the realization of the target color value according to the format of the texel color value, the value of the normalized integer bit and the value of the normalized decimal bit, as shown in FIG13 , and may include: S901 - S902 .
[0158] S901. When the value of the normalized decimal place is less than half of the base number, the value of the normalized integer place is used as the unsigned color value; or, when the value of the normalized decimal place is greater than or equal to half of the base number, the sum of the value of the normalized integer place and 1 is used as the unsigned color value.
[0159] In an embodiment of the present disclosure, the electronic device can determine the size between the value of the normalized decimal place and half of the base number to obtain a judgment result. When the judgment result indicates that the value of the normalized decimal place is less than half of the base number, the value of the normalized integer place is used as an unsigned color value; when the judgment result indicates that the value of the normalized decimal place is greater than or equal to half of the base number, the sum of the value of the normalized integer place and 1 is used as an unsigned color value. It should be noted that for a color value with a base number of 2, if the decimal place is 1, the integer place is increased by 1, and if the decimal place is 0, the integer place remains unchanged.
[0160] S902 : Determine a target color value according to the format of the texel color value and the unsigned color value.
[0161] In the embodiment of the present disclosure, after determining the unsigned color value, the electronic device may convert the format of the unsigned color value into the format of the texel color value to obtain the target color value.
[0162] In some embodiments of the present disclosure, when the format of the texel color value is a signed normalized format and the pixel color value is a positive number, the electronic device can use a preset signed positive number as the value of the sign bit of the target color value, and use an unsigned color value as the value of the target color value excluding the sign bit.
[0163] In the embodiment of the present disclosure, the texel color value is in a signed normalized snorm format. A positive texel color value indicates that the target color value should be the original color value. The electronic device can combine the result of a preset signed positive number with the unsigned color value as the target color value.
[0164] In the embodiment of the present disclosure, the preset signed positive number can be set as needed, and the embodiment of the present disclosure does not limit it.
[0165] Exemplarily, the unsigned color value is 101, the texel color value is a positive number, and the preset signed positive number is 0; then the target color value is 0101.
[0166] In some embodiments of the present disclosure, when the format of the texel color value is a signed normalized format and the pixel color value is a negative number, the electronic device can use a preset signed negative number as the value of the sign bit of the target color value, and use the complement of the unsigned color value as the value other than the sign bit in the target color value.
[0167] In the disclosed embodiment, the texel color value is in a signed normalized snorm format. A negative texel color value indicates that the target color value should be a two's complement color value. The electronic device can combine the negative number with the two's complement of the unsigned color value as the target color value.
[0168] In the embodiment of the present disclosure, the preset signed negative number can be set as needed, and the embodiment of the present disclosure does not limit it.
[0169] Exemplarily, the texel color value is a negative number, and the preset negative sign is 1. The unsigned color value is 101, and its complement is 011, so the target color value is 1011.
[0170] In some embodiments of the present disclosure, the preset sign of a positive number is 0, and the preset sign of a negative number is 1.
[0171] In some embodiments of the present disclosure, when the format of the texel color value is an unsigned normalized format, the electronic device may use the unsigned color value as the target color value.
[0172] In the embodiment of the present disclosure, the texel color value is in an unsigned normalized format unorm, and the unsigned color value is the target color value.
[0173] For example, if the unsigned color value is 101 and the texel color value is unorm4, the target color value is 0101.
[0174] It is understandable that the electronic device can process the unsigned color value according to the format of the texel color value to obtain the target color value; in this way, the target color value can have the same format as the texel color value to achieve a restoration effect.
[0175] The present disclosure provides a method for determining a color value, as shown in FIG14 . The method may include:
[0176] S11. Obtain color information of multiple texels that affect the target pixel; the color information includes texel color values and texture formats.
[0177] In the embodiment of the present disclosure, the texture formats of texels include unorm24 and 32-bit floating point formats.
[0178] S12. Determine whether the texture format of the multiple texels is unorm24; if so, execute S13; if not, execute S14.
[0179] In the embodiment of the present disclosure, if the texture format of the plurality of texels is not unorm24, it is a 32-bit floating point format.
[0180] S13. Shift the color value of each texel to obtain multiple shifted color values.
[0181] S14. Extract the exponent bit and the mantissa bit from each texel color value to obtain a plurality of shifted color values.
[0182] S15 . Based on the influence factor of each texel on the target pixel, perform weighted processing on a corresponding shifted color value to obtain a weighted color value of each texel.
[0183] In the embodiment of the present disclosure, the impact factor is an 8-bit fixed-point number. In S15, the 24-bit shifted color value is multiplied by the 8-bit impact factor, and the number of bits of the obtained weighted color value is less than or equal to 32.
[0184] S16 . Perform a second shift process on each weighted color value based on the index values of the multiple texels to obtain a second shifted color value of each texel.
[0185] S17. Add the second shifted color value of each texel to obtain a pixel color value.
[0186] In an embodiment of the present disclosure, if the texel color value is in floating-point format and the value of the sign bit indicates that the texel color value is a negative number, the electronic device needs to update the decimal value of the second shifted color value of each texel to its complement to obtain the sum color value, and then add the sum color value to obtain the pixel color value.
[0187] S18. Determine whether the texture format of the multiple texels is unorm24; if so, execute S19; if not, execute S20.
[0188] In some embodiments of the present disclosure, the judgment result of S18 is the same as the judgment result of S12, and S18 can directly adopt the judgment result of S12.
[0189] S19. Restore the pixel color value to a target color value in unorm24 format.
[0190] S20. Restore the pixel color value to a target color value in a 32-bit floating point format.
[0191] In an embodiment of the present disclosure, an electronic device can simultaneously support texture filtering for two texture formats: unorm24 and 32-bit floating-point format. The texture format is determined by determining whether the texel's texture format is unorm24. The texel's color value is first shifted according to the texture format to obtain a shifted color value. The shifted color values are then weighted and summed, and finally restored according to the texture format to obtain the target color value.
[0192] Based on the above color value determination method, the present disclosure provides a structure of a color value determination device. As shown in FIG15 , the color value determination device 110 may include:
[0193] An acquisition module 1101 is configured to acquire a shifted color value of each texel among a plurality of texels that affect a target pixel; the shifted color value of each texel is obtained by performing a first shift processing on the texel color value of the texel according to a texture format of the texel; the decimal digits and integer digits of the decimal value of the shifted color value of different texture formats are the same;
[0194] A determination module 1102 is configured to determine a pixel color value of a target pixel based on an influence factor of each texel on the target pixel and a shifted color value of each texel;
[0195] The restoration module 1103 is configured to restore the pixel color value according to a restoration method corresponding to the texture format to obtain a target color value of the target pixel.
[0196] In some embodiments, the determination module 1102 is further used to perform weighted summation processing on the shifted color values of the multiple texels based on the influence factor of each texel on the target pixel and the index values of the multiple texels to obtain the pixel color value of the target pixel.
[0197] In some embodiments, the acquisition module 1101 is also used to obtain the color information of each texel; the color information of each texel includes a texel color value and a texture format; according to the texture format, the texel color value of each texel is subjected to a first shift processing to obtain the shifted color value of each texel.
[0198] In some embodiments, the texture format of the texel is a floating-point format; the acquisition module 1101 is further used to determine the exponent value corresponding to the shifted color value based on the value of the exponent bit of the texel color value of each texel; use a preset integer as the value of the integer bit of the decimal value in the shifted color value; and determine the value of the mantissa bit of the texel color value as the value of the decimal bit of the decimal value in the shifted color value.
[0199] In some embodiments, the texture format of the texel is a normalized format; the acquisition module 1101 is further used to determine the normalized color value of the corresponding texel based on the texel color value of each texel; the normalized color value does not include the original color value of the sign value; the sign value represents whether the texel color value is positive or negative; the decimal point of the normalized color value is shifted to the left by a first shift number to obtain the decimal value of the shifted color value; the first shift number is the number of mantissa bits in the shifted color value in floating point format; and the first shift number is used as the exponent value of the shifted color value.
[0200] In some embodiments, the normalization format is a signed normalization format; the acquisition module 1101 is further used to use the other values of the texel color value except the sign value as the normalized color value when the sign value of the texel color value represents that the texel color value is a positive number; and use the complement of the other values of the texel color value except the sign value as the normalized color value when the sign value of the texel color value represents that the texel color value is a negative number.
[0201] In some embodiments, the normalized format is an unsigned normalized format; the acquisition module 1101 is further configured to use the texel color value as the normalized color value.
[0202] In some embodiments, the determination module 1102 is further used to perform weighted processing on the shifted color values of the multiple texels based on the influence factor of each texel on the target pixel to obtain the weighted color value of each texel; perform a second shift processing on each of the weighted color values based on the index values of the multiple texels to obtain the second shifted color value of each texel; and sum the second shifted color values of the multiple texels to obtain the pixel color value of the target pixel.
[0203] In some embodiments, the determination module 1102 is further used to shift the decimal point of the decimal value in the weighted color value to the left by a second shift number to obtain the decimal value of the second shifted color value; the sum of the second shift number and the exponent of the weighted color value is greater than or equal to the maximum exponent value among the exponent values of the multiple weighted color values; and the exponent value in the weighted color value is increased by the second shift number to obtain the exponent value of the second shifted color value.
[0204] In some embodiments, when the texture format of the texel is a floating point format, the exponent value of the second shifted color value is equal to the maximum exponent value.
[0205] In some embodiments, when the texture format of the texel is a normalized format, the exponent value of the second shifted color value is equal to the number of decimal places in the texel color value.
[0206] In some embodiments, the texel color value is a negative value; the determination module 1102 is further used to update the decimal value of each second shifted color value to the complement of the decimal value of the corresponding second shifted color value to obtain multiple summed color values; and use the sum of the multiple summed color values as the pixel color value of the target pixel.
[0207] In some embodiments, the texture format of the texel is a floating-point format; the restoration module 1103 is further used to convert the pixel color value into a floating-point color value to be restored; the floating-point color value to be restored is the original code color value; the floating-point color value to be restored is subjected to a third shift processing to obtain a floating-point color value; and the target color value is determined based on the texel color value and the floating-point color value.
[0208] In some embodiments, the restoration module 1103 is also used to shift the decimal point of the decimal value in the floating-point color value to be restored to the right by a third shift number to obtain the decimal value of the floating-point color value; the integer digit of the decimal value in the floating-point color value is a preset integer; and the exponential value of the floating-point color value to be restored is subtracted from the third shift number to obtain the exponential value of the floating-point color value.
[0209] In some embodiments, the restoration module 1103 is also used to determine the decimal value of the decimal value of the floating-point color value as the mantissa value of the target color value; use the exponent value of the floating-point color value as the value of the exponent bit of the target color value; and determine the preset sign value corresponding to the positive and negative properties of the pixel color value as the value of the sign bit of the target color value.
[0210] In some embodiments, the texture format of the texel is a normalized format; the restoration module 1103 is further used to perform a fourth shift processing on the pixel color value according to the positive and negative properties of the pixel color value to obtain the normalized color value to be restored; the normalized color value to be restored is the original code color value; the value of the first shift number of the highest bit is intercepted from the normalized color value to be restored as the value of the normalized integer bit, and the value of the bit after the first shift number is intercepted from the normalized color value to be restored as the value of the normalized decimal bit; the target color value is determined according to the format of the texel color value, the value of the normalized integer bit and the value of the normalized decimal bit.
[0211] In some embodiments, the restoration module 1103 is further used to shift the decimal point of the pixel color value to the right by a preset number of digits when the positive and negative properties of the pixel color value indicate that the pixel color value is a positive number, so as to obtain the normalized color value to be restored.
[0212] In some embodiments, the restoration module 1103 is also used to update the value of the decimal place of the pixel color value to the value of the complement of the decimal place of the pixel color value when the positive and negative properties of the pixel color value indicate that the pixel color value is a negative number, so as to obtain a negative color value; and shift the decimal point of the negative color value to the right by a preset number of digits to obtain the normalized color value to be restored.
[0213] In some embodiments, the restoration module 1103 is further used to use the value of the normalized integer bit as an unsigned color value when the value of the normalized decimal bit is less than half of the base; or, when the value of the normalized decimal bit is greater than or equal to half of the base, use the sum of the value of the normalized integer bit and 1 as the unsigned color value; and determine the target color value according to the format of the texel color value and the unsigned color value.
[0214] In some embodiments, the restoration module 1103 is further used to, when the format of the texel color value is a signed normalized format and the pixel color value is a positive number, use a preset signed positive number as the value of the sign bit of the target color value, and use the unsigned color value as the value of the target color value other than the sign bit; when the format of the texel color value is a signed normalized format and the pixel color value is a negative number, use a preset signed negative number as the value of the sign bit of the target color value, and use the complement of the unsigned color value as the value of the target color value other than the sign bit; when the format of the texel color value is an unsigned normalized format, use the unsigned color value as the target color value.
[0215] Based on Figure 15, an embodiment of the present disclosure provides an optional structure of a device for determining a color value. As shown in Figure 16, the device can perform texture filtering on color values in unorm24 and 32-bit floating-point formats. The acquisition module 1101 includes four acquisition units 111, 112, 113, and 114. The determination module 1102 may include: four multipliers 121, 122, 123, and 124, four right shifters 126, 127, 128, and 129, one exponent comparator 125, and one adder 1210; the restoration module 1103 may include: one multiplexer 131, one exponent normalization module 132, and one rounding module 133. Among them, the acquisition units 111-114 are used to obtain four pieces of color information from the four texels that affect the target pixel, each piece of color information includes a shifted color value and bypass information, and the bypass information includes a texture format; the multipliers 121-124 are used to multiply the 24-bit decimal value in the shifted color value by the 8-bit impact factor to obtain a weighted color value; the exponent comparator 11023 is used to compare the exponent values in the four shifted color values to obtain a comparison result; the right shifters 126-129 are used to perform a second shift processing on the weighted color value based on the comparison result to obtain a second shifted color value; The adder 1210 is used to add the four second shifted color values to obtain a pixel color value; the multiplexer 131 is used to transmit the pixel color value to the exponent normalization module 132 when the texture format of the texel is a 32-bit floating point format; or, when the texture format of the texel is unorm24, transmit the pixel color value to the rounding module 133; the exponent normalization module 132 is used to restore the pixel color value to a 32-bit floating point format to obtain a target color value; the rounding module 133 is used to restore the pixel color value to unorm24 to obtain a target color value.
[0216] It should be noted that color information is transmitted in the circuit, and the color information received by the multiplexer 131 from the adder 1210 includes pixel color values and bypass information. In this way, the multiplexer 131 can determine the texture format of the pixel color value based on the bypass information. When the texture format is unorm24, the pixel color value is transmitted to the rounding module 133; when the texture format is a 32-bit floating point format, the pixel color value is transmitted to the exponent normalization module 132.
[0217] It is understandable that the electronic device can add an acquisition module 1101, a multiplexer 131 and a rounding module 133 to the texture filtering unit in the 32-bit floating-point format, and reuse the part used for weighted summation in the determination module 1102, so as to be compatible with the texture filtering function of unorm24; reduce the space occupied by the texture filtering unit and reduce hardware overhead.
[0218] Figure 17 shows the structure of an electronic device. As shown in Figure 17, the electronic device 170 includes a memory 1707, a processor 1708, and a computer program stored in the memory 1707 and executable on the processor 1708; wherein, when the processor 1708 runs the computer program, it executes the method for determining the color value in the aforementioned embodiment.
[0219] As will be appreciated, electronic device 170 also includes a bus system 1709; the various components within electronic device 170 are coupled together via bus system 1709. As will be appreciated, bus system 1709 is used to enable communication between these components. In addition to a data bus, bus system 1709 also includes a power bus, a control bus, and a status signal bus.
[0220] It can be understood that the memory in the embodiments of the present disclosure can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of the present disclosure are intended to include, but are not limited to, these and any other suitable types of memories.
[0221] The methods disclosed in the above embodiments of the present disclosure can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above methods can be completed by hardware integrated logic circuits in the processor or instructions in software form. The above processor may be a general-purpose processor, a DSP, or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory. The processor reads the signals in the memory and completes the steps of the above method in conjunction with its hardware.
[0222] An embodiment of the present disclosure provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0223] The present disclosure provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and when the computer program is read and executed by a computer, implements some or all of the steps in the above method. The computer program product can be implemented specifically by hardware, software, or a combination thereof. In some embodiments, the computer program product is specifically embodied as a computer storage medium. In other embodiments, the computer program product is specifically embodied as a software product, such as a software development kit (SDK), etc.
[0224] It should be pointed out here that the description of the various embodiments above tends to emphasize the differences between the various embodiments, and the same or similar aspects can refer to each other. In the several embodiments provided in the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation, such as: multiple modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the devices or modules can be electrical, mechanical or other forms.
[0225] The above description is merely an embodiment of the present disclosure and is not intended to limit the scope of protection of the present disclosure. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present disclosure are included in the scope of protection of the present disclosure. Industrial Applicability
[0226] The disclosed embodiments provide a method and apparatus for determining a color value, an electronic device, a computer storage medium, and a computer program product. The method for determining a color value includes: obtaining a shifted color value of each texel among a plurality of texels that affect a target pixel; the shifted color value of each texel is obtained by performing a first shift process on the texel color value of the texel according to the texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same; the pixel color value of the target pixel is determined based on the influence factor of each texel on the target pixel and the shifted color value of each texel; the pixel color value is restored according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel. The above scheme can reduce the space occupied by the hardware module during texture filtering, thereby saving the space occupied by the graphics processor in the electronic device.
Claims
1. A method for determining a color value, the method comprising: Get the shifted color value of each texel in the plurality of texels that affect the target pixel; The shifted color value of each texel is obtained by performing a first shift process on the texel color value of the texel according to the texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same; Determining a pixel color value of a target pixel based on an influence factor of each texel on the target pixel and a shifted color value of each texel; The pixel color value is restored according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel.
2. The method for determining a color value according to claim 1, wherein determining the pixel color value of the target pixel based on the influence factor of each texel on the target pixel and the shifted color value of each texel comprises: Based on the influence factor of each texel on the target pixel and the index values of the multiple texels, weighted sum processing is performed on the shifted color values of the multiple texels to obtain the pixel color value of the target pixel.
3. The method for determining a color value according to claim 1 or 2, wherein obtaining the shifted color value of each texel in a plurality of texels affecting the target pixel comprises: Obtaining color information of each texel; The color information of each texel includes the texel color value and the texture format; According to the texture format, a first shift process is performed on the texel color value of each texel to obtain the shifted color value of each texel.
4. The method for determining a color value according to claim 3, wherein the texture format of the texel is a floating point format; and performing a first shift processing on the texel color value of each texel according to the texture format to obtain the shifted color value of each texel comprises: Determining an exponent value corresponding to the shifted color value according to a value of an exponent bit of the texel color value of each texel; Using a preset integer as the value of the integer position of the decimal value in the shifted color value; The value of the mantissa of the texel color value is determined as the value of the decimal place of the decimal value in the shifted color value.
5. The method for determining a color value according to claim 3, wherein the texture format of the texel is a normalized format; and performing a first shift processing on the texel color value of each texel according to the texture format to obtain the shifted color value of each texel comprises: Determine a normalized color value of the corresponding texel according to the texel color value of each texel; the normalized color value is an original color value excluding a sign value; the sign value indicates whether the texel color value is a positive number or a negative number; Shifting the decimal point of the normalized color value to the left by a first shift number to obtain a decimal value of the shifted color value; the first shift number is the number of mantissa bits in the shifted color value in a floating point format; The first shift amount is used as an exponent value of the shifted color value.
6. The method for determining a color value according to claim 5, wherein the normalized format is a signed normalized format; and determining the normalized color value of the corresponding texel according to the texel color value of each texel comprises: In a case where the sign value of the texel color value represents that the texel color value is a positive number, taking other values of the texel color value except the sign value as the normalized color value; In the case where the sign value of the texel color value represents that the texel color value is a negative number, the complement of other values of the texel color value except the sign value is used as the normalized color value.
7. The method for determining a color value according to claim 5, wherein the normalized format is an unsigned normalized format; and determining the normalized color value of the corresponding texel according to the texel color value of each texel comprises: The texel color value is used as the normalized color value.
8. The method for determining a color value according to claim 2, wherein the weighted summation of the shifted color values of the plurality of texels based on the influence factor of each texel on the target pixel and the index values of the plurality of texels to obtain the pixel color value of the target pixel comprises: Based on the influence factor of each texel on the target pixel, weighted processing is performed on the shifted color values of the plurality of texels to obtain a weighted color value of each texel; Based on the index values of the plurality of texels, performing a second shift process on each of the weighted color values to obtain a second shifted color value of each texel; The second shifted color values of the plurality of texels are summed to obtain a pixel color value of the target pixel.
9. The method for determining a color value according to claim 8, wherein the step of performing a second shift process on each of the weighted color values based on the index values of the plurality of texels to obtain the second shifted color value of each texel comprises: Shifting a decimal point of a decimal value in the weighted color value to the left by a second shift number to obtain a decimal value of the second shifted color value; A sum of the second shift number and the exponent of the weighted color value is greater than or equal to a maximum exponent value among the exponent values of the weighted color values; The exponent value in the weighted color value is increased by a second shifting amount to obtain the exponent value of the second shifted color value.
10. The method for determining a color value according to claim 9, In the case where the texture format of the texel is a floating point format, the exponent value of the second shifted color value is equal to the maximum exponent value.
11. The method for determining a color value according to claim 9, In the case where the texture format of the texel is a normalized format, the exponent value of the second shifted color value is equal to the number of decimal places in the texel color value.
12. The method for determining a color value according to claim 8, wherein the texel color value is a negative value; and the step of summing the second shifted color values of the plurality of texels to obtain the pixel color value of the target pixel comprises: updating the decimal value of each of the second shifted color values to the complement of the decimal value of the corresponding second shifted color value to obtain a plurality of summed color values; The sum of the multiple summed color values is used as the pixel color value of the target pixel.
13. The method for determining a color value according to any one of claims 1 to 12, wherein the texture format of the texel is a floating point format; and the restoring process of the pixel color value according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel comprises: Convert the pixel color value into a floating point color value to be restored; The floating point color value to be restored is the original color value; Performing a third shift process on the floating-point color value to be restored to obtain a floating-point color value; The target color value is determined according to the pixel color value and the floating-point color value.
14. The method for determining a color value according to claim 13, wherein the step of performing a third shift process on the floating-point color value to be restored to obtain the floating-point color value comprises: Shifting the decimal point of the decimal value in the floating-point color value to be restored rightward by a third shift number to obtain the decimal value of the floating-point color value; The integer digit of the decimal value in the floating-point color value is a preset integer; The exponent value of the floating-point color value to be restored is subtracted from the third shift number to obtain the exponent value of the floating-point color value.
15. The method for determining a color value according to claim 13 or 14, wherein determining the target color value according to the pixel color value and the floating-point color value comprises: Determine the value of the decimal place of the decimal value of the floating-point color value as the value of the mantissa of the target color value; Using the exponent value of the floating-point color value as the value of the exponent bit of the target color value; A preset sign value corresponding to the positive or negative property of the pixel color value is determined as the value of the sign bit of the target color value.
16. The method for determining a color value according to any one of claims 1 to 15, wherein the texture format of the texel is a normalized format; and the restoring process of the pixel color value according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel comprises: According to the positive and negative properties of the pixel color value, the pixel color value is subjected to a fourth shift process to obtain a normalized color value to be restored; The normalized color value to be restored is the original color value; The value of the first shift number of the highest bit of the normalized color value to be restored is intercepted as the value of the normalized integer bit, and the value of the bit after the first shift number is intercepted from the normalized color value to be restored as the value of the normalized decimal bit; The target color value is determined according to the format of the texel color value, the value of the normalized integer bit, and the value of the normalized decimal bit.
17. The method for determining a color value according to claim 16, wherein the fourth shift processing is performed on the pixel color value according to the positive and negative properties of the pixel color value to obtain the normalized color value to be restored, comprising: When the positive and negative properties of the pixel color value represent that the pixel color value is a positive number, the decimal point of the pixel color value is shifted rightward by a preset number of digits to obtain the normalized color value to be restored.
18. The method for determining a color value according to claim 16, wherein the fourth shift processing is performed on the pixel color value according to the positive and negative properties of the pixel color value to obtain the normalized color value to be restored, comprising: When the positive and negative properties of the pixel color value indicate that the pixel color value is a negative number, updating the value of the decimal place of the pixel color value to the value of the complement of the decimal place of the pixel color value to obtain a negative color value; The decimal point of the negative color value is shifted rightward by a preset number of digits to obtain the normalized color value to be restored.
19. The method for determining a color value according to claim 16, wherein determining the target color value according to the format of the texel color value, the value of the normalized integer bit, and the value of the normalized decimal bit comprises: When the value of the normalized decimal place is less than half of the base of the system, the value of the normalized integer place is used as an unsigned color value; Alternatively, when the value of the normalized decimal place is greater than or equal to half of the base of the system, the sum of the value of the normalized integer place and 1 is used as the unsigned color value; The target color value is determined according to the format of the texel color value and the unsigned color value.
20. The method for determining a color value according to claim 19, wherein determining the target color value according to a format of the texel color value and the unsigned color value comprises: In the case where the format of the texel color value is a signed normalized format and the pixel color value is a positive number, a preset signed positive number is used as the value of the sign bit of the target color value, and the unsigned color value is used as the value of the target color value excluding the sign bit; In the case where the format of the texel color value is a signed normalized format and the pixel color value is a negative number, a preset signed negative number is used as the value of the sign bit of the target color value, and the complement of the unsigned color value is used as the value of the target color value other than the sign bit; When the format of the texel color value is an unsigned normalized format, the unsigned color value is used as the target color value.
21. A device for determining a color value, the device comprising: An acquisition module, used for acquiring a shifted color value of each texel among a plurality of texels affecting a target pixel; The shifted color value of each texel is obtained by performing a first shift process on the texel color value of the texel according to the texture format of the texel; the decimal places and integer places of the decimal values of the shifted color values of different texture formats are the same; A determination module, configured to determine a pixel color value of a target pixel based on an influence factor of each texel on the target pixel and a shifted color value of each texel; The restoration module is used to restore the pixel color value according to the restoration method corresponding to the texture format to obtain the target color value of the target pixel.
22. An electronic device, comprising Memory for storing computer programs; A processor, configured to execute the method for determining a color value as described in any one of claims 1 to 20 when the computer program is running.
23. A computer storage medium storing executable instructions for implementing the method for determining a color value according to any one of claims 1 to 20 when executed by a processor.
24. A computer program product, comprising a computer program or instructions, which, when executed on an electronic device, enables the electronic device to execute the method for determining a color value according to any one of claims 1 to 20.
Citation Information
Patent Citations
High accuracy texture filtering
CN110349245A
Pixel color mixing operation method, graph drawing method, device and equipment
CN115718586A
Scene rendering method and device, computing equipment, storage medium and program product
CN116843736A
Color value determination method and device, electronic equipment and computer storage medium
CN117422807A
Rendering scalable multicolored vector content
US20230081389A1
Cited By
Data format conversion device and method, electronic equipment and computer storage medium
CN120848840A
Data processing method and device, electronic equipment, storage medium and program product
CN121785564A