A texture sampling method and system based on texture object segmentation

By segmenting the texture object and dividing it into multiple new texture objects, the texture unit can effectively sample texture objects with pixel bit widths larger than the sampling bit width, solving the problem of waste of texture unit resources and low utilization, and achieving efficient texture sampling and simplified sampling operations.

CN114463400BActive Publication Date: 2025-04-15NO 709 RES INST OF CHINA SHIPBUILDING IND CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210071725.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-21
Publication Date
2025-04-15
Estimated Expiration
2042-01-21

AI Technical Summary

Technical Problem

It is difficult for the prior art to effectively sample texture objects whose pixel bit width is larger than the sampling bit width, the number of color components is more than 2, and all component bit widths are smaller than the sampling bit width, resulting in waste of hardware resources of texture units and low utilization rate.

Method used

By segmenting a single texture object, it is divided into multiple new texture objects, each new texture object's pixel format is the pixel format supported by the texture unit, allowing the texture unit to perform texture sampling.

Benefits of technology

Effective texture sampling of texture objects whose pixel bit width is larger than the sampling bit width is realized, improving the utilization rate of texture units, and simplifying the repeated texture sampling operation of the same texture object.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114463400B_ABST
    Figure CN114463400B_ABST
Patent Text Reader

Abstract

The invention discloses a texture sampling method and system based on texture object segmentation, wherein the texture sampling method comprises: a preprocessing step, a texture object segmentation step, a sampling instruction rewriting step, a sampling instruction calling step and a sampling result reorganization step; the invention divides a texture object whose pixel bit width is greater than the sampling bit width, the number of color components is more than 2 and the bit widths of all components are less than the sampling bit width into a plurality of new texture objects, the pixel format of the new texture object is the pixel format supported by the texture unit; then texture sampling is performed on each new texture object respectively, and the sampling results are reorganized to generate a final sampling color value; the invention only performs a texture object segmentation operation and generates a sampling instruction set when texture sampling is performed on the texture object for the first time, and only needs to call the sampling instruction set for repeated texture sampling of the texture object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing, and more specifically, relates to a texture sampling method and system based on texture object segmentation. Background Art

[0002] Graphics rendering is a technology that converts two-dimensional or three-dimensional graphics into two-dimensional images that can be displayed by computers. It is widely used in computer-aided design, geographic information systems, virtual reality and other fields.

[0003] Texture generally refers to a 2D flat image; texture sampling is the act of obtaining color values ​​from a texture object and providing them to the shader program for graphics rendering. Existing texture sampling methods mainly include two categories: one is to perform texture sampling through a 3D graphics pipeline to obtain texture sampling result data corresponding to the texture; the other is to use a general computing pipeline to implement a texture sampler.

[0004] The process of texture sampling is as follows: the graphics card of the PC contains a graphics processor GPU, which contains two hardware units: a shading unit and a texture unit; the shading language compiler is a software module installed on the same PC, which is used to compile the shader program and then transmit it to the shading unit, and the shading unit executes the program; the texture sampling instruction is a type of instruction in the shader program; the shader program controls the texture unit to perform texture sampling operations: the texture unit obtains the texture object and sampling coordinates according to the texture sampling instruction; and establishes a coordinate system with the lower left corner of the texture object as the origin, searches for the sampling color value corresponding to the sampling coordinate in the video memory of the graphics card, and transmits it to the shader program; the process of the texture unit searching for the sampling color value is as follows:

[0005] 1) Select pixel points: select 4 or 8 or other number of pixel points close to the sampling coordinates according to the pre-set rules; the following process takes 4 pixel points as an example;

[0006] 2) Extract color components: Update the sampling bit width value to the pixel bit width value of the texture object, and set the corresponding sampling mode according to the pixel bit width value. Different pixel bit widths correspond to different sampling modes. According to the set sampling mode, for each selected pixel point, take out the data in the corresponding storage space. According to the pixel format corresponding to the texture object, use shift and logical operation instructions to extract the component values ​​of each color component from the obtained data and generate a new color value.

[0007] 3) Generate sampled color values: Take the average value of each color component of the new color value generated for each pixel. The four average values ​​are the component values ​​of the four color components of the sampled color value.

[0008] However, when designing a texture unit, in addition to the limitations of many objective conditions, it is also necessary to consider the number of pixel formats supported and the utilization of the texture unit. According to the current graphics standards, if you want to support as many types of textures as possible, the sampling bit width of the texture unit must be designed according to the larger pixel bit width of all pixel formats. However, since the frequency of use of such texture objects in actual usage scenarios is very low, the hardware resources of the texture unit are wasted in most scenarios, resulting in low utilization; if the sampling bit width of the texture unit is designed according to the pixel bit width of the commonly used pixel format, the utilization of such a texture unit in most scenarios is improved, but it is impossible to sample pixel formats with higher pixel bit widths.

