Method and device for improving performance of computer graphic system
By converting arithmetic operations into logarithmic space, the arithmetic operation steps of the computer graphics system are simplified, the performance limitation problem is solved, and the speed and efficiency are improved.
Patent Information
- Application Number
- CN202510835404.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-10-10
AI Technical Summary
The performance of computer graphics systems is limited by the speed of arithmetic operations and has low practicality.
Converting arithmetic operations to logarithmic space simplifies the operation steps and reduces hardware implementation costs.
It greatly improves the arithmetic operation speed of computer graphics systems and enhances system performance.
Smart Images

Figure CN120765445A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for improving the performance of a computer graphics system. Background Art
[0002] Arithmetic operations include multiplication, reciprocal, square, and square root operations. In the field of computer image processing, the application of arithmetic operations is extremely common and important, covering multiple aspects such as image enhancement, filtering, and transformation, and plays a key role in the extraction, analysis, and processing of image information.
[0003] When computer graphics systems perform computer image processing, the input and output values of arithmetic operations are usually represented in fixed-point formats with lower precision. Fixed-point representation is a numerical representation method in which the decimal point position is fixed. It is usually used in situations where precise control of the number of decimal places or fixed-precision calculations are required.
[0004] However, the performance of computer graphics systems in the prior art is often limited by the speed of arithmetic operations, resulting in a need for improvement in their practicality. Therefore, a solution for optimizing arithmetic operations in computer graphics systems is urgently needed.
[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in this technical field. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a method and device for improving the performance of a computer graphics system. The purpose is to simplify the operations and optimize the calculation speed of commonly used arithmetic operations by converting arithmetic operation tasks into logarithmic space, thereby solving the problem in the prior art that the performance of the computer graphics system is limited by the arithmetic operation speed and has low practicality.
[0007] The present invention adopts the following technical solutions: In a first aspect, the present invention provides a method for improving the performance of a computer graphics system, comprising: Determine a linear representation of an element to be operated on of a computation task in a linear space; convert the linear representation to a logarithmic space to obtain a corresponding logarithmic representation; perform a logarithmic operation on the logarithmic representation to obtain a logarithmic output; and convert the logarithmic output to a linear space to obtain a target output.
[0008] In a second aspect, in an optional embodiment, the apparatus for improving the performance of a computer graphics system may include: At least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, the instructions are executed by the processor to execute the method for improving the performance of the computer graphics system of the first aspect.
[0009] In a third aspect, the application further provides a non-volatile computer storage medium, the computer storage medium stores computer executable instructions, the computer executable instructions are executed by one or more processors to complete the method for improving the performance of the computer graphics system of the first aspect.
[0010] In a fourth aspect, a computer program product containing instructions is provided, when the instructions are run on a computer or processor, the computer or processor executes the method for improving the performance of the computer graphics system of the first aspect to the third aspect and any one thereof.
[0011] In a fifth aspect, a method system for improving the performance of the computer graphics system is provided, including the device for improving the performance of the computer graphics system of the second aspect, and using the method for improving the performance of the computer graphics system of the first aspect to complete the interaction of the device for improving the performance of the computer graphics system of the second aspect.
[0012] Compared with the prior art, the application has at least the following beneficial effects: The application determines the floating point number representation of the to-be-operated element in the linear space for the addition operation task, multiplication operation task, square operation task, square root operation task, reciprocal operation task and reciprocal square root operation task, converts it from the floating point format to the logarithmic space, obtains the logarithmic representation, completes the corresponding operation task by performing the logarithmic operation on the corresponding logarithmic representation, and then converts the logarithmic output in the logarithmic space to the linear space to obtain the target output. The application converts the operation task originally performed in the linear space to the logarithmic space, simplifies the execution steps of the operation in the computer graphics system, reduces the hardware implementation cost of the calculation, and further greatly improves the calculation speed of the commonly used arithmetic operation, thereby solving the problem of low practicability of the performance of the computer graphics system being limited by the arithmetic operation speed in the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0013] In order to more clearly illustrate the technical solutions of the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiments of the application. Obviously, the drawings described below are only some embodiments of the application, and for those skilled in the art, other drawings can also be obtained from these drawings without creative labor.
[0014] Figure 11 is a flow chart of a method for improving the performance of a computer graphics system provided by an embodiment of the present invention; Figure 2 is a schematic diagram of a logarithmic arithmetic micro-architecture structure provided by an embodiment of the present invention; Figure 3 This embodiment of the present invention provides a Schematic diagram of the function; Figure 4 is a flow chart of step 10 provided in an embodiment of the present invention; Figure 5 is a flow chart of step 103a provided by an embodiment of the present invention; Figure 6 is another flow chart of step 10 provided in an embodiment of the present invention; Figure 7 This is a function provided by an embodiment of the present invention. Schematic diagram of the numerical distribution of ; Figure 8 This is a function provided by an embodiment of the present invention. Schematic diagram of the numerical distribution of its approximate functions; Figure 9 This is a function provided by an embodiment of the present invention. Schematic diagram of the numerical distribution of ; Figure 10 This is a function provided by an embodiment of the present invention. Schematic diagram of the numerical distribution of its approximate functions; Figure 11 1 is a numerical distribution diagram of a residual function provided by an embodiment of the present invention; Figure 12 This is a schematic diagram of result quality when the input precision is 10, provided by an embodiment of the present invention; Figure 13 This is a schematic diagram of result quality when the input precision is 16, provided by an embodiment of the present invention; Figure 14 This is a schematic diagram of result quality when the input precision is 23, provided by an embodiment of the present invention; Figure 15 is a flow chart of another method for improving the performance of a computer graphics system provided by an embodiment of the present invention; Figure 16 is a schematic diagram of a texture processing unit provided by an embodiment of the present invention; Figure 17 The present invention is a schematic diagram of an apparatus for improving the performance of a computer graphics system. DETAILED DESCRIPTION
[0015] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0016] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0017] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as meaning open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "example", "specific example" or "some examples" and the like are intended to indicate that the specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.
[0018] In the description of the present invention, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present disclosure.
[0019] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, for example, the description may also use the method of adding "A" and "B" at the end to describe the same type of nouns as two independent individuals. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the description purposes of the same type of individuals, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0020] In describing some embodiments, the use of "coupled" or "coupling" and variations thereof can be used. For example, these terms can be used to indicate that two or more elements are in direct physical or electrical contact with one another. As used herein, the term "coupled" can also mean that two or more elements are not in direct contact with one another, but yet still co-operate or interact with one another. The embodiments disclosed herein are not necessarily limited in terms of the manner in which the various elements are coupled together.
[0021] In the description of the present application, the expression "A and / or B" (wherein A and B represent specific features) is used to represent the following three combinations: A alone, B alone, and a combination of A and B.
[0022] As used herein, the terms "about," "approximately," or "substantially" include the recited value and the average value within an acceptable range of deviation from the recited value, as determined by one of ordinary skill in the art considering the measurement in question and the error in measuring the particular quantity (i.e., the limitations of the measurement system).
[0023] To solve the above problems, as shown in Figure 1 The embodiments of the present application provide a method for improving the performance of a computer graphics system, comprising: In step 10, a linear representation of an operation task in a linear space is determined; the linear representation is converted to a logarithmic space to obtain a corresponding logarithmic representation; a logarithmic operation is performed on the logarithmic representation to obtain a logarithmic output; and the logarithmic output is converted to the linear space to obtain a target output.
[0024] The operation task includes an addition operation task, a multiplication operation task, a square operation task, a square root operation task, an inverse operation task, or an inverse square root operation task. The linear representation and the target output are in floating-point format.
[0025] The operation task includes an addition operation task, a multiplication operation task, a square operation task, a square root operation task, an inverse operation task, or an inverse square root operation task. The linear representation and the target output are in floating-point format.
[0026] In an optional embodiment, as shown in Figure 2 In hardware, a plurality of functions are implemented to complete the method for improving the performance of a computer graphics system according to the embodiments of the present application; the functions are used to complete the method for improving the performance of a computer graphics system according to the embodiments of the present application. F(x)Obtain a computation task, implement a selective function, and use an optional function in the selective function to convert the obtained computation task into a logarithmic space for computation.
[0027] On this basis, in an optional embodiment, when there are multiple input values instead of one input value (i.e., x), a multivariate operation function, such as 1 plus the reciprocal and 1 minus the reciprocal, is added to the selective function of the logarithmic space processing to implement the multivariate operation task in the logarithmic space. This will be explained in detail below. In fact, in order to limit the hardware cost, the multivariate operation function is more suitable for ( )or( ) and other functions.
[0028] The following is an analysis of the optimization effect of performing operations in logarithmic space instead of linear space: For multiplication-related operations, many key operations are greatly simplified after taking the logarithm. A specific example of multiplication-related operations in linear space in logarithmic space is shown in Table 1 below.
[0029] Table 1 Specific examples of multiplication-related operations in linear space in logarithmic space
[0030] Among them, in particular, the reciprocal, square root, and square root have negligible cost and are operated on in logarithmic space very differently from their fixed-point or floating-point counterparts in linear space.
[0031] However, if all operations are converted to logarithmic space, the price of simplifying multiplication operations must be paid, that is, addition operations will become more complicated. A specific example of addition-related operations in linear space in logarithmic space is shown in Table 2 below.
[0032] Table 2 Specific examples of addition-related operations in linear space in logarithmic space
[0033] This approach is particularly effective in applications where multiplication-related operations are predominant. By converting multiplication operations implemented in linear space to logarithmic space, many key multiplication operations can be greatly simplified. In particular, the computational costs of reciprocal operations, square operations, and square root operations are negligible. However, the cost of converting multiplication operations to logarithmic space is that addition operations become overly complex. Since addition operations are commonly used in computer graphics systems, this results in lower performance in computer graphics systems.
[0034] To solve the problem of high complexity in implementing addition operations in logarithmic space, embodiments of the present invention can improve the above method by sorting operands in logarithmic space and using logarithmic identities for approximate calculations:
[0035]
[0036] To better approximate in computer graphics hardware Function, that is, using a finite approximate interval lookup table to implement related calculations, such as Figure 3 As shown, The range should be kept better middle.
[0037] For addition operations, the embodiment of the present invention selects the difference between the minimum and maximum values in the logarithmic space, so that we can effectively limit range, because it is necessary to Set a certain number of approximate intervals in .
[0038] If retained ,but ,therefore able to Function in within the range.
[0039] To limit The range of the function, in logarithmic space, uses the formula in Table 3 below.
[0040] Table 3 Specific examples of processing addition-related operations in logarithmic space
[0041] On the surface, embodiments of the present invention still require adding an addition term to a transcendental mapping and its inverse mapping; wherein, in the special case of a transcendental mapping and its inverse mapping, such as "1" and "1 / |x|", it is now obvious that these composite functions are univariate, and a specific example of a composite function is shown in Table 4 below.
[0042] Table 4 Specific examples of composite functions
[0043] It should be noted that you can choose a single variable function or a single variable function For performing subtraction operations; it should be noted that The argument must be non-negative, so we must always subtract the maximum from the minimum, i.e. . Single variable function The range of is limited to [0,1], while the univariate function covers all non-negative numbers. In fact, just like in the case of the equivalent additive expressions, these functions are associated by an additive term (i.e., the difference between the minimum and maximum values), which can always be included but is not necessary if a simpler formula is chosen.
[0044] It should be noted that if |y|>|x|, an extra field is needed to track the sign, because the embodiment of the present invention cannot perform this subtraction directly in the logarithmic space.
[0045] Therefore, directly taking an approximate method for a class of functions can greatly improve the calculation speed. This class of functions represents the numerical value that needs to be increased or decreased for larger terms, and this method is also feasible in terms of practical accuracy.
[0046] Floating-point operations can be thought of as a hybrid log-linear format (the exponent is logarithmic, and the sign is linear). A basic floating-point addition implementation first sorts the operands in order of magnitude, aligns the inputs, performs the addition, and then renormalizes the result after canceling the operation. The method of the embodiment of the present invention is analogous to floating-point operations. The initial alignment can be thought of as exponentiation in floating-point operations, but only applies to the integer part of the logarithm (i.e., the exponent). The renormalization can be thought of as the final logarithm, but again, only applies to the integer part. Faster floating-point operation architectures divide input values into different subdomains based on whether the input values are similar in size. Input values with similar amplitudes rarely require initial alignment, while inputs with different amplitudes or matching signs rarely require renormalization, thereby reducing the number of component operations from three to two, thereby reducing latency at the cost of redundant calculations and increased hardware area. The same is true when using logarithms for operations.
[0047] The present invention respectively targets addition operation tasks, multiplication operation tasks, square operation tasks, square root operation tasks, reciprocal operation tasks and reciprocal square root operation tasks, and determines the floating-point representation of the input value to be calculated in the linear space, converts it from the floating-point format to the logarithmic space to obtain the logarithmic representation, and completes the corresponding operation task by performing logarithmic operation on the corresponding logarithmic representation, and then converts the logarithmic output of the logarithmic space to the linear space to obtain the target output; the present invention converts the operation tasks originally performed in the linear space to the logarithmic space, simplifies the execution steps of multiplication-related operations in the computer graphics system, reduces the hardware implementation cost of the calculation, and thus greatly improves the calculation speed of commonly used arithmetic operations, solving the problem in the prior art that the performance of the computer graphics system is limited by the arithmetic operation speed and has low practicality.
[0048] The log arithmetic micro-architecture proposed in the embodiments of the present application is shown in Figure 2 , wherein the selective function is processed in the log space, and the hardware implementation cost is low; that is, the input x is first converted to the log space in the log unit, then the log arithmetic operation is performed, and finally, the result of the log arithmetic operation is converted back to the linear space with the exponential function unit to obtain the final target output. Specifically, as shown in Figure 4 , when the operation task is an addition operation task in the linear space, the step 10 includes: Step 101a: determining a first linear representation of each to-be-operated element in the addition operation task in the linear space; wherein the first linear representation is in the floating point format.
[0049] Step 102a: inputting the first linear representation into a log function to obtain a first log representation.
[0050] , wherein the first log representation is in the fixed point format.
[0051] In an optional embodiment, the log function can be .
[0052] Step 103a: using an approximate function in the log space to perform approximate calculation on each first log representation of the addition operation task to obtain a first log output.
[0053] In the embodiments of the present application, all approximate functions use the input and output in the fixed point format.
[0054] The multiplication and division operation relationship in the linear space can be converted into the log addition and subtraction operation relationship in the log space, so as to simplify the hardware implementation of the calculation. And the addition and subtraction operation in the linear space can be approximated by the approximate function in the log space, so as to reduce the workload required for the calculation.
[0055] In an embodiment, the approximate calculation can be performed according to the following expression of the approximate function:
[0056] Specifically, when the addition operation task is completed, the embodiments of the present application first find the maximum value of the log representation corresponding to each to-be-operated element, and the result of the addition operation is the maximum value plus a single-variable approximate function , and the variable x of the approximate function is the difference between the log representations corresponding to the to-be-operated elements .
[0057] The approximate function of the log space addition calculation in the present application is single-variable, and only one conversion from the log space to the linear space is required, that is, , which is relative to the calculation of the original addition operation task in the log space , which reduces the conversion from logarithmic space to linear space, thereby reducing the amount of calculation and improving performance.
[0058] Step 104a: Convert the first logarithmic output into a floating-point format in a linear space to obtain a first target output.
[0059] The addition operation of the first type of operation task in the linear space is converted into a logarithmic and exponential approximate function operation in the logarithmic space, the converted logarithmic and exponential approximate function operation is performed on the first logarithmic representation to obtain a first logarithmic output, and the first logarithmic output is converted into a floating-point format in the linear space to obtain a first target output.
[0060] The first logarithmic representation includes a plurality of vectors, each of the vectors includes a first component and a second component, and the first component and the second component belong to a linear space. Figure 5 As shown, step 103a includes: Step 1031a: convert the dot product of the first component and the second component of each vector into a logarithmic addition operation performed on the first component and the second component in a logarithmic space to obtain a plurality of logarithmic addition results.
[0061] It should be noted that the method for improving the performance of a computer graphics system in an embodiment of the present invention only involves addition and subtraction operations in logarithmic space. Since it does not involve multiplication and division in logarithmic space, it simplifies the execution steps of operations in the computer graphics system, reduces the hardware implementation cost of the calculation, and avoids the performance of the computer graphics system being limited by the speed of arithmetic operations.
[0062] Step 1032a: Sort the logarithmic addition results corresponding to the elements to be calculated, and determine the logarithmic addition maximum value and the logarithmic addition minimum value among the logarithmic addition results; determine the difference expression of the logarithmic addition results in the logarithmic space; wherein the difference expression represents the difference between the logarithmic addition minimum value and the logarithmic addition maximum value.
[0063] Among them, when the first vector is ( , ), the second vector is ( , ), the logarithmic addition minimum express and The minimum value in the logarithmic addition, the maximum value express and In one embodiment, the following expression is used: .
[0064] Step 1033a: determining a corresponding operation mapping relationship in a logarithm space according to the linear operation relationship between the vectors.
[0065] Step 1034a: obtaining a first logarithm output according to the operation mapping relationship and the difference expression.
[0066] wherein the first vector is ( , ), and the second vector is ( , ).
[0067] When the linear operation relationship is an even relationship, the expression of the first logarithm output is: ; wherein the even relationship indicates that, in a linear space dot product operation of the first vector and the corresponding second vector, and are of the same sign.
[0068] When the linear operation relationship is an odd relationship, the expression of the first logarithm output is: ; wherein the odd relationship indicates that, in a linear space dot product operation of the first vector and the corresponding second vector, and are of different signs.
[0069] When the linear operation relationship is uncertain, the expression of the first logarithm output is: ; wherein is a sign function.
[0070] The method of the embodiment of the application can be briefly summarized as a segmented linear approximation combined with truncated multiplication and minimized lookup table compression. Since these techniques are suitable for a low-to-medium precision range, the embodiment of the application can evaluate the precision as much as possible within the possible input range of non-zero output.
[0071] In an embodiment, the precision of the method of the embodiment of the application can be evaluated within the possible input range of non-zero output by using the dot product of two vectors, using three components shown in Table 5 as follows; wherein the unformatted calculation is an actually executed function, which interprets the input value and the output value as fixed-point numbers, and therefore explicitly applies conversion.
[0072] Table 5: Specific examples of three components
[0073] Since, in the linear space dot product operation of the first vector and the corresponding second vector, ( , )·( , ) = +
[0074] For even relations, in the linear space dot product operation of the first vector and the corresponding second vector, and They have the same sign, so they are suitable for calculating 1+1 / x.
[0075] For even relations, in the linear space dot product operation of the first vector and the corresponding second vector, and Different signs, so it is suitable for calculating 1-1 / x.
[0076] When the linear operation relationship is uncertain, it is impossible to know and When the signs are the same, the result of the sign function is used to dynamically select whether to apply 1+1 / x or 1-1 / x.
[0077] Among them, the dot products in each component of Table 5 are accumulated To get the final target value, it is also output by each component. The operation of each component is divided into the following two stages: Phase 1: The vector logarithm addition component computes the vector components in pairs, sorts the logarithm addition results and divides the smallest value by the largest value. If the logarithm is required, the result is converted to floating point according to the approximation requirements.
[0078] In one embodiment, an approximation function is used It is easier to make approximations; using represents the absolute value of the logarithm with base 2, that is, =log2(|x|).
[0079] Phase 2: Query the function values of the "OnePlusRcp" and / or "OneMinusRcp" modules (including secant and second-order correction terms), use truncation multipliers to extrapolate the value range, and use linear and logarithmic terms for accumulation when necessary.
[0080] The DP2 even-type component is by far the component that requires the least resources for hardware implementation because it does not need to include linear and logarithmic terms, which reduces the critical path of these two stages and also reduces the accuracy pressure caused by merging multiple inaccurate terms.
[0081] DP2 odd-type components need to include linear and logarithmic terms, so compared with DP2 even-type components, the hardware implementation of DP2 odd-type components is more complex and will result in a larger increase in hardware area.
[0082] DP2 general component needs to use two lookup tables of OnePlusRcp and OneMinusRcp when performing logarithmic operation, so it is the largest in hardware area among the three components. Since it can share two functions and the multiplier resource of the first stage calculation, the increase in hardware area is not particularly exaggerated.
[0083] wherein, in the truncated multiplication, the high bit part (i.e. the least important part) of the product is discarded, and only the low bit part (i.e. the most important part) is kept. The lookup table is a pre-computed array or list used to store the output results of a specific function, which can be implemented by a Hash Table or Hash Map in optional embodiments. In image processing, the lookup table is usually used to store the mapping relationship between the input and output of a certain function. Through the lookup table, the corresponding output value can be quickly found from the input value of a certain function within a certain range without complex calculation; in parallel processing devices such as Graphics Processing Unit (GPU), the lookup table can be stored in the GPU memory, and the lookup and replacement operations can be directly performed on the GPU, so as to fully utilize the parallel computing capability of the GPU; in addition, since the memory access speed of the GPU is usually faster than that of the Central Processing Unit (CPU), using the GPU to perform the lookup table operation can further improve the processing speed and realize efficient image processing. In optional embodiments, the lookup table can be used for point operation of the image, especially in the operation without position correlation between pixels, since these operations only need to consider the pixel value itself, and do not involve the position relationship between pixels, so in this case, the use of the lookup table can significantly improve the processing speed. When using the lookup table for image processing, a lookup table is created according to the requirements; the lookup table can be a one-dimensional array, each element in the array corresponds to an input pixel value, and stores the output pixel value corresponding to the pixel value; in the image processing process, for each pixel, only the corresponding value in the lookup table needs to be found, and it is replaced with a new pixel value, which is equivalent to using the assignment operation instead of the calculation operation, thereby greatly saving the time consumption.
[0084] The operation task can also be a multi-element operation task, such as Figure 6 As shown in the figure, when the operation task is a multi-element operation task, the step 10 includes: Step 101b: Determine a second linear representation of each element to be calculated in the multivariate operation task in the linear space; wherein the multivariate operation task is used in the linear space to calculate the amount to be processed according to the intermediate operation relationship to obtain the intermediate amount, and to calculate the unit amount and the intermediate amount according to the target operation relationship; the second linear representation is in floating point format.
[0085] Among them, an expression of a multivariate operation task in a linear space is such as "1+1 / x", where x is the amount to be processed and the unit amount is 1; , It can be a single value or an expression. The intermediate operation is to calculate the reciprocal of the quantity to be processed, obtaining the intermediate quantity "1 / x". The target operation is 1 plus the intermediate quantity.
[0086] Step 102b: Based on the second linear representation, determine the operational mapping relationship after converting the intermediate operational relationship into the logarithmic space; based on the operational mapping relationship, input the second linear representation except the unit quantity into the logarithmic function to obtain the second logarithmic representation, so as to convert the linear representation into the logarithmic space.
[0087] where the second logarithm represents, for example, , the corresponding operation mapping expression is " ”.
[0088] Step 103b: Based on the target accuracy of the multivariate operation task, the numerical size of the quantity to be processed and the target operation relationship, approximate calculation is performed on the unit quantity and the second logarithmic representation in the logarithmic space to obtain a second logarithmic output to perform logarithmic operation.
[0089] The target accuracy and the threshold of the numerical value of the amount to be processed are selected by those skilled in the art according to the specific usage scenario.
[0090] Step 104b: Convert the second logarithmic output into a floating-point format in a linear space to obtain a second target output.
[0091] Specifically, when the multivariate operation task is the unit quantity plus the inverse of the quantity to be processed, the expression of the second logarithmic representation is: , in this expression, Indicates the amount to be processed; the amount to be processed can be a variable or an expression; in one embodiment, the amount to be processed can be .
[0092] When the multivariate operation task is the unit amount minus the reciprocal of the amount to be processed, the expression of the second logarithmic representation is: .
[0093] When the multivariate operation task is to operate on the unit quantity and the reciprocal of the quantity to be processed, the expression of the second logarithmic representation is: ;in, is a symbolic function.
[0094] In the function shown in Table 6 below, the function It is easier to approximate, such as Figure 7 As shown in , it is a positive, monotonically decreasing exponential function with an upper bound of 1 at the origin, indicating that it can match twice the input value. These properties allow for efficient polynomial approximation of this function, especially at fixed precision (converted to relative precision in the linear domain). As precision and accuracy increase, the primary processing burden is the size of the lookup table; increased precision effectively increases the number of cutoff points before the output value is truncated to zero while still within the target accuracy range.
[0095] Table 6 Specific examples of multivariate operations in linear space
[0096] When the multivariate operation task is the logarithm of the unit quantity plus the quantity to be processed, the expression of the second logarithm is: .
[0097] For example, the expression to be calculated is When , the logarithm of the amount to be processed is .
[0098] In one embodiment, when the multivariate operation task is the sum of the unit quantity and the inverse of the quantity to be processed (ie, 1+1 / x), step 103b includes: When the target accuracy is less than the first threshold, or the target accuracy is greater than or equal to the first threshold and less than the second threshold and the amount to be processed is less than or equal to the third threshold, the amount to be processed is calculated according to a first approximate formula to obtain a second logarithmic output; wherein the first approximate formula is: .
[0099] Among them, the target accuracy is the accuracy requirement for the approximation calculation; the first threshold, the second threshold and the third threshold are selected by those skilled in the art according to the specific usage scenario, and the second threshold is greater than the first threshold.
[0100] When the target accuracy requirement is low, all The first approximation formula is used for approximation calculation. Figure 8 As shown, for larger ,have ; The function has relatively low curvature over the entire domain. Also note that the right-hand side of the function Similar behavior (i.e., with flipped signs) occurs in the subtraction case.
[0101] When there is a further requirement for target accuracy and the amount to be processed is small, that is, when the target accuracy is greater than or equal to the first threshold and less than the second threshold and the amount to be processed is less than or equal to the third threshold, use Perform approximate calculations.
[0102] When the target accuracy is greater than or equal to the first threshold and less than the second threshold, and the amount to be processed is greater than the third threshold, the amount to be processed is calculated according to a second approximate formula to obtain a second logarithmic output; wherein the second approximate formula is: .
[0103] When there is a higher requirement for target accuracy and the amount to be processed is large, use Perform approximate calculations.
[0104] When the target accuracy is greater than or equal to a second threshold, the second logarithmic representation is approximated to a corresponding intermediate approximate representation; wherein the expression of the intermediate approximate representation is a third approximate formula: ; Combined with the exponential operation, the integer part of the second logarithmic representation is arithmetically shifted, and the decimal part of the second logarithmic representation is approximated to obtain the second logarithmic output.
[0105] When the target accuracy is very high, use For higher precision, the function Approximating the function and combining it with exponential operations can be more efficient. This can then be combined with exponential operations (where the operation only needs to be approximated in the fractional domain, as the integer portion is simply an arithmetic shift). Since the function converges quickly to a straight line, the increase in lookup table size caused by increased precision can be mitigated to some extent. This is similar to floating-point operations, where addition only requires input alignment (i.e., exponentiation).
[0106] When the multivariate operation task is the unit amount minus the reciprocal of the amount to be processed, step 103b further includes: When the target accuracy is less than the fourth threshold and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to a fourth approximate formula to obtain a second logarithmic output; wherein the fourth approximate formula is: .
[0107] The fourth threshold and the sixth threshold are selected by those skilled in the art according to specific usage scenarios.
[0108] When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to a sixth approximate formula to obtain a second logarithmic output; wherein the sixth approximate formula is: .
[0109] The fifth threshold is selected by those skilled in the art according to a specific usage scenario, and the fifth threshold is greater than the fourth threshold.
[0110] like Figure 9 As shown, when When it is small, the function More difficult to approximate. Figure 10 As shown, for larger , is a negative exponential decreasing function. You can use Make an approximation.
[0111] Generally speaking, for The Taylor series of , is:
[0112]
[0113]
[0114]
[0115] When the target accuracy is less than the fourth threshold and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to the fourth approximate formula or the fifth approximate formula; wherein the fifth approximate formula is: .
[0116] When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to the fifth approximate formula.
[0117] When the target accuracy is greater than or equal to the fifth threshold and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to the seventh approximate formula to obtain a second logarithmic output; wherein the seventh approximate formula is: .
[0118] When the target accuracy is greater than or equal to the fifth threshold and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to an eighth approximate formula to obtain a second logarithmic output; wherein the eighth approximate formula is: .
[0119] For smaller By keeping only the first term of the series, a useful linear approximation is given by
[0120] As shown in FIG. 1 1, by separately computing the simpler logarithmic and linear terms, one can approximate the residual function Figure 11 When becomes sufficiently large, it is beneficial to drop these terms and revert to the original function, the optimal trade-off point being at . Thus one designates as the "near road" and as the "far road".
[0121] In summary, for 1 - 1 / x: when the target accuracy requirement is high, use for approximation computation when the amount of processing is large, and use for approximation computation when the amount of processing is small; when the target accuracy requirement is further high, use for approximation computation when the amount of processing is large, and use for approximation computation when the amount of processing is small; when the target accuracy requirement is low, use for approximation computation when the amount of processing is large, and use or for approximation computation when the amount of processing is small.
[0122] For the case of other operation types than the above operation tasks, as shown in FIG. 12, there are also: Figure 1 In step 20, a first fixed-point representation of the exponential operation task is determined; the exponential operation result of the first fixed-point representation is converted from the fixed-point format to the floating-point format, to obtain the corresponding exponential target output. As shown in FIG. 13, for the logarithmic function, in an embodiment, the input value can be a fixed-point number, the input value enters the logarithmic unit, and then after conversion from the fixed-point number format to the floating-point format, it is directly outputted.
[0123] Figure 2 In step 30, and / or, a first floating-point representation of the logarithmic operation task is determined; the first floating-point representation is converted from the floating-point format to the fixed-point format in the logarithmic space, to obtain the corresponding logarithmic target output.
[0124] As shown in FIG. 14, for the exponential function, in an embodiment, the input value enters the exponential unit, to obtain the processing result, and then after conversion from the floating-point number format to the fixed-point format, it is directly outputted.
[0125] In step 30, and / or, a first floating-point representation of the logarithmic operation task is determined; the first floating-point representation is converted from the floating-point format to the fixed-point format in the logarithmic space, to obtain the corresponding logarithmic target output. Figure 2
[0126] In step 40, and / or, a third linear representation in linear space is determined for other operation tasks; a linear operation is performed on the third linear representation to obtain a third target output; wherein the other operation tasks are operation tasks that cannot be taken logarithm of the third linear representation.
[0127] Other functions that are not suitable for logarithmic space, such as sin, cos, tan, and arctan, will be operated by the ordinary arithmetic operation unit of the linear space, which can be implemented by referring to the prior art by those skilled in the art, and will not be repeated here.
[0128] In the logarithmic space operation model, addition operation is to realize linear multiplication, and multiplication operation is to realize power operation in the logarithmic space operation model; for example, in the linear space, In the logarithmic space, will be converted to Square, square root, reciprocal and reciprocal square root are special cases of y equal to 2; -1 and respectively. Therefore, in the logarithmic space, square, square root, reciprocal and reciprocal square root are , , and .
[0129] It should be noted that, as mentioned earlier, log2 needs to be converted from floating point format to fixed point format in order to facilitate approximation simulation of the target function in a specific numerical range in GPU hardware, so a post-processing stage from fixed point format to floating point format is required, and exp2 needs to be converted from fixed point format to floating point format, so a pre-processing stage from floating point format to fixed point format is required. This can be understood by considering the impact of log2 on 2^exp×(1+mnt×2-mw); where mnt represents the integer part of the mantissa, and mw represents the mantissa bit width. The multiplication instruction or linear algorithm (for example, y×log2x+c) in the middle of the pipeline generally promotes to power (for example ). Square root, reciprocal square root and reciprocal square root can be regarded as special cases of these cases (i.e. with constant y). Therefore, embodiments of the present application can use multiple pipeline instances to limit the use of these functions at a lower cost, and then use an additional parameter to perform more general power operations (or, if the logarithmic operation microarchitecture is only limited to the bandwidth of the register, the general value can also be shared in multiple multiplication pipelines) It should be noted that in embodiments of the present application, the gamma correction function (outside its linear interval) is essentially a power of gamma (with some additional linear operations that can be handled by ordinary floating point operations in the compiler), which can be handled by a special constant or a general logarithmic space multiplication term.
[0130] Based on the method for improving the performance of a computer graphics system according to an embodiment of the present invention, a device for improving the performance of a computer graphics system is also provided, comprising a conversion unit and an operation unit; The conversion unit is used to determine the linear representation of the elements to be calculated of the calculation task in the linear space; and convert the linear representation into the logarithmic space to obtain the corresponding logarithmic representation.
[0131] The operation unit is used to perform logarithmic operation on the logarithmic representation to obtain a logarithmic output; and convert the logarithmic output into a linear space to obtain a target output.
[0132] The operation task may be an addition operation task, the conversion unit includes a first logarithmic conversion unit, and the operation unit includes an addition conversion unit; The first logarithmic conversion unit is used to determine the first linear representation of each element to be operated in the addition operation task in the linear space; wherein the first linear representation is in floating point format; the first linear representation is input into the logarithmic function to obtain the first logarithmic representation.
[0133] The addition conversion unit is used to use an approximate function in the logarithmic space to perform approximate calculations on each first logarithmic representation of the addition operation task to obtain a first logarithmic output; and convert the first logarithmic output into a floating-point format in the linear space to obtain a first target output.
[0134] The device for improving the performance of a computer graphics system according to the embodiment of the present invention further includes a logarithmic operation unit, an exponential operation unit, and a linear operation unit.
[0135] The exponential operation unit is used to determine a first fixed-point representation of the exponential operation task; convert the exponential operation result of the first fixed-point representation from a fixed-point format to a floating-point format to obtain a corresponding exponential target output.
[0136] The logarithmic operation unit is used to determine a first floating-point representation of the logarithmic operation task; convert the first floating-point representation from a floating-point format to a fixed-point format in a logarithmic space to obtain a corresponding logarithmic target output.
[0137] The linear operation unit is used to determine a third linear representation of other operation tasks in the linear space; perform linear operation on the third linear representation to obtain a third target output; wherein the other operation tasks are operation tasks whose third linear representation cannot take logarithms.
[0138] The operation unit further comprises a first logarithmic space unit; wherein the first logarithmic representation comprises a plurality of vectors, each of the vectors comprising a first component and a second component.
[0139] The first logarithmic space unit is used to convert the dot product of the first component and the second component of each vector into a logarithmic addition operation on the first component and the second component in the logarithmic space to obtain multiple logarithmic addition results; sort the logarithmic addition results corresponding to the elements to be operated, and determine the logarithmic addition maximum value and the logarithmic addition minimum value in the logarithmic addition results; determine the difference expression of the logarithmic addition results in the logarithmic space; wherein the difference expression represents the difference between the logarithmic addition minimum value and the logarithmic addition maximum value.
[0140] It is also used to determine the corresponding operation mapping relationship in the logarithmic space according to the linear operation relationship between each vector; and obtain the first logarithmic output according to the operation mapping relationship and the difference expression, so as to obtain the corresponding first target output.
[0141] The computing task may also be a multi-component computing task. The apparatus for improving the performance of a computer graphics system according to an embodiment of the present invention further includes a second logarithmic conversion unit and an approximate computing unit. The second logarithmic conversion unit is used to determine the second linear representation of each element to be operated in the multivariate operation task in the linear space; based on the second linear representation, determine the operation mapping relationship after converting the intermediate operation relationship to the logarithmic space; based on the operation mapping relationship, input the second linear representation except the unit quantity into the logarithmic function to obtain a second logarithmic representation; wherein, the multivariate operation task is used in the linear space to calculate the amount to be processed according to the intermediate operation relationship to obtain the intermediate quantity, and to calculate the unit quantity and the intermediate quantity according to the target operation relationship; the second linear representation is in floating point format.
[0142] The approximate calculation unit is used to perform approximate calculation on the unit quantity and the second logarithmic representation in the logarithmic space according to the target accuracy of the multivariate calculation task, the numerical size of the quantity to be processed and the target operation relationship to obtain a second logarithmic output; and convert the second logarithmic output into a floating-point format in the linear space to obtain a second target output.
[0143] The second logarithmic conversion unit includes a reciprocal addition conversion unit, a reciprocal subtraction conversion unit, a sign function conversion unit and a logarithmic addition conversion unit.
[0144] When the multivariate operation task is the sum of the unit quantity and the reciprocal of the quantity to be processed, the reciprocal addition conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ;in, Indicates the amount to be processed; When the multivariate operation task is to subtract the reciprocal of the amount to be processed from the unit amount, the reciprocal subtraction conversion unit is used to calculate the amount to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ; When the multivariate operation task is to operate on the unit quantity and the reciprocal of the quantity to be processed, the sign function conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ;in, is a symbolic function; When the multivariate operation task is the logarithm of the unit quantity plus the quantity to be processed, the logarithmic addition conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: .
[0145] The approximate calculation unit includes a first approximate unit, a second approximate unit and a third approximate unit: When the target accuracy is less than a first threshold, or the target accuracy is greater than or equal to the first threshold and less than a second threshold and the amount to be processed is less than or equal to a third threshold, the first approximation unit is configured to calculate the amount to be processed according to a first approximation formula to obtain a second logarithmic output; wherein the first approximation formula is: .
[0146] When the target accuracy is greater than or equal to a first threshold and less than a second threshold, and the amount to be processed is greater than a third threshold, the second approximation unit is configured to calculate the amount to be processed according to a second approximation formula to obtain a second logarithmic output; wherein the second approximation formula is: .
[0147] When the target accuracy is greater than or equal to a second threshold, the third approximation unit is used to approximate the second logarithmic representation to a corresponding intermediate approximate representation; wherein the expression of the intermediate approximate representation is a third approximate formula: ; Combined with the exponential operation, the integer part of the second logarithmic representation is arithmetically shifted, and the decimal part of the second logarithmic representation is approximated to obtain the second logarithmic output.
[0148] The approximate calculation unit includes a fourth approximate unit, a fifth approximate unit, a sixth approximate unit, a seventh approximate unit and an eighth approximate unit: When the target accuracy is less than a fourth threshold and the amount to be processed is greater than a sixth threshold, the fourth approximation unit is configured to calculate the amount to be processed according to a fourth approximation formula to obtain a second logarithmic output; wherein the fourth approximation formula is: .
[0149] When the target accuracy is less than a fourth threshold and the amount to be processed is less than or equal to a sixth threshold, the fifth approximation unit is configured to calculate the amount to be processed according to a fourth approximation formula or a fifth approximation formula; wherein the fifth approximation formula is: .
[0150] When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is greater than the sixth threshold, the sixth approximation unit is used to calculate the amount to be processed according to a sixth approximation formula to obtain a second logarithmic output; wherein the sixth approximation formula is: .
[0151] When the target accuracy is greater than or equal to a fourth threshold and less than a fifth threshold, and the amount to be processed is less than or equal to a sixth threshold, the sixth approximation unit is configured to calculate the amount to be processed according to a fifth approximation formula.
[0152] When the target accuracy is greater than or equal to a fifth threshold and the amount to be processed is greater than a sixth threshold, the seventh approximation unit is configured to calculate the amount to be processed according to a seventh approximation formula to obtain a second logarithmic output; wherein the seventh approximation formula is: .
[0153] When the target accuracy is greater than or equal to a fifth threshold and the amount to be processed is less than or equal to a sixth threshold, the eighth approximation unit is configured to calculate the amount to be processed according to an eighth approximation formula to obtain a second logarithmic output; wherein the eighth approximation formula is: .
[0154] In an optional embodiment, the addition operation in the logarithmic operation micro-architecture proposed by the present invention is shown in Table 7 below.
[0155] Table 7 Specific examples of addition operations according to the embodiment of the present invention
[0156] Among them, X_RANGE represents the number of bits of the integer part in the fixed-point format, and the value range of x is [0, 2^X_RANGE-1]; X_PRECISION represents the number of bits after the decimal point in the fixed-point format (i.e., decimal precision); U[X_RANGE].[X_PRECISION] represents an unsigned fixed-point format, consisting of an X_RANGE-bit integer and an X_PRECISION-bit decimal (for example, U5.3 is an 8-bit unsigned number); S[F_RANGE].[F_PRECISION] represents a signed fixed-point format, consisting of an F_RANGE-bit integer (including the sign bit) and an F_PRECISION-bit decimal; U1.[F_PRECISION] represents a 1-bit integer part (unsigned) + F_PRECISION-bit decimal; U0.[F_PRECISION] Indicates a decimal with no integer part (the value is always less than 1) + F_PRECISION bits; xy_arg_max is a 1-bit flag that indicates the larger parameter of x and y; xy_max is the maximum value of x and y; xy_max_div_min is the quotient of the maximum and minimum values; B1 represents a 1-bit binary value; (-1)^sign is the sign function that returns +1 or -1 depending on the value of sign.
[0157] The parameters and restrictions on the parameters in Table 7 above are shown in Table 8 below.
[0158] Table 8 Specific examples of parameters and restrictions for addition operations
[0159] In Table 8, " is the mark of OnePlus components in Table 7; for OnePlus components, the corresponding restrictions are "8(9 )<=F_PRECISION<=15(16 )" means: 9<=F_PRECISION<=16 or 8<=F_PRECISION<=15.
[0160] In the table above, the "Formatted Computation" column represents the fixed-point inputs and outputs corresponding to the input values, which are encoded in logarithmic form and therefore implicitly perform exponential and inverse operations. Formatted computations interpret the inputs and outputs as fixed-point numbers, explicitly applying conversions; these are the functions actually implemented. All components can be implemented in the logarithmic computation microarchitecture proposed in the embodiments of the present invention, outputting fixed-point formats with an accuracy of strictly less than 1 least significant bit unit (ULP). The outputs of the xy_arg_max, xy_max, and xy_max_div_min functions have an accuracy of 1 ULP.
[0161] The first three components can be implemented in a computer graphics processing system in a pipelined (two-stage) hardware implementation: cmx_lib_log2_dp2_even_unresolved, cmx_lib_log2_dp2_odd_unresolved, and cmx_lib_log2_dp2_unresolved; where their final "product" / accumulated term are not processed in order to enable hardware daisy chain pipelining as well as feedback, such as accumulation in further computing microarchitectures.
[0162] DP2EvenResolved = DP2EvenUnresolved * cmx_lib_log2_dp2_even_resolved
[0163] The remaining components are only used to build more complex computing microarchitectures and implement basic arithmetic functions from which more complex computing microarchitectures can be built. Since these functions are univariate, they are easy to verify and validate in a computing microarchitecture implementation.
[0164] The embodiments of the present application use a first brand 14nm library for hardware testing, with a clock frequency of 1 GHz (clock uncertainty of 0.2ns). Three sets of fixed input precisions (10, 16 and 23) are selected, and the total cell area (square microns) is plotted as a function of output precision; wherein, as shown in FIG. 1, the result quality diagram when the input precision is 10 is shown, as shown in FIG. 2, the result quality diagram when the input precision is 16 is shown, as shown in FIG. 3, the result quality diagram when the input precision is 23 is shown. Figure 12 Figure 13 Figure 14
[0165] While not directly comparable due to differences in operation counts and error characteristics, the fused multiply-add (FMA) results are included in the above description. FMA is a fused multiply-add operation A×B+C, using the IEEE 754 standard's default rounding mode (round to nearest, ties to even). FMA is a common single-arithmetic logic unit (ALU) operation used to compute the linear equation A×B+C in a single step in hardware. "Fused" refers to the fact that the FMA operation rounds only once to the final result, rather than performing intermediate rounding after calculating A×B before adding it to C. FMA is generally insensitive to output precision but insensitive to highly sensitive input precision, while the opposite is true for these functions. This specialized architecture is highly competitive when component products must execute with high-precision inputs but may produce relatively low-precision outputs, such as in parts of the texture filtering pipeline in computer graphics systems.
[0166] It is worth noting that without modifying the DP2EvenUnresolved component, it is possible to calculate .
[0167] Finally, in an optional embodiment, an output precision of 15 is the upper limit of the logarithmic operation microarchitecture of the embodiment of the present invention in terms of time and reasonable piecewise linear approximation.
[0168] On this basis, the embodiment of the present invention also proposes a texture filtering method based on a logarithmic algorithm. The logarithmic operation micro-architecture of the embodiment of the present invention can be used in the texture processing pipeline of the computer graphics processing system for arithmetic calculation of the texture filtering fixed-point format, thereby improving the texture processing performance in the computer graphics processing system. Figure 15 As shown, it also includes: In step 501, texture coordinates and texture sample colors corresponding to the texture coordinates are obtained; wherein the texture coordinates and the texture sample colors are in floating point format.
[0169] In step 502, the texture coordinates and the texture sample colors are converted into a logarithmic space to obtain corresponding logarithmic representations of coordinates and colors.
[0170] In step 503, a logarithmic operation is performed on the coordinate logarithmic representation and the corresponding color logarithmic representation to obtain a color logarithmic output corresponding to the texture coordinates.
[0171] In step 504, a plurality of the color logarithmic outputs are accumulated to obtain a texture color to be converted; and the texture color to be converted is converted into a floating point format in a linear space to obtain a target texture color.
[0172] In this embodiment, the texture coordinates and the texture sample colors are both elements to be calculated, and the texture coordinates and the texture sample colors are in floating point format, that is, the texture coordinates and the texture sample colors respectively correspond to the linear representation of the above-mentioned embodiment.
[0173] During steps 502 and 503, the operations performed on the texture coordinates and texture sample colors correspond to the computation tasks described in the aforementioned embodiment. As can be seen from the preceding description, different computation tasks lead to different methods for calculating the logarithmic representation and outputting the logarithmic representation. Therefore, in this embodiment, the computation method to be used is determined based on the operations performed on the texture coordinates and texture sample colors. The specific computation process is described in the aforementioned embodiment and will not be further elaborated here.
[0174] In actual application scenarios, steps 502 and 503 are mostly multiplication operations, reciprocal operations, or multivariate operations according to embodiments of the present invention.
[0175] For example, during texture filtering, the elements to be calculated are the texture sample color and the texture filter weight, and a multiplication operation is performed on the two. Texture filtering often involves addition operations, such as accumulating multiple values (e.g., texture sample colors), which can be accomplished using the operation steps of step 103a. For example, the dot product of the first and second components of each vector is converted to a logarithmic addition operation in logarithmic space, resulting in multiple logarithmic addition results and ultimately a first logarithmic output. For another example, during texture mapping, if the texture coordinate span of a screen pixel corresponds to multiple texels, the most appropriate mipmap level must be selected. Trilinear filtering selects the two closest mipmap levels, performs bilinear interpolation on each, and then linearly interpolates the results. When calculating the interpolation weights for bilinear or trilinear interpolation, 1+1 / G and 1-1 / G must be calculated. For another example, in texture analysis, when calculating the gradient amplitude, if the gradient amplitude G is small, the edge response can be amplified by calculating 1+1 / G; if G is large, the noise can be suppressed by calculating 1-1 / G to adjust the result; the operation in step 10 can be followed.
[0176] In step 502, the linear representation (floating point format) of the texture sample color in the linear space is determined; the linear representation is converted to the logarithmic space to obtain its logarithmic representation; for ease of calculation, directly in the following example Figure 16The texture filter unit shown in the figure pre-stores texture filter weights in logarithmic form and obtains them when calculation is required.
[0177] Since the operation required to be performed on the two elements to be operated on in linear space is multiplication, a logarithmic addition operation needs to be performed in logarithmic space. In step 503, a logarithmic addition operation is performed on the texture filter weights and the corresponding logarithmic representation to obtain the corresponding color logarithmic output (i.e., logarithmic output).
[0178] The texture processing unit in a computer graphics system takes the texture coordinates of a pixel's texture sample in floating-point format and the color of the texture sample at a certain location in the texture sampling as input, applies texture filter weights, and generates the target texture color for the pixel. Due to the low precision requirements for the target texture color, such as 8-bit integer color format, texture processing is typically performed in a fixed-point function pipeline, with arithmetic operations performed in fixed-point format, to reduce the hardware cost of the computer graphics system.
[0179] The texture coordinates are converted to fixed-point format in the texture processing unit and used to calculate the texture filter weights Wi. The target texture color is calculated by accumulating the colors of all texture samples and multiplying them by the texture filter weights. Different texture filtering algorithms use different numbers of texture samples and different texture filter weights.
[0180] like Figure 16 As shown, in this embodiment of the present invention, floating-point texture coordinates are converted to logarithmic space instead of being converted to fixed-point format in the texture processing unit. Special arithmetic operations used in texture filtering, such as multiplication and reciprocal, are simplified in logarithmic space in the logarithmic operation microarchitecture of this embodiment of the present invention. Target texture color is in accordance with , by accumulating the weights of the texture filter All texture sample colors added In the logarithmic space of the embodiment of the present invention, the target texture color is expressed as , thus simplifying the calculation of texture filtering.
[0181] The device for improving the performance of a computer graphics system also includes a texture conversion unit and a texture filtering unit; the texture conversion unit is used to obtain texture coordinates and texture sample colors corresponding to the texture coordinates; wherein the texture coordinates and the texture sample colors are in floating-point format; and is also used to convert the texture coordinates and the texture sample colors into a logarithmic space to obtain corresponding coordinate logarithmic representation and color logarithmic representation.
[0182] The texture filtering unit is used to perform logarithmic operations on the coordinate logarithmic representation and the corresponding color logarithmic representation to obtain the color logarithmic output corresponding to the texture coordinates; it is also used to accumulate multiple color logarithmic outputs to obtain the texture color to be converted; and convert the texture color to be converted into a floating point format to obtain a target texture color.
[0183] like Figure 17 FIG. 1 is a schematic diagram of the architecture of a device for improving the performance of a computer graphics system according to an embodiment of the present invention. The device for improving the performance of a computer graphics system according to this embodiment includes one or more processors 21 and a memory 22. Figure 17 A processor 21 is taken as an example.
[0184] The processor 21 and the memory 22 may be connected via a bus or other means. Figure 17 The bus connection is taken as an example.
[0185] Memory 22, as a nonvolatile computer-readable storage medium, can be used to store nonvolatile software programs and nonvolatile computer-executable programs, such as the method for improving computer graphics system performance in this embodiment. Processor 21 executes the method for improving computer graphics system performance by running the nonvolatile software programs and instructions stored in memory 22.
[0186] The memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 22 may optionally include a memory remotely located relative to the processor 21, and such remote memory may be connected to the processor 21 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0187] The program instructions / modules are stored in the memory 22 , and when executed by the one or more processors 21 , the method for improving the performance of a computer graphics system in the above embodiment is performed.
[0188] An embodiment of the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, for example Figure 17 A processor 21 can enable the above one or more processors to execute the method for improving the performance of the computer graphics system in the specific embodiment of the present invention; it can also realize Figure 17 The various modules and units described above; or the method for improving the performance of a computer graphics system according to a specific embodiment of the present invention; or Figure 17 The various modules and units described.
[0189] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific content can be found in the description of the method embodiment of the present invention and will not be repeated here.
[0190] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk or an optical disk, etc.
[0191] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for improving the performance of a computer graphics system, characterized in that: include: Determine a linear representation of an element to be operated on of the operation task in a linear space; convert the linear representation into a logarithmic space to obtain a corresponding logarithmic representation; Performing a logarithmic operation on the logarithmic representation to obtain a logarithmic output; converting the logarithmic output to a linear space to obtain a target output.
2. The method for improving the performance of a computer graphics system according to claim 1, wherein: When the operation task is an addition operation task in a linear space, the method includes: Determining a first linear representation of each to-be-operated element in the addition operation task in a linear space; wherein the first linear representation is in a floating-point format; Inputting the first linear representation into a logarithmic function to obtain a first logarithmic representation; Using an approximate function in a logarithmic space, performing an approximate calculation on each first logarithmic representation of the addition operation task to obtain a first logarithmic output; The first logarithmic output is converted into a floating-point format in a linear space to obtain a first target output.
3. The method for improving the performance of a computer graphics system according to claim 2, wherein: The first logarithmic representation includes a plurality of vectors, each of the vectors including a first component and a second component; The method comprises: Converting the dot product of the first component and the second component of each vector into a logarithmic addition operation on the first component and the second component in a logarithmic space to obtain a plurality of logarithmic addition results; Sorting the logarithmic addition results corresponding to the elements to be operated on, determining a logarithmic addition maximum value and a logarithmic addition minimum value among the logarithmic addition results; determining a difference expression of the logarithmic addition results in a logarithmic space; wherein the difference expression represents a difference between the logarithmic addition minimum value and the logarithmic addition maximum value; According to the linear operation relationship between each vector, the corresponding operation mapping relationship is determined in the logarithmic space; A first logarithmic output is obtained according to the operation mapping relationship and the difference expression.
4. The method for improving the performance of a computer graphics system according to claim 3, wherein: The first logarithmic representation includes a first vector and a second vector; wherein the first vector is ( , ), the second vector is ( , ); is the first component of the first vector, is the second component of the first vector, is the first component of the second vector, is the second component of the second vector; When the linear operation relationship is an even relationship, the expression of the first logarithmic output is: ; When the linear operation relationship is an odd relationship, the expression of the first logarithmic output is: ; When the linear operation relationship is uncertain, the expression of the first logarithmic output is: ;in, is a symbolic function.
5. The method for improving the performance of a computer graphics system according to claim 1, wherein: When the computing task is a multi-component computing task, the method includes: Determining a second linear representation of each element to be operated in the multivariate operation task in a linear space; wherein the multivariate operation task is used in the linear space to calculate the amount to be processed according to the intermediate operation relationship to obtain an intermediate amount, and to calculate the unit amount and the intermediate amount according to the target operation relationship; the second linear representation is in a floating point format; Determining, based on the second linear representation, an operational mapping relationship after converting the intermediate operational relationship into a logarithmic space; inputting the second linear representation excluding the unit quantity into a logarithmic function based on the operational mapping relationship to obtain a second logarithmic representation, so as to convert the linear representation into a logarithmic space; performing an approximate calculation on the unit quantity and the second logarithmic representation in a logarithmic space according to a target accuracy of the multivariate operation task, a numerical value of the quantity to be processed, and the target operation relationship, to obtain a second logarithmic output for performing a logarithmic operation; The second logarithmic output is converted into a floating-point format in a linear space to obtain a second target output.
6. The method for improving the performance of a computer graphics system according to claim 5, wherein: When the multivariate operation task is the unit quantity plus the inverse of the quantity to be processed, the expression of the second logarithmic representation is: ;in, Indicates the amount to be processed; When the multivariate operation task is the unit amount minus the reciprocal of the amount to be processed, the expression of the second logarithmic representation is: ; When the multivariate operation task is to operate on the unit quantity and the reciprocal of the quantity to be processed, the expression of the second logarithmic representation is: ;in, is a symbolic function; When the multivariate operation task is the logarithm of the unit quantity plus the quantity to be processed, the expression of the second logarithm is: .
7. The method for improving the performance of a computer graphics system according to claim 6, wherein: When the multivariate operation task is the unit quantity plus the inverse of the quantity to be processed, the method includes: When the target accuracy is less than the first threshold, or the target accuracy is greater than or equal to the first threshold and less than the second threshold and the amount to be processed is less than or equal to the third threshold, the amount to be processed is calculated according to a first approximate formula to obtain a second logarithmic output; wherein the first approximate formula is: ; When the target accuracy is greater than or equal to the first threshold and less than the second threshold, and the amount to be processed is greater than the third threshold, the amount to be processed is calculated according to a second approximate formula to obtain a second logarithmic output; wherein the second approximate formula is: ; When the target accuracy is greater than or equal to a second threshold, the second logarithmic representation is approximated to a corresponding intermediate approximate representation; wherein the expression of the intermediate approximate representation is a third approximate formula: ; Combined with the exponential operation, the integer part of the second logarithmic representation is arithmetically shifted, and the decimal part of the second logarithmic representation is approximated to obtain the second logarithmic output.
8. The method for improving the performance of a computer graphics system according to claim 6, wherein: When the multivariate operation task is the unit amount minus the reciprocal of the amount to be processed, the method includes: When the target accuracy is less than the fourth threshold and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to a fourth approximate formula to obtain a second logarithmic output; wherein the fourth approximate formula is: ; When the target accuracy is less than the fourth threshold and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to the fourth approximate formula or the fifth approximate formula; wherein the fifth approximate formula is: ; When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to a sixth approximate formula to obtain a second logarithmic output; wherein the sixth approximate formula is: ; When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to the fifth approximation formula; When the target accuracy is greater than or equal to the fifth threshold and the amount to be processed is greater than the sixth threshold, the amount to be processed is calculated according to the seventh approximate formula to obtain a second logarithmic output; wherein the seventh approximate formula is: ; When the target accuracy is greater than or equal to the fifth threshold and the amount to be processed is less than or equal to the sixth threshold, the amount to be processed is calculated according to an eighth approximate formula to obtain a second logarithmic output; wherein the eighth approximate formula is: .
9. The method for improving the performance of a computer graphics system according to claim 1, wherein: Also includes: Determining a first fixed-point representation of an exponential operation task; converting an exponential operation result of the first fixed-point representation from a fixed-point format to a floating-point format to obtain a corresponding exponential target output; and / or, determining a first floating-point representation of the logarithmic operation task; converting the first floating-point representation from a floating-point format to a fixed-point format in a logarithmic space to obtain a corresponding logarithmic target output; And / or, determine a third linear representation of other computing tasks in the linear space; perform linear operations on the third linear representation to obtain a third target output; wherein the other computing tasks are computing tasks whose third linear representation cannot take a logarithm.
10. The method for improving the performance of a computer graphics system according to any one of claims 1 to 9, characterized in that: Also includes: Obtaining texture coordinates and texture sample colors corresponding to the texture coordinates; wherein the texture coordinates and the texture sample colors are in floating point format; Converting the texture coordinates and the texture sample colors into logarithmic space to obtain corresponding logarithmic representations of coordinates and colors; performing a logarithmic operation on the coordinate logarithmic representation and the corresponding color logarithmic representation to obtain a color logarithmic output corresponding to the texture coordinate; Accumulating a plurality of the color logarithmic outputs to obtain a texture color to be converted; and converting the texture color to be converted into a floating point format in a linear space to obtain a target texture color.
11. A device for improving the performance of a computer graphics system, characterized in that: It includes a conversion unit and an operation unit, wherein: The conversion unit is used to determine the linear representation of the elements to be calculated of the calculation task in the linear space; convert the linear representation into the logarithmic space to obtain the corresponding logarithmic representation; The operation unit is used to perform logarithmic operation on the logarithmic representation to obtain a logarithmic output; and convert the logarithmic output into a linear space to obtain a target output.
12. The device for improving the performance of a computer graphics system according to claim 11, wherein: The operation task includes an addition operation task, the conversion unit includes a first logarithmic conversion unit, and the operation unit includes an addition conversion unit; The first logarithmic conversion unit is configured to determine a first linear representation of each element to be operated in the addition operation task in a linear space; wherein the first linear representation is in a floating-point format; and input the first linear representation into a logarithmic function to obtain a first logarithmic representation; The addition conversion unit is used to use an approximate function in the logarithmic space to perform approximate calculations on each first logarithmic representation of the addition operation task to obtain a first logarithmic output; and convert the first logarithmic output into a floating-point format in the linear space to obtain a first target output.
13. The device for improving the performance of a computer graphics system according to claim 12, wherein: It also includes a logarithmic operation unit, an exponential operation unit and a linear operation unit; The exponential operation unit is configured to determine a first fixed-point representation of the exponential operation task; convert the exponential operation result of the first fixed-point representation from a fixed-point format to a floating-point format to obtain a corresponding exponential target output; The logarithmic operation unit is used to determine a first floating-point representation of the logarithmic operation task; Converting the first floating-point representation from a floating-point format to a fixed-point format in a logarithmic space to obtain a corresponding logarithmic target output; The linear operation unit is used to determine a third linear representation of other operation tasks in the linear space; perform linear operation on the third linear representation to obtain a third target output; wherein the other operation tasks are operation tasks whose third linear representation cannot take logarithms.
14. The device for improving the performance of a computer graphics system according to claim 12, wherein: The operation unit further includes a first logarithmic space unit; wherein the first logarithmic representation includes a plurality of vectors, each of the vectors including a first component and a second component; The first logarithmic space unit is configured to convert the dot product of the first component and the second component of each vector into a logarithmic addition operation performed on the first component and the second component in the logarithmic space to obtain a plurality of logarithmic addition results; sort the logarithmic addition results corresponding to the elements to be operated on, and determine a logarithmic maximum value and a logarithmic minimum value among the logarithmic addition results; and determine a difference expression of the logarithmic addition results in the logarithmic space; wherein the difference expression represents a difference between the logarithmic minimum value and the logarithmic maximum value; It is also used to determine the corresponding operation mapping relationship in the logarithmic space according to the linear operation relationship between each vector; and obtain the first logarithmic output according to the operation mapping relationship and the difference expression, so as to obtain the corresponding first target output.
15. The device for improving the performance of a computer graphics system according to claim 11, wherein: The computing task includes a multivariate computing task, and the device for improving the performance of a computer graphics system further includes a second logarithmic conversion unit and an approximate computing unit; The second logarithmic conversion unit is used to determine a second linear representation of each element to be operated in the multivariate operation task in the linear space; determine an operation mapping relationship after converting the intermediate operation relationship into the logarithmic space based on the second linear representation; input the second linear representation except the unit quantity into the logarithmic function based on the operation mapping relationship to obtain a second logarithmic representation; wherein the multivariate operation task is used in the linear space to calculate the amount to be processed according to the intermediate operation relationship to obtain the intermediate quantity, and to calculate the unit quantity and the intermediate quantity according to the target operation relationship; the second linear representation is in floating point format; The approximate calculation unit is used to perform approximate calculation on the unit quantity and the second logarithmic representation in the logarithmic space according to the target accuracy of the multivariate calculation task, the numerical size of the quantity to be processed and the target operation relationship to obtain a second logarithmic output; and convert the second logarithmic output into a floating-point format in the linear space to obtain a second target output.
16. The device for improving the performance of a computer graphics system according to claim 15, wherein: The second logarithmic conversion unit includes a reciprocal addition conversion unit, a reciprocal subtraction conversion unit, a sign function conversion unit and a logarithmic addition conversion unit; When the multivariate operation task is the sum of the unit quantity and the reciprocal of the quantity to be processed, the reciprocal addition conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ;in, Indicates the amount to be processed; When the multivariate operation task is to subtract the reciprocal of the amount to be processed from the unit amount, the reciprocal subtraction conversion unit is used to calculate the amount to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ; When the multivariate operation task is to operate on the unit quantity and the reciprocal of the quantity to be processed, the sign function conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: ;in, is a symbolic function; When the multivariate operation task is the logarithm of the unit quantity plus the quantity to be processed, the logarithmic addition conversion unit is used to calculate the quantity to be processed according to the instruction set to obtain a corresponding second logarithmic representation, and the expression of the second logarithmic representation is: .
17. The device for improving the performance of a computer graphics system according to claim 16, wherein: The approximate calculation unit includes a first approximate unit, a second approximate unit and a third approximate unit; When the target accuracy is less than a first threshold, or the target accuracy is greater than or equal to the first threshold and less than a second threshold and the amount to be processed is less than or equal to a third threshold, the first approximation unit is configured to calculate the amount to be processed according to a first approximation formula to obtain a second logarithmic output; wherein the first approximation formula is: ; When the target accuracy is greater than or equal to a first threshold and less than a second threshold, and the amount to be processed is greater than a third threshold, the second approximation unit is configured to calculate the amount to be processed according to a second approximation formula to obtain a second logarithmic output; wherein the second approximation formula is: ; When the target accuracy is greater than or equal to a second threshold, the third approximation unit is used to approximate the second logarithmic representation to a corresponding intermediate approximate representation; wherein the expression of the intermediate approximate representation is a third approximate formula: ; Combined with the exponential operation, the integer part of the second logarithmic representation is arithmetically shifted, and the decimal part of the second logarithmic representation is approximated to obtain the second logarithmic output.
18. The device for improving the performance of a computer graphics system according to claim 16, wherein: The approximate calculation unit includes a fourth approximate unit, a fifth approximate unit, a sixth approximate unit, a seventh approximate unit and an eighth approximate unit; When the target accuracy is less than a fourth threshold and the amount to be processed is greater than a sixth threshold, the fourth approximation unit is configured to calculate the amount to be processed according to a fourth approximation formula to obtain a second logarithmic output; wherein the fourth approximation formula is: ; When the target accuracy is less than a fourth threshold and the amount to be processed is less than or equal to a sixth threshold, the fifth approximation unit is configured to calculate the amount to be processed according to a fourth approximation formula or a fifth approximation formula; wherein the fifth approximation formula is: ; When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is greater than the sixth threshold, the sixth approximation unit is used to calculate the amount to be processed according to a sixth approximation formula to obtain a second logarithmic output; wherein the sixth approximation formula is: ; When the target accuracy is greater than or equal to the fourth threshold and less than the fifth threshold, and the amount to be processed is less than or equal to the sixth threshold, the sixth approximation unit is used to calculate the amount to be processed according to the fifth approximation formula; When the target accuracy is greater than or equal to a fifth threshold and the amount to be processed is greater than a sixth threshold, the seventh approximation unit is configured to calculate the amount to be processed according to a seventh approximation formula to obtain a second logarithmic output; wherein the seventh approximation formula is: ; When the target accuracy is greater than or equal to a fifth threshold and the amount to be processed is less than or equal to a sixth threshold, the eighth approximation unit is configured to calculate the amount to be processed according to an eighth approximation formula to obtain a second logarithmic output; wherein the eighth approximation formula is: .
19. The device for improving the performance of a computer graphics system according to claim 11, wherein: The device for improving the performance of a computer graphics system further comprises a texture conversion unit and a texture filtering unit; The texture conversion unit is configured to obtain texture coordinates and texture sample colors corresponding to the texture coordinates, wherein the texture coordinates and the texture sample colors are in floating-point format; and is further configured to convert the texture coordinates and the texture sample colors into a logarithmic space to obtain corresponding logarithmic representations of the coordinates and the colors; The texture filtering unit is used to perform logarithmic operations on the coordinate logarithmic representation and the corresponding color logarithmic representation to obtain the color logarithm output corresponding to the texture coordinates; it is also used to accumulate multiple color logarithmic outputs to obtain the texture color to be converted; and convert the texture color to be converted into a floating-point format in a linear space to obtain a target texture color.
20. A non-volatile computer storage medium, characterized in that The computer storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors to implement the method for improving the performance of a computer graphics system according to any one of claims 1 to 10.