[0009] When the pixel bit width of a certain pixel format is greater than the sampling bit width, the texture unit determines the pixel format as an unsupported pixel format and does not perform texture sampling operations on the pixel format; the prior art does not provide a solution to this problem.

[0010] In order to facilitate the understanding of the present invention, the following explains relevant terms and related concepts:

[0011] Color value: Each pixel corresponds to a color value, which is data containing up to 4 color components, namely red, green, blue and transparency. The value of a color component is called a component value. The bit width of a component value is expressed in bits, which is called a component bit width. The pixel bit width is obtained by adding up the bit widths of each component. The storage of a color value requires a storage space, and the bit width of the storage space is consistent with the pixel bit width. The storage space continuously stores the component values ​​of the color value starting from its starting storage position.

[0012] Texture object: A texture object corresponds to a rectangular image and a texture parameter set. The rectangular image is composed of pixels. The texture parameter set includes pixel format, width, height and starting storage address. A texture object corresponds to a pixel format. The pixel format of all pixels in the texture object is the same. The pixel format includes the number of color components of the pixel, the name, the component storage order and the component bit width of each color component. Among them, the width is the number of horizontal pixels of the rectangular image, the height is the number of vertical pixels of the rectangular image, and the component storage order is the component values ​​of all color components of a color value in its corresponding The storage order in the corresponding storage space; Common pixel formats include RGB16, RGBA8, RGB565, RGB32F, etc.; Taking RGB565 as an example, the number of color components of a pixel point with a pixel format of RGB565 is 3, and the names are red, green and blue respectively; the red component bit width is 5 bits, the green component bit width is 6 bits, and the blue component bit width is 5 bits; the pixel bit width is 16 bits; the component storage order is red, green and blue; the texture object in the present invention refers to a texture object whose pixel bit width is greater than the sampling bit width, the number of color components is more than 2, and all component bit widths are less than the sampling bit width;

[0013] Storage order of pixels: The color values ​​of all pixels contained in a texture object are stored in the video memory of the graphics card according to the length, width and starting storage address of its texture parameter set. The color values ​​of the pixels in the first row from left to right are stored starting from the starting storage address, and then the color values ​​of the pixels in the second row from left to right are stored... and so on, until the color values ​​of all pixels are stored;

[0014] Sampling coordinates: A coordinate system is established with the lower left corner of the texture object as the origin, the origin coordinates are (0, 0), and the coordinates of the upper right corner are (1, 1); the sampling coordinates are the coordinates of a sampling point in the coordinate system, and the texture unit obtains the color value from the texture object according to the sampling coordinates;

[0015] Sampling bit width: When a texture unit obtains the color value of a pixel next to a sampling point from a texture object, the maximum number of bits that can be obtained from the storage space corresponding to the color value of a single pixel;

[0016] Shader program: an instruction sequence consisting of several shader instructions;

[0017] Sampling instruction: An instruction in a shader program. A texture sampling instruction contains a handle and a sampling coordinate, where the handle corresponds to a texture object; the sampling coordinate is a variable, and the value of the sampling coordinate can be modified when the sampling instruction is called. Summary of the invention

[0018] In view of the defects of the prior art, the purpose of the present invention is to provide a texture sampling method and system based on texture object segmentation, aiming to solve the problem of texture sampling for texture objects whose pixel bit width is greater than the sampling bit width, the number of color components is more than 2, and all component bit widths are less than the sampling bit width.

[0019] To achieve the above object, the present invention provides a texture object segmentation method for performing a segmentation operation on a single texture object;

[0020] According to the number of color components of the single texture object, the same number of letters are selected from letters A, B, C and D in sequence to represent the values ​​of the component bit widths from small to large;

[0021] If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order;

[0022] M is the sampling bit width;

[0023] The following steps are involved:

[0024] Step (1):

[0025] For a single texture object, determine whether A+B>M. If yes, execute step (2); otherwise, execute step (8).

[0026] Step (2):

[0027] Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if so, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, execute step (3);

[0028] Step (3):

[0029] Determine whether B+C>M. If yes, execute step (4); otherwise, execute step (6).

[0030] Step (4):

[0031] Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if so, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, execute step (5);

[0032] Step (5):

[0033] Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end;

[0034] Step (6):

[0035] Determine whether the number of color components is 3. If so, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, execute step (7);

[0036] Step (7):

[0037] Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end;

[0038] Step (8):

[0039] Determine whether A+B+C>M. If yes, execute step (9). Otherwise, perform a segmentation operation on the color components corresponding to A, B, and C to form a first new texture object; perform a segmentation operation on the color component corresponding to D to form a second new texture object; end;

[0040] Step (9):

[0041] Determine whether the number of color components is 3. If yes, perform segmentation operations on the color components corresponding to A and B and the color component corresponding to C respectively, and form the first and second new texture objects accordingly; end; otherwise, execute step (10);

[0042] Step (10):

[0043] Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object;

[0044] When X is A, B, C or D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component value corresponding to X in each pixel is read out in turn, and each component value forms a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0045] When X is A and B, B and C, C and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in sequence, and the two component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0046] When X is A, B, C, B, C, and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in sequence, and the three component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0047] The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0".

[0048] Preferably, in the segmentation operation, when the two or three component values ​​corresponding to each pixel point form a new pixel point, the component storage order is: sort the two or three component values ​​from small to large according to their corresponding component bit widths, and the sorting order is the component storage order.

[0049] The present invention provides a texture sampling method based on the above texture object segmentation method, comprising the following steps:

[0050] (1) Preprocessing steps:

[0051] Find the texture object corresponding to the original sampling instruction. If the original sampling instruction is an instruction for performing texture sampling on the texture object for the first time, execute step (2); otherwise, execute step (4).

[0052] The original sampling instruction is the sampling instruction currently being compiled;

[0053] (2) Texture object segmentation steps:

[0054] According to the texture object segmentation method described above, the texture object is segmented into a plurality of new texture objects to form a texture object set;

[0055] (3) Sampling instruction rewriting steps:

[0056] Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as the corresponding original sampling instruction; call the sampling instruction set;

[0057] (4) Sampling instruction calling steps:

[0058] Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction to obtain new sampling instructions to form a new sampling instruction set; call the new sampling instruction set;

[0059] (5) Sampling result reorganization steps:

[0060] Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

[0061] Preferably, in the sampling result reorganization step, the process of returning a sampled color value is:

[0062] (1) According to a preset rule, select 4 or 8 or other number of pixel points adjacent to the sampling coordinates in each new texture object;

[0063] (2) for each selected pixel point, taking out the data in the corresponding storage space; using shift and logic operation instructions to extract the component values ​​of each color component from the data in the storage space, and generating a new color value according to the pixel format corresponding to each new texture object;

[0064] (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value;

[0065] (4) Return the sampled color value corresponding to each new texture object;

[0066] In the sampling result reorganization step, the process of reorganizing into a final sampling color value is as follows:

[0067] (1) for each sampled color value, extracting the name and component value of each color component according to the pixel format of the corresponding new texture object;

[0068] (2) Combine all the extracted color components into a final sampled color value.

[0069] The present invention provides a texture object segmentation system for performing segmentation operations on a single texture object;

[0070] According to the number of color components of the single texture object, the same number of letters are selected from letters A, B, C and D in sequence to represent the values ​​of the component bit widths from small to large;

[0071] If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order;

[0072] M is the sampling bit width;

[0073] Includes the following modules:

[0074] Module 1:

[0075] For a single texture object, determine whether A+B>M, if yes, execute the operation in the second module, otherwise execute the operation in the eighth module;

[0076] Module 2:

[0077] Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if yes, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, perform the operation in the third module;

[0078] Module 3:

[0079] Determine whether B+C>M, if yes, execute the operation in the fourth module, otherwise execute the operation in the sixth module;

[0080] Module 4:

[0081] Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if yes, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, perform the operation in the fifth module;

[0082] Module 5:

[0083] Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end;

[0084] Module 6:

[0085] Determine whether the number of color components is 3, if yes, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, perform the operation in the seventh module;

[0086] Module 7:

[0087] Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end;

[0088] Module 8:

[0089] Determine whether A+B+C>M. If yes, perform the operation in the ninth module. Otherwise, perform segmentation operation on the color components corresponding to A, B and C to form the first new texture object; perform segmentation operation on the color component corresponding to D to form the second new texture object; end;

[0090] Module 9:

[0091] Determine whether the number of color components is 3, if yes, perform segmentation operations on the color components corresponding to A and B, and the color component corresponding to C, respectively, to form the first and second new texture objects accordingly; end; otherwise, perform the operations in the tenth module;

[0092] Module 10:

[0093] Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object;

[0094] When X is A, B, C or D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component value corresponding to X in each pixel is read out in turn, and each component value forms a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0095] When X is A and B, B and C, C and D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in sequence, and the two component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0096] When X is A, B, C, B, C, and D, the operation of performing the segmentation operation on the color component corresponding to X is: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in sequence, and the three component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0097] The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0".

[0098] Preferably, in the segmentation operation, when the two or three component values ​​corresponding to each pixel point form a new pixel point, the component storage order is: sort the two or three component values ​​from small to large according to their corresponding component bit widths, and the sorting order is the component storage order.

[0099] The present invention provides a texture sampling system based on the above-mentioned texture object segmentation system, comprising the following modules:

[0100] Preprocessing module:

[0101] Find the texture object corresponding to the original sampling instruction, if the original sampling instruction is an instruction for sampling the texture object for the first time, then execute the operation in the texture object segmentation module; otherwise, execute the operation in the sampling instruction calling module;

[0102] The original sampling instruction is the sampling instruction currently being compiled;

[0103] Texture object segmentation module:

[0104] According to the texture object segmentation system described above, the texture object is segmented into a plurality of new texture objects to form a texture object set;

[0105] Sampling instruction rewriting module:

[0106] Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as the corresponding original sampling instruction; call the sampling instruction set;

[0107] Sampling instruction calling module:

[0108] Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction to obtain new sampling instructions to form a new sampling instruction set; call the new sampling instruction set;

[0109] Sampling result reorganization module:

[0110] Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

[0111] Preferably, in the sampling result reorganization module, the operation of returning a sampled color value is:

[0112] (1) According to a preset rule, select 4 or 8 or other number of pixel points adjacent to the sampling coordinates in each new texture object;

[0113] (2) for each selected pixel point, taking out the data in the corresponding storage space; using shift and logic operation instructions to extract the component values ​​of each color component from the data in the storage space, and generating a new color value according to the pixel format corresponding to each new texture object;

[0114] (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value;

[0115] (4) Return the sampled color value corresponding to each new texture object;

[0116] In the sampling result reorganization module, the operation of reorganizing into a final sampling color value is:

[0117] (1) for each sampled color value, extracting the name and component value of each color component according to the pixel format of the corresponding new texture object;

[0118] (2) Combine all the extracted color components into a final sampled color value.

[0119] The present invention provides a texture sampling device based on texture object segmentation, characterized in that it includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement the texture sampling method as described above when executing the computer program.

[0120] The present invention provides a computer-readable storage medium, characterized in that a computer program is stored on the storage medium, and when the computer program is executed by a processor, the texture sampling method as described above is implemented.

[0121] Through the above technical solution conceived by the present invention, compared with the prior art, since the present invention divides the texture object whose pixel bit width is greater than the sampling bit width, the number of color components is more than 2 and the bit width of all components is less than the sampling bit width into multiple new texture objects, the pixel format of the new texture object is the pixel format supported by the texture unit, so that the texture unit can perform texture sampling on the divided new texture objects;

[0122] The present invention performs texture sampling on each new texture object respectively, and reorganizes the sampling results to generate a final sampling color value; the present invention only performs a texture object segmentation operation and generates a sampling instruction set when the texture object is sampled for the first time, and repeated texture sampling of the texture object only requires calling the sampling instruction set; thus, the texture sampling operation on the same texture object is simple and fast;

[0123] In the present invention, the bit width of the storage space for the color value of each pixel of the new texture object is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0"; when texture sampling is performed on a single new texture object, for each selected pixel, the data in the corresponding storage space is taken out; thereby avoiding the operation of "setting different sampling methods for different pixel bit widths" in the prior art, so that pixels of different pixel bit widths all use the same sampling method. BRIEF DESCRIPTION OF THE DRAWINGS

[0124] Figure 1 is a flow chart of a texture object segmentation method provided by an embodiment of the present invention;

[0125] Figure 2 is a flowchart of a texture sampling method provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0126] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with 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.

[0127] like Figure 1 As shown, this embodiment provides a texture object segmentation method for performing a segmentation operation on a single texture object;

[0128] According to the number of color components of a single texture object, the same number of letters are taken from letters A, B, C, and D to represent the values ​​of the component bit width from small to large;

[0129] If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order;

[0130] M is the sampling bit width;

[0131] The following steps are involved:

[0132] Step (1):

[0133] For a single texture object, determine whether A+B>M. If yes, execute step (2); otherwise, execute step (8).

[0134] Step (2):

[0135] Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if so, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, execute step (3);

[0136] Step (3):

[0137] Determine whether B+C>M. If yes, execute step (4); otherwise, execute step (6).

[0138] Step (4):

[0139] Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if so, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, execute step (5);

[0140] Step (5):

[0141] Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end;

[0142] Step (6):

[0143] Determine whether the number of color components is 3. If so, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, execute step (7);

[0144] Step (7):

[0145] Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end;

[0146] Step (8):

[0147] Determine whether A+B+C>M. If yes, execute step (9). Otherwise, perform a segmentation operation on the color components corresponding to A, B, and C to form a first new texture object; perform a segmentation operation on the color component corresponding to D to form a second new texture object; end;

[0148] Step (9):

[0149] Determine whether the number of color components is 3. If yes, perform segmentation operations on the color components corresponding to A and B and the color component corresponding to C respectively, and form the first and second new texture objects accordingly; end; otherwise, execute step (10);

[0150] Step (10):

[0151] Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object;

[0152] When X is A, B, C or D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and each component value forms a new pixel; all new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0153] When X is A and B, B and C, C and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the two component values ​​corresponding to each pixel form a new pixel; all new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0154] When X is A, B, C, B, C, and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the three component values ​​corresponding to each pixel form a new pixel; all new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0155] The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage location in the storage space that is less than the sampling bit width stores "0". The texture parameter set of the new texture object includes the pixel format, length, width and starting storage address of the new texture object; the pixel format includes the number, name, component storage order and component bit width of each color component of the new pixel; the component storage order is: sort the multiple component values ​​corresponding to each pixel from small to large according to their corresponding component bit widths, and the sorting order is the component storage order;

[0156] Among them, the sampling bit width is 16 bits; the pixel format corresponding to the texture object is RGB16, the number of color components is 3, the component bit width is 16 bits, and the component storage order is: red, green, blue;

[0157] The value of M is 16; A represents the bit width of the red component, which is 16; B represents the bit width of the green component, which is 16; C represents the bit width of the blue component, which is 16:

[0158] Step (1):

[0159] For a single texture object, determine if A+B>M and execute step (2).

[0160] Step (2):

[0161] Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine that the number of color components is not 2, and execute step (3);

[0162] Step (3):

[0163] If B+C>M, execute step (4).

[0164] Step (4):

[0165] Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine that the number of color components is 3, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end.

[0166] Since the present invention divides a texture object whose pixel bit width is greater than the sampling bit width, the number of color components is more than 2 and the bit widths of all components are less than the sampling bit width into multiple new texture objects, the pixel format of the new texture object is a pixel format supported by the texture unit, thereby enabling the texture unit to perform texture sampling on the divided new texture objects.

[0167] like Figure 2 As shown, this embodiment provides a texture sampling method based on the above texture object segmentation method, comprising the following steps:

[0168] (1) Preprocessing steps:

[0169] Find the texture object corresponding to the original sampling instruction. If the original sampling instruction is an instruction for sampling the texture object for the first time, execute step (2); otherwise, execute step (4).

[0170] The original sampling instruction is the sampling instruction currently being compiled;

[0171] (2) Texture object segmentation steps:

[0172] According to the texture object segmentation method, the texture object is segmented into a plurality of new texture objects to form a texture object set; wherein the number of the new texture objects is 3; the color components in the pixel formats corresponding to the three new texture objects each contain only one, namely red, green and blue;

[0173] (3) Sampling instruction rewriting steps:

[0174] Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as the corresponding original sampling instruction; call the sampling instruction set;

[0175] In this embodiment, the sampling instruction set is encapsulated into a function, and the function receives an input parameter. Each sampling instruction in the function uses the input parameter as a sampling coordinate; the sampling coordinate of the original sampling instruction is used as an input parameter to call the sampling instruction set function;

[0176] (4) Sampling instruction calling steps:

[0177] Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction, obtain new sampling instructions, and form a new sampling instruction set; call the new sampling instruction set;

[0178] In this embodiment, the sampling coordinates of the original sampling instruction are used as input parameters to call the sampling instruction set function corresponding to the texture object;

[0179] (5) Sampling result reorganization steps:

[0180] Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

[0181] The process of returning a sampled color value is:

[0182] (1) According to a preset rule, select 4 or 8 or other number of pixel points adjacent to the sampling coordinates in each new texture object; wherein the preset rule is a common rule in the art; the number of pixel points is 4;

[0183] (2) For each selected pixel point, the data in the corresponding storage space is retrieved; the component values ​​of each color component are extracted from the data in the storage space using shift and logic operation instructions, and a new color value is generated according to the pixel format corresponding to each new texture object; wherein the shift and logic operation instructions are commonly used operations in this field;

[0184] (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value;

[0185] (4) Returns the sampled color value corresponding to each new texture object; the three sampled color values ​​contain only one color component each, namely red, green, and blue;

[0186] The process of recombining into a final sampled color value is:

[0187] (1) For each sampled color value, extract the name and component value of each color component according to the pixel format of the corresponding new texture object;

[0188] (2) All the extracted color components are combined into a final sampled color value; the final sampled color value contains three color components: red, green, and blue;

[0189] This embodiment performs texture sampling on each new texture object respectively, and reorganizes the sampling results to generate a final sampled color value; the present invention only performs a texture object segmentation operation and generates a sampling instruction set when the texture object is sampled for the first time, and repeated texture sampling of the texture object only requires calling the sampling instruction set; thus, the texture sampling operation on the same texture object is simple and fast;

[0190] In this embodiment, the bit width of the storage space for the color value of each pixel of the new texture object is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0"; when texture sampling is performed on a single new texture object, for each selected pixel, the data in the corresponding storage space is taken out; thereby avoiding the operation of "setting different sampling methods for different pixel bit widths" in the prior art, so that pixels of different pixel bit widths all use the same sampling method.

[0191] This embodiment provides a texture object segmentation system for performing a segmentation operation on a single texture object;

[0192] According to the number of color components of a single texture object, the same number of letters are taken from letters A, B, C, and D to represent the values ​​of the component bit width from small to large;

[0193] If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order;

[0194] M is the sampling bit width;

[0195] Includes the following modules:

[0196] Module 1:

[0197] For a single texture object, determine whether A+B>M, if yes, execute the operation in the second module, otherwise execute the operation in the eighth module;

[0198] Module 2:

[0199] Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if yes, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, perform the operation in the third module;

[0200] Module 3:

[0201] Determine whether B+C>M, if yes, execute the operation in the fourth module, otherwise execute the operation in the sixth module;

[0202] Module 4:

[0203] Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if yes, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, perform the operation in the fifth module;

[0204] Module 5:

[0205] Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end;

[0206] Module 6:

[0207] Determine whether the number of color components is 3, if yes, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, perform the operation in the seventh module;

[0208] Module 7:

[0209] Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end;

[0210] Module 8:

[0211] Determine whether A+B+C>M. If yes, perform the operation in the ninth module. Otherwise, perform segmentation operation on the color components corresponding to A, B and C to form the first new texture object; perform segmentation operation on the color component corresponding to D to form the second new texture object; end;

[0212] Module 9:

[0213] Determine whether the number of color components is 3, if yes, perform segmentation operations on the color components corresponding to A and B, and the color component corresponding to C, respectively, to form the first and second new texture objects accordingly; end; otherwise, perform the operations in the tenth module;

[0214] Module 10:

[0215] Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object;

[0216] When X is A, B, C or D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component value corresponding to X in each pixel is read out in turn, and each component value forms a new pixel; all new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0217] When X is A and B, B and C, C and D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the two component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0218] When X is A, B, C, B, C, and D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the three component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one;

[0219] The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0"; the component storage order is: sort the multiple component values ​​corresponding to each pixel from small to large according to their corresponding component bit widths, and the sorting order is the component storage order;

[0220] This embodiment provides a texture sampling system based on the above texture object segmentation system, including the following modules:

[0221] Preprocessing module:

[0222] Find the texture object corresponding to the original sampling instruction. If the original sampling instruction is an instruction for sampling the texture object for the first time, then execute the operation in the texture object segmentation module; otherwise, execute the operation in the sampling instruction calling module;

[0223] The original sampling instruction is the sampling instruction currently being compiled;

[0224] Texture object segmentation module:

[0225] According to the texture object segmentation system described above, the texture object is segmented into a plurality of new texture objects to form a texture object set;

[0226] Sampling instruction rewriting module:

[0227] Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as the corresponding original sampling instruction; call the sampling instruction set;

[0228] Sampling instruction calling module:

[0229] Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction, obtain new sampling instructions, and form a new sampling instruction set; call the new sampling instruction set;

[0230] Sampling result reorganization module:

[0231] Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

[0232] Among them, the operation of returning a sampled color value is:

[0233] (1) According to a preset rule, select 4 or 8 or other number of pixels adjacent to the sampling coordinates in each new texture object;

[0234] (2) For each selected pixel, take out the data in the corresponding storage space; use shift and logical operation instructions to extract the component values ​​of each color component from the data in the storage space, and generate a new color value according to the pixel format corresponding to each new texture object;

[0235] (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value;

[0236] (4) Returns the sampled color value corresponding to each new texture object;

[0237] In the sampling result reorganization module, the operation of reorganizing into a final sampled color value is:

[0238] (1) For each sampled color value, extract the name and component value of each color component according to the pixel format of the corresponding new texture object;

[0239] (2) Combine all the extracted color components into a final sampled color value.

[0240] It will be easily understood by those skilled in the art that 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 protection scope of the present invention.

Claims

1. A texture object segmentation method, used to perform segmentation operation on a single texture object; According to the number of color components of the single texture object, the same number of letters are selected from letters A, B, C and D in sequence to represent the values ​​of the component bit widths from small to large; If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order; M is the sampling bit width; It is characterized in that The following steps are involved: Step (1): For a single texture object, determine whether A+B>M. If yes, execute step (2); otherwise, execute step (8). Step (2): Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if so, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, execute step (3); Step (3): Determine whether B+C>M. If yes, execute step (4); otherwise, execute step (6). Step (4): Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if so, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, execute step (5); Step (5): Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end; Step (6): Determine whether the number of color components is 3. If so, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, execute step (7); Step (7): Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end; Step (8): Determine whether A+B+C>M. If so, execute step (9). Otherwise, perform a segmentation operation on the color components corresponding to A, B, and C to form a first new texture object; perform a segmentation operation on the color component corresponding to D to form a second new texture object; end; Step (9): Determine whether the number of color components is 3. If yes, perform segmentation operations on the color components corresponding to A and B and the color component corresponding to C respectively, and form the first and second new texture objects accordingly; end; otherwise, execute step (10); Step (10): Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object; When X is A, B, C or D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component value corresponding to X in each pixel is read out in turn, and each component value forms a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; When X is A and B, B and C, C and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the two component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; When X is A, B, C, B, C, and D, the process of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the three component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0".

2. The texture object segmentation method according to claim 1, characterized in that: In the segmentation operation, when the two or three component values ​​corresponding to each pixel point form a new pixel point, the component storage order is: sort the two or three component values ​​from small to large according to their corresponding component bit widths, and the sorting order is the component storage order.

3. A texture sampling method based on the texture object segmentation method according to claim 1, characterized in that: The following steps are involved: (1) Preprocessing steps: Find the texture object corresponding to the original sampling instruction. If the original sampling instruction is an instruction for performing texture sampling on the texture object for the first time, execute step (2); otherwise, execute step (4). The original sampling instruction is the sampling instruction currently being compiled; (2) Texture object segmentation steps: According to the texture object segmentation method of claim 1, the texture object is segmented into a plurality of new texture objects to form a texture object set; (3) Sampling instruction rewriting steps: Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as its corresponding original sampling instruction; Call the sampling instruction set; (4) Sampling instruction calling steps: Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction to obtain new sampling instructions to form a new sampling instruction set; call the new sampling instruction set; (5) Sampling result reorganization steps: Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

4. The texture sampling method according to claim 3, characterized in that: In the sampling result reorganization step, the process of returning a sampled color value is as follows: (1) According to a preset rule, select 4 or 8 or other number of pixel points adjacent to the sampling coordinates in each new texture object; (2) for each selected pixel point, taking out the data in the corresponding storage space; using shift and logic operation instructions to extract the component values ​​of each color component from the data in the storage space, and generating a new color value according to the pixel format corresponding to each new texture object; (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value; (4) Return the sampled color value corresponding to each new texture object; In the sampling result reorganization step, the process of reorganizing into a final sampling color value is as follows: (1) for each of the sampled color values, extracting the name and component value of each color component according to the pixel format of the corresponding new texture object; (2) Combine all the extracted color components into a final sampled color value.

5. A texture object segmentation system, used to perform segmentation operations on a single texture object; According to the number of color components of the single texture object, the same number of letters are selected from letters A, B, C and D in sequence to represent the values ​​of the component bit widths from small to large; If the values ​​of the component bit widths are equal, the component bit width corresponding to the component value in the front order is determined as the smaller value, and the component bit width corresponding to the component value in the back order is determined as the larger value according to the component storage order; M is the sampling bit width; It is characterized in that Includes the following modules: Module 1: For a single texture object, determine whether A+B>M, if yes, execute the operation in the second module, otherwise execute the operation in the eighth module; Module 2: Perform a segmentation operation on the color component corresponding to A to form the first new texture object; determine whether the number of color components is 2, if yes, perform a segmentation operation on the color component corresponding to B to form the second new texture object; end; otherwise, perform the operation in the third module; Module 3: Determine whether B+C>M, if yes, execute the operation in the fourth module, otherwise execute the operation in the sixth module; Module 4: Perform a segmentation operation on the color component corresponding to B to form a second new texture object; determine whether the number of color components is 3, if yes, perform a segmentation operation on the color component corresponding to C to form a third new texture object; end; otherwise, perform the operation in the fifth module; Module 5: Determine whether C+D>M. If yes, perform segmentation operation on the color components corresponding to C and D respectively, and form the third and fourth new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to C and D; form the third new texture object; end; Module 6: Determine whether the number of color components is 3, if yes, perform a segmentation operation on the color components corresponding to B and C to form a second new texture object; end; otherwise, perform the operation in the seventh module; Module 7: Determine whether B+C+D>M. If yes, perform segmentation operation on the color components corresponding to B and C and the color components corresponding to D respectively, and form the second and third new texture objects respectively; end; otherwise, perform segmentation operation on the color components corresponding to B, C and D, and form the second new texture object; end; Module 8: Determine whether A+B+C>M. If yes, perform the operation in the ninth module. Otherwise, perform segmentation operation on the color components corresponding to A, B and C to form the first new texture object; perform segmentation operation on the color component corresponding to D to form the second new texture object; end; Module 9: Determine whether the number of color components is 3, if yes, perform segmentation operations on the color components corresponding to A and B, and the color component corresponding to C, respectively, to form the first and second new texture objects accordingly; end; otherwise, perform the operations in the tenth module; Module 10: Perform a segmentation operation on the color components corresponding to A and B to form the first new texture object; determine whether C+D>M, if so, perform a segmentation operation on the color components corresponding to C and D respectively to form the second and third new texture objects; otherwise, perform a segmentation operation on the color components corresponding to C and D to form the third new texture object; When X is A, B, C or D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component value corresponding to X in each pixel is read out in turn, and each component value forms a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; When X is A and B, B and C, C and D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the two component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; When X is A, B, C, B, C, and D, the operation of performing the segmentation operation on the color component corresponding to X is as follows: according to the storage order of the pixels, the component values ​​corresponding to X in each pixel are read out in turn, and the three component values ​​corresponding to each pixel form a new pixel; all the new pixels form a new texture object; the coordinates of the new pixel in the new texture object correspond to the coordinates of the corresponding pixel in the texture object one by one; The bit width of the storage space for the color value of the new pixel is consistent with the sampling bit width, and each storage position in the storage space that is less than the sampling bit width stores "0".

6. The texture object segmentation system according to claim 5, characterized in that: In the segmentation operation, when the two or three component values ​​corresponding to each pixel point form a new pixel point, the component storage order is: sort the two or three component values ​​from small to large according to their corresponding component bit widths, and the sorting order is the component storage order.

7. A texture sampling system based on the texture object segmentation system according to claim 5, characterized in that: Includes the following modules: Preprocessing module: Find the texture object corresponding to the original sampling instruction, if the original sampling instruction is an instruction for performing texture sampling on the texture object for the first time, then execute the operation in the texture object segmentation module; otherwise, execute the operation in the sampling instruction calling module; The original sampling instruction is the sampling instruction currently being compiled; Texture object segmentation module: The texture object segmentation system according to claim 5, segmenting the texture object into a plurality of new texture objects to form a texture object set; Sampling instruction rewriting module: Generate a sampling instruction for each new texture object to form a sampling instruction set; the sampling coordinates in each sampling instruction are the same as its corresponding original sampling instruction; Call the sampling instruction set; Sampling instruction calling module: Modify the sampling coordinates in each sampling instruction in the sampling instruction set corresponding to the texture object to the sampling coordinates in the original sampling instruction to obtain new sampling instructions to form a new sampling instruction set; call the new sampling instruction set; Sampling result reorganization module: Each sampling instruction in the sampling instruction set or the new sampling instruction set or each new sampling instruction returns a sampling color value, and all the sampling color values ​​are reassembled into a final sampling color value according to the pixel format of each new texture object.

8. The texture sampling system of claim 7, wherein: In the sampling result reorganization module, the operation of returning a sampled color value is: (1) According to a preset rule, select 4 or 8 or other number of pixel points adjacent to the sampling coordinates in each new texture object; (2) for each selected pixel point, taking out the data in the corresponding storage space; using shift and logic operation instructions to extract the component values ​​of each color component from the data in the storage space, and generating a new color value according to the pixel format corresponding to each new texture object; (3) Take the average value of each color component in all new color values, and each average value is the value of each component of the sampled color value; (4) Return the sampled color value corresponding to each new texture object; In the sampling result reorganization module, the operation of reorganizing into a final sampling color value is: (1) for each of the sampled color values, extracting the name and component value of each color component according to the pixel format of the corresponding new texture object; (2) Combine all the extracted color components into a final sampled color value.

9. A texture sampling device based on texture object segmentation, characterized in that: It comprises a memory and a processor; the memory is used to store a computer program; the processor is used to implement the texture sampling method as described in any one of claims 3-4 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the texture sampling method according to any one of claims 3 to 4 is implemented.

Citation Information

Patent Citations

  • Method and device for image analysis

    CN101655978A

  • Techniques for reducing accesses for retrieving texture images

    CN104424652A