Image data storage, writing, reading method, device, equipment, storage medium
By using an image data storage method based on color consistency identifiers in multisampling anti-aliasing (MSAA), the storage space and bandwidth consumption problems caused by MSAA are solved, and efficient image data reading and writing are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-21
- Publication Date
- 2026-03-27
AI Technical Summary
Multisampling anti-aliasing (MSAA) improves image resolution but also leads to a significant increase in storage space and read/write bandwidth consumption, thus increasing the load on computer equipment.
By determining the consistency identifier based on the color consistency of multiple sampling points, the colors of the same sampling point identifier corresponding to different pixels are stored in the same color storage area, and the correspondence between pixel coordinates, consistency identifiers and color blocks is established, thereby optimizing the storage and retrieval method of image data.
It effectively reduces the consumption of read and write bandwidth, improves read and write efficiency and resource utilization, and reduces the load on computer equipment.
Smart Images

Figure CN121000983B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to, but is not limited to, the technical field of computer, and particularly relates to an image data storage, writing-out and reading method, device, equipment and storage medium. BACKGROUND
[0002] Multi-Sample Anti-Aliasing (MSAA) is a technique for reducing image aliasing effect. In MSAA, the color of a pixel is determined by the color, depth and other image data collected by multiple samples in the area where the pixel is located.
[0003] Although MSAA improves image resolution and makes the image smoother, because of the data collection of multiple samples, the obtained image data needs to be stored in a storage space that is multiplied, and the read-write bandwidth is also multipliedly consumed. SUMMARY
[0004] Therefore, the present disclosure provides at least an image data storage, writing-out and reading method, device, equipment and storage medium.
[0005] The technical solution of the present disclosure is implemented as follows:
[0006] In one aspect, the present disclosure provides an image data storage method, which comprises:
[0007] obtaining the color of multiple samples corresponding to a first pixel to be processed;
[0008] determining a consistency identifier of the first pixel based on the color consistency of the multiple samples corresponding to the first pixel;
[0009] storing the color of the sample with the same sample identifier corresponding to different first pixels in the same color storage area based on the multiple sample identifiers corresponding to each first pixel, to obtain a first color block; the different first pixels correspond to the same sample identifier generation mode;
[0010] establishing a corresponding relationship between the coordinates of the first pixel, the consistency identifier of the first pixel and the first color block, to obtain a first corresponding relationship.
[0011] In one aspect, the present disclosure provides an image data writing-out method, which comprises:
[0012] determine the consistency identifier of the second pixel based on the coordinate of the second pixel and the second correspondence relationship; the second correspondence relationship represents a correspondence relationship among the coordinate of the second pixel, the consistency identifier of the second pixel and a second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on color consistency of a plurality of sampling points corresponding to the second pixel, and the second color block includes colors of sampling points corresponding to a plurality of different pixels, and colors of sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area;
[0013] determine the second color block and a second color storage position of the second pixel in the second color block based on the coordinate of the second pixel and the second correspondence relationship;
[0014] in a case where the consistency identifier of the second pixel represents that colors of the plurality of sampling points corresponding to the second pixel are completely same, write the consistency identifier of the second pixel and a color in any color storage area in the second color block at the second color storage position.
[0015] In one aspect, the embodiment of the present disclosure provides an image data reading method, which comprises:
[0016] determine the consistency identifier of the third pixel based on the coordinate of the third pixel and the third correspondence relationship; the third correspondence relationship represents a correspondence relationship among the coordinate of the third pixel, the consistency identifier of the third pixel and a third color block corresponding to the third pixel; the consistency identifier of the third pixel is determined based on color consistency of a plurality of sampling points corresponding to the third pixel, and the third color block includes colors of sampling points corresponding to a plurality of different pixels, and colors of sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area;
[0017] determine the third color block and a third color storage position of the third pixel in the third color block based on the coordinate of the third pixel and the third correspondence relationship;
[0018] in a case where the consistency identifier of the third pixel represents that colors of the plurality of sampling points corresponding to the third pixel are completely same, read a color in any color storage area in the third color block at the third color storage position and the coordinate of the plurality of sampling points.
[0019] In another aspect, the embodiment of the present disclosure provides an image data storage device, which comprises:
[0020] an obtaining module configured to obtain colors of a plurality of sampling points corresponding to a first pixel to be processed;
[0021] a first processing module configured to determine a consistency identifier of the first pixel based on color consistency of the plurality of sampling points corresponding to the first pixel;
[0022] a storage module, configured to store, based on the plurality of sample point identifiers corresponding to each first pixel, colors of sample points corresponding to a same sample point identifier of different first pixels in a same color storage region to obtain a first color block, the different first pixels corresponding to the same sample point identifier being generated in a same manner;
[0023] the first processing module is further configured to establish a correspondence between the coordinates of the first pixels, the consistency identifiers of the first pixels, and the first color block to obtain a first correspondence.
[0024] In another aspect, an embodiment of the present disclosure provides an image data writing device, which includes:
[0025] a second processing module, configured to determine, based on the coordinates of a second pixel to be written out and a second correspondence, a consistency identifier of the second pixel, the second correspondence representing a correspondence between the coordinates of the second pixel, the consistency identifier of the second pixel, and a second color block corresponding to the second pixel, the consistency identifier of the second pixel being determined based on color consistency of a plurality of sample points corresponding to the second pixel, the second color block including colors of sample points corresponding to different pixels, and colors of sample points corresponding to a same sample point identifier of different pixels being stored in a same color storage region;
[0026] the second processing module is further configured to determine, based on the coordinates of the second pixel and the second correspondence, the second color block and a second color storage position of the second pixel in the second color block;
[0027] a writing module, configured to write out, in a case where the consistency identifier of the second pixel represents that colors of the plurality of sample points corresponding to the second pixel are completely same, the consistency identifier of the second pixel and a color in a color storage region at the second color storage position in the second color block.
[0028] In another aspect, an embodiment of the present disclosure provides an image data reading device, which includes:
[0029] a third processing module, configured to determine, based on the coordinates of a third pixel to be read out and a third correspondence, a consistency identifier of the third pixel, the third correspondence representing a correspondence between the coordinates of the third pixel, the consistency identifier of the third pixel, and a third color block corresponding to the third pixel, the consistency identifier of the third pixel being determined based on color consistency of a plurality of sample points corresponding to the third pixel, the third color block including colors of sample points corresponding to different pixels, and colors of sample points corresponding to a same sample point identifier of different pixels being stored in a same color storage region;
[0030] The third processing module is further configured to determine the third color block and a third color storage position of the third pixel in the third color block based on the coordinate of the third pixel and the third correspondence relationship;
[0031] The reading module is configured to read the color at the third color storage position and the coordinates of the plurality of sampling points in any color storage area in the third color block in a case where the consistency identifier of the third pixel represents that the colors of the plurality of sampling points corresponding to the third pixel are completely same.
[0032] In yet another aspect, an embodiment of the present disclosure provides a computer device, including a memory and a processor, the memory stores a computer program capable of running on the processor, and the processor implements part or all steps of the above method when executing the program.
[0033] In yet another aspect, an embodiment of the present disclosure provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement part or all steps of the above method.
[0034] In yet another aspect, an embodiment of the present disclosure provides a computer program, which includes computer readable code, and when the computer readable code runs in a computer device, a processor in the computer device executes part or all steps for implementing the above method.
[0035] In yet another aspect, an embodiment of the present disclosure provides a computer program product, which includes a non-transitory computer readable storage medium storing a computer program, and when the computer program is read and executed by a computer, part or all steps of the above method are implemented.
[0036] In the embodiments of the present disclosure, the consistency identifier of the first pixel is determined based on the color consistency of the plurality of sampling points corresponding to the first pixel. In this way, the consistency identifier can be used to quickly determine whether the colors of the plurality of sampling points corresponding to the first pixel are completely the same. Based on the plurality of sampling point identifiers corresponding to each first pixel, the colors of the sampling points corresponding to the same sampling point identifier of different first pixels are stored in the same color storage area to obtain a first color block. In this way, the sampling points of the plurality of pixels are grouped and stored according to the sampling point identifiers, the colors of the sampling points corresponding to the plurality of pixels can be stored in one color block, and when it is known through the consistency identifier that the colors of the sampling points corresponding to any first pixel are completely the same, the colors of all the sampling points corresponding to the first pixel can be obtained by only reading and writing the color of the sampling point corresponding to this pixel stored in the first color storage area in the first color block. In this way, when it is known through the consistency identifier that the colors of all the sampling points corresponding to all the first pixels stored in the first color block are only one kind (the colors of the sampling points corresponding to different pixels can be the same or different), the colors of all the sampling points corresponding to all the first pixels can be obtained by only reading and writing the colors of all the sampling points stored in the first color storage area in the first color block. Therefore, by using a very small reading and writing bandwidth, the colors of all the sampling points corresponding to the pixels are read and written to the maximum extent, and the reading and writing efficiency and resource utilization are improved.
[0037] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the technical solutions of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS
[0038] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the technical solutions of the present disclosure.
[0039] Figure 1 A schematic diagram of image texture not using MSAA is provided for the embodiments of the present disclosure;
[0040] Figure 2 A schematic diagram of image texture using MSAA is provided for the embodiments of the present disclosure;
[0041] Figure 3 An implementation flowchart of an image data storage method is provided for the embodiments of the present disclosure Figure 1 ;
[0042] Figure 4 An implementation flowchart of an image data storage method is provided for the embodiments of the present disclosure Figure 2 ;
[0043] Figure 5A schematic diagram of color blocks in an image data storage method provided by an embodiment of the present disclosure
[0044] Figure 6 A schematic diagram of identification blocks in an image data storage method provided by an embodiment of the present disclosure
[0045] Figure 7 An implementation flowchart of an image data writing method provided by an embodiment of the present disclosure Figure 1
[0046] Figure 8 An implementation flowchart of an image data writing method provided by an embodiment of the present disclosure Figure 2
[0047] Figure 9 An implementation flowchart of an image data reading method provided by an embodiment of the present disclosure
[0048] Figure 10 An implementation schematic diagram of an image data writing method provided by an embodiment of the present disclosure when applied to MSAA
[0049] Figure 11 An implementation schematic diagram of an image data reading method provided by an embodiment of the present disclosure when applied to MSAA
[0050] Figure 12 A component structure schematic diagram of an image data storage device provided by an embodiment of the present disclosure
[0051] Figure 13 A component structure schematic diagram of an image data writing device provided by an embodiment of the present disclosure
[0052] Figure 14 A component structure schematic diagram of an image data reading device provided by an embodiment of the present disclosure
[0053] Figure 15 A hardware entity schematic diagram of a computer device provided by an embodiment of the present disclosure DETAILED DESCRIPTION
[0054] In order to make the objectives, technical solutions and advantages of the present disclosure clearer, the technical solutions of the present disclosure are further described in detail below in combination with the drawings and embodiments. The described embodiments should not be regarded as limiting the present disclosure, and all other embodiments obtained by those of ordinary skill in the art without making creative efforts fall within the scope of protection of the present disclosure.
[0055] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments, but it is understood that "some embodiments" can be the same subset or different subsets as each other and can be combined with each other, without conflict.
[0056] The terms "first / second / third" are only to distinguish similar objects, and do not represent a specific order of the objects. It is understood that the "first / second / third" can be interchanged in a specific order or sequence as allowed, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0057] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this disclosure belongs. The terminology used in the specification herein is for describing the present disclosure only and is not intended to be limiting of the present disclosure.
[0058] In order to better understand the method provided by the embodiments of the present disclosure, the innovative ideas of the embodiments of the present disclosure are described first as follows.
[0059] As shown in Figure 1 , a schematic diagram of image texture without MSAA provided by the embodiments of the present disclosure is shown in Figure 1 , in which a "cross" represents a pixel. Figure 1 A schematic diagram of image texture with MSAA provided by the embodiments of the present disclosure is shown in Figure 2 , in which a "dot" represents a sampling point, a "dot" filled with different patterns represents a sampling point of different image data, and a "rectangle" filled with different patterns represents a pixel of different colors. As can be seen from Figure 2 , when MSAA is not used, the colors of the pixels occupied by the triangle are the same. As can be seen from Figure 1 , when MSAA is used, the pixels occupied by the edges of the triangle will present different colors due to the different image data collected by the sampling points. Obviously, Figure 2 , the triangle in Figure 2 will consume 4 times the bandwidth of the triangle in Figure 1 when reading and writing, which increases the load of the computer device.
[0060] As shown in Figure 2 , if a plurality of samples are all inside the triangle, the colors of all the samples are consistent. Moreover, the number of samples on the edge is smaller than that of samples inside the triangle. Therefore, most of the samples (i.e., pixels) should be inside the triangle, so the embodiments of the present disclosure utilize this feature to compress the bandwidth of the entire pipeline.
[0061] The embodiment of the present disclosure provides an image data storage method, which can be executed by a processor of a computer device. The computer device can be a server, a notebook computer, a tablet computer, a desktop computer, a smart television, a set-top box, a mobile device (such as a mobile phone, a portable video player, a personal digital assistant, a dedicated messaging device, a portable game device) and the like with data processing capability. As shown in the following figure, the method comprises the following steps 301 to 304: Figure 3
[0062] Step 301: Obtain the color of a plurality of sampling points corresponding to a first pixel to be processed.
[0063] The first pixel can be one or more pixels to be processed. For example, the first pixel can be a pixel in an image to be rendered. A plurality of sampling points correspond to one pixel. It should be noted that the number of sampling points corresponding to one pixel can be determined according to the performance of the computer device and the effect of the image to be rendered.
[0064] In some embodiments, the specific implementation of step 301 can be: directly obtaining the color value calculated in the MSAA rendering process of each sampling point.
[0065] Step 302: Determine the consistency identifier of the first pixel based on the color consistency of the plurality of sampling points corresponding to the first pixel.
[0066] The color consistency of the plurality of sampling points represents whether the colors of the plurality of sampling points corresponding to the first pixel are completely the same.
[0067] In some embodiments, the specific implementation of step 302 can be: setting the consistency identifier of the first pixel to a first identifier in the case that the colors of the plurality of sampling points corresponding to the first pixel are completely the same; and setting the consistency identifier of the first pixel to a second identifier in the case that the colors of the plurality of sampling points corresponding to the first pixel are not completely the same.
[0068] The first identifier represents that the colors of the plurality of sampling points corresponding to the first pixel (any pixel) are completely the same. The second identifier represents that the colors of the plurality of sampling points corresponding to the first pixel are not completely the same. For example, the first identifier can be 0, and the second identifier can be 1. The colors of the plurality of sampling points corresponding to the first pixel can be completely the same, that is, the first pixel corresponds to a sampling point of one color. The colors of the plurality of sampling points can not be completely the same, that is, the first pixel corresponds to a sampling point of two or more colors.
[0069] For example, if a pixel includes four sampling points, and the colors of the four sampling points are completely the same, the consistency identifier of the pixel is set to 0; if the colors of the four sampling points are not completely the same, the consistency identifier of the pixel is set to 1.
[0070] Step 303, store the color of the sampling point corresponding to the same sampling point identifier of different first pixels in the same color storage area, to obtain a first color block.
[0071] The same sampling point identifier of different first pixels corresponds to the same sampling point identifier generation manner.
[0072] The color storage area can be a storage area composed of multiple address-continuous cache areas, or a storage area composed of multiple non-continuous cache areas, which can be set according to the allocation manner of the cache area of the computer device.
[0073] In some embodiments, the sampling point identifier generation manner can be: for each first pixel, encoding the multiple sampling points based on the positions of the multiple sampling points in the first pixel, to obtain each sampling point identifier.
[0074] Specifically, the sampling point identifier generation manner can be: for each first pixel, encoding the multiple sampling points in the order from top to bottom and from left to right based on the positions of the multiple sampling points in the first pixel, to obtain each sampling point identifier. Alternatively, the multiple sampling points corresponding to each first pixel can also be encoded according to the generation order of the sampling points, or the multiple sampling points corresponding to each first pixel can also be encoded according to the distance between the sampling points and the center of the pixel.
[0075] For example, for a pixel A including four sampling points, the sampling points are encoded in the order from left to right and from top to bottom, to obtain sampling point 1, sampling point 2, sampling point 3 and sampling point 4.
[0076] Storing the color of the sampling point corresponding to the same sampling point identifier of different first pixels in the same color storage area can be: grouping the sampling points of multiple pixels according to the sampling point identifier, and storing the color of the sampling point of the same sampling point identifier in the color storage area of the same group. More specifically, the color of the sampling point of the same sampling point identifier is stored in the address-continuous storage area of the same group. For example, if pixel A and pixel B both include sampling point 1, sampling point 2 and sampling point 3, then the sampling point 1 of pixel A and the sampling point 1 of pixel B are stored in one area, the sampling point 2 of pixel A and the sampling point 2 of pixel B are stored in one area, and the sampling point 3 of pixel A and the sampling point 3 of pixel B are stored in one area.
[0077] Step 304, establishing a corresponding relationship between the coordinates of the first pixels, the consistency identifier of the first pixels and the first color block, to obtain a first corresponding relationship.
[0078] The first correspondence can be a correspondence between the coordinate of the first pixel, the consistency identifier of the first pixel, and the first color block.
[0079] The first correspondence is established so that when the coordinate of any first pixel is obtained, the consistency identifier of the first pixel and the color of all sampling points corresponding to the first pixel can be determined according to the first correspondence.
[0080] In some embodiments, the specific implementation of step 304 can be: obtaining the first correspondence by taking the coordinate of the first pixel as the key information item, and taking the consistency identifier of the first pixel, the first color block, and the storage location of the color of the sampling point corresponding to the first pixel in the color block as the value information item. Alternatively, the correspondence between the coordinate of the first pixel, the consistency identifier of the first pixel, and the first color block can also be established in the form of a relationship diagram.
[0081] In the embodiments of the present disclosure, the consistency identifier of the first pixel is determined based on the color consistency of the plurality of sampling points corresponding to the first pixel. In this way, the color consistency of the plurality of sampling points corresponding to the first pixel can be quickly known through the consistency identifier. The color of the sampling point corresponding to the same sampling point identifier of different first pixels is stored in the same color storage area based on the plurality of sampling point identifiers corresponding to each first pixel, and the first color block is obtained. In this way, the colors of the sampling points corresponding to a plurality of pixels are stored in groups according to the sampling point identifiers, the colors of the sampling points corresponding to the first pixel can be obtained by reading and writing only the color stored in the first color storage area of the first color block when the colors of the sampling points corresponding to the first pixel are completely the same through the consistency identifier, and the colors of all sampling points corresponding to the first pixel can be obtained. When the colors of all sampling points corresponding to the first pixel stored in the first color block are only one kind (the colors of the sampling points corresponding to different pixels can be the same or different) through the consistency identifier, only the colors of all sampling points stored in the first color storage area of the first color block need to be read and written, and the colors of all sampling points corresponding to all first pixels can be obtained. Therefore, by using a very small read-write bandwidth, the colors of all sampling points corresponding to the pixels are read and written to the maximum extent, and the read-write efficiency and resource utilization are improved.
[0082] The embodiments of the present disclosure provide an image data storage method, which can be executed by a processor of a computer device. As shown in the method includes the following steps 401 to 405: Figure 4
[0083] Step 401: Obtain the colors of a plurality of sampling points corresponding to a first pixel to be processed.
[0084] Step 402, determining the consistency identifier of the first pixel based on the color consistency of the plurality of sampling points corresponding to the first pixel.
[0085] Here, the steps 401-402 correspond to the steps 301-302 respectively, and the specific embodiments of the steps 301-302 can be referred to in implementation.
[0086] Step 403, determining the number N of pixels corresponding to a single color storage area; N is a positive integer.
[0087] The number of pixels corresponding to a single color storage area can be the maximum number of pixels that a single color storage area can store. N can be pre-set, and can be set to 2*2, or 4*4, or 8*8 according to actual business needs.
[0088] Step 404, storing the color of the sampling point with the same sampling point identifier corresponding to every N first pixels in the same color storage area according to the plurality of sampling point identifiers corresponding to each first pixel, to obtain a first color block corresponding to every N first pixels.
[0089] Here, the same sampling point identifier generation method corresponds to different first pixels.
[0090] In some embodiments, the specific implementation of step 404 can be: determining the first color storage position of every N first pixels based on the coordinates of every N first pixels; storing the color of the sampling point with the same sampling point identifier corresponding to every N first pixels in the same color storage area according to the first color storage position based on the plurality of sampling point identifiers corresponding to each first pixel, to obtain a first color block corresponding to every N first pixels.
[0091] The first color storage position can be the storage position of the color of the sampling point corresponding to every N first pixels. The coordinates of the first pixel can be the position of the first pixel in the image.
[0092] In a feasible implementation, the specific implementation of “determining the first color storage position of every N first pixels based on the coordinates of every N first pixels” can be: determining the first color storage position of every N first pixels based on the distance between the coordinates of every N first pixels and a preset origin. Alternatively, the first color storage position of every N first pixels can also be determined according to the distance between the coordinates of every N first pixels and the center of the image.
[0093] In a possible implementation, the specific implementation of "storing, according to the first color storage position, the color of each Nth first pixel corresponding to the same sampling point with the same sampling point identifier, in the same color storage area, to obtain a first color block corresponding to each Nth first pixel" can be: determining, based on the plurality of sampling point identifiers corresponding to each first pixel, the color of each Nth first pixel corresponding to the sampling point with identifier i; i is a positive integer; storing, according to the first color storage position, the color of each Nth first pixel corresponding to the sampling point with identifier i in the i th color storage area in sequence; determining, based on the plurality of sampling point identifiers corresponding to each first pixel, the color of each Nth first pixel corresponding to the sampling point with identifier i+1; storing, according to the first color storage position, the color of each Nth first pixel corresponding to the sampling point with identifier i+1 in the i+1 th color storage area in sequence; and determining, based on the i th color storage area and the i+1 th color storage area, the first color block corresponding to each Nth first pixel.
[0094] For example, if pixel A and pixel B each include sampling point 1, sampling point 2 and sampling point 3, then the color of sampling point 1 of pixel A and the color of sampling point 1 of pixel B are stored in the first color storage area, the color of sampling point 2 of pixel A and the color of sampling point 2 of pixel B are stored in the second color storage area, and the color of sampling point 3 of pixel A and the color of sampling point 3 of pixel B are stored in the third color storage area.
[0095] As shown in Figure 5 , if the sampling point identifier starts from 0 and the sequence starts from 1, then the color of the sampling point with identifier i is stored in the i+1 th color storage area, and the color of the sampling point with identifier i+1 is stored in the i+2 th color storage area.
[0096] Referring to Figure 5 , the size of a sample color block can be 256B (bit, Byte). One sample color block can correspond to 4*4 pixels, and at this time, the sample color block is divided into four color storage areas: 4*4 sampling point 0, 4*4 sampling point 1, 4*4 sampling point 2 and 4*4 sampling point 3, and the size of each color storage area is 64B. Each color storage area stores one sampling point corresponding to 16 pixels; for example, for the color storage area of 4*4 sampling point 3, Figure 5 , 0 to 15 in the color storage area represent 16 pixels each corresponding to sampling point 3, and the 16 pixels are sorted according to the pixel coordinates.
[0097] Alternatively, referring to Figure 5, one color block can also correspond to 8 2*2 pixels, at this time, one color block is divided into 8 color storage areas of 2*2 sampling point 0, 2*2 sampling point 1, 2*2 sampling point 2, 2*2 sampling point 3, 2*2 sampling point 4, 2*2 sampling point 5, 2*2 sampling point 6, 2*2 sampling point 7, and the size of each color storage area is 32B. Each color storage area stores one sampling point corresponding to 4 pixels; for example, for the color storage area of 2*2 sampling point 7, Figure 5 0-3 in the 2*2 sampling point 7 color storage area represent the sampling point 7 corresponding to the 4 pixels respectively, and the 4 pixels are sorted according to the pixel coordinates.
[0098] It should be noted that, based on the coordinates of each N first pixel, the storage position (first color storage position) of the color of the sampling point corresponding to each N first pixel is determined, the coordinates of the pixel are associated with the storage position of the color of the sampling point, which facilitates locating the storage position of the color of the sampling point according to the coordinates of the pixel, and obtaining the coordinates of the corresponding pixel according to the color storage position of the sampling point; based on the plurality of sampling point identifiers corresponding to each first pixel, the color of the sampling point of the same sampling point identifier corresponding to each N first pixel is stored in the same color storage area according to the first color storage position, to obtain the first color block corresponding to each N first pixel, which can store the colors of the sampling points corresponding to multiple pixels in one color block, facilitating reading and writing the colors of the sampling points corresponding to the pixels.
[0099] Step 405, establishing a correspondence between the coordinates of the first pixel, the consistency identifier of the first pixel and the first color block, to obtain a first correspondence.
[0100] Since the colors of the sampling points of the same sampling point identifier corresponding to different first pixels are stored in one color storage area and are stored according to the coordinates of the first pixel, establishing the correspondence between the coordinates of the first pixel, the consistency identifier of the first pixel and the first color block includes: establishing the correspondence between the coordinates of the first pixel and the color storage position of each first pixel in each color storage area (i.e., the correspondence between the pixel coordinates and the color storage position). Since each N first pixel corresponds to a first color block, establishing the correspondence between the coordinates of the first pixel, the consistency identifier of the first pixel and the first color block also includes: establishing the correspondence between the coordinates of the first pixel and the first color block (the correspondence between the pixel coordinates and the color block).
[0101] It should be noted that since the maximum number of pixels that a single color storage area can store is N, storing the colors of the sampling points with the same sampling point identifier corresponding to each first pixel in the same color storage area based on the multiple sampling point identifiers corresponding to each first pixel can maximize the use of the storage space of the color storage area and improve resource utilization.
[0102] In some embodiments, the image data storage method provided in this disclosure may further include the following steps 405 to 407:
[0103] Step 405: Determine the number M of pixels corresponding to a single identifier block; M is a positive integer.
[0104] M can be preset, and can be set to 16*16 or 8*8 according to actual business needs.
[0105] Step 406: Based on the coordinates of each M first pixels, determine the first identifier storage location for each M first pixels.
[0106] The storage location of the first identifier can be the storage order of the identifiers of every M first pixels.
[0107] In one feasible implementation, step 406 can be implemented by: determining the first identifier storage location of each M first pixels based on the distance between the coordinates of each M first pixels and a preset origin. Alternatively, the first identifier storage location of each M first pixels can be determined according to the coordinates of each M first pixels and the distance between each pixel and the image center.
[0108] Step 407: According to the first identifier storage location, store the consistency identifiers of every M first pixels in the same storage area to obtain the first identifier block.
[0109] Each M first-level pixel consistency identifier corresponds to a first identifier block.
[0110] like Figure 6 As shown, the size of a flag block can be 32 bytes. One flag block can correspond to 16*16 pixels, that is, one flag block can store 16*16 pixels of flags.
[0111] Since the consistency identifier of each M first pixels is stored in a storage area and is stored according to the coordinates of the first pixels, the correspondence between the coordinates of the first pixels, the consistency identifier of the first pixels and the first color block is established, including: establishing the correspondence between the coordinates of the first pixels and the storage location of each first pixel in the identifier block (i.e., the correspondence between the pixel coordinates and the storage location of the identifier). Since each M first pixel corresponds to a first identifier block, the correspondence between the coordinates of the first pixels, the consistency identifier of the first pixels and the first color block is also established, including: establishing the correspondence between the coordinates of the first pixels and the first identifier block (the correspondence between the pixel coordinates and the identifier block).
[0112] In the embodiment of the present disclosure, the consistency identifier of the first pixel is determined based on the color consistency of the plurality of sampling points corresponding to the first pixel; in this way, the consistency identifier can be used to quickly determine whether the colors of the plurality of sampling points corresponding to the first pixel are completely the same. Based on the plurality of sampling point identifiers corresponding to each first pixel, the colors of the sampling points corresponding to the same sampling point identifier of different first pixels are stored in the same color storage area to obtain the first color block; in this way, the sampling points of the plurality of pixels are grouped and stored according to the sampling point identifiers, the colors of the sampling points corresponding to the plurality of pixels can be stored in one color block, and when it is known through the consistency identifier that the colors of the sampling points corresponding to any first pixel are completely the same, the colors of all the sampling points corresponding to the first pixel can be obtained by only reading and writing the colors of the sampling points corresponding to this pixel stored in the first color storage area in the first color block; in this way, when it is known through the consistency identifier that the colors of all the sampling points corresponding to all the first pixels stored in the first color block are only one kind (the colors of the sampling points corresponding to different pixels can be the same or different), the colors of all the sampling points corresponding to all the first pixels can be obtained by only reading and writing the colors of all the sampling points stored in the first color storage area in the first color block. Therefore, by using a very small reading and writing bandwidth, the colors of all the sampling points corresponding to the pixels are read and written to the maximum extent, and the reading and writing efficiency and resource utilization are improved.
[0113] The embodiment of the present disclosure provides an image data storage method, which can be executed by a processor of a computer device. As shown in the method includes the following steps 701 to 703: Figure 7
[0114] Step 701, determining the consistency identifier of the second pixel based on the coordinates of the second pixel to be written out and the second correspondence.
[0115] The second correspondence relationship represents a correspondence relationship between the coordinates of the second pixel, the consistency identifier of the second pixel, and a second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on color consistency of a plurality of sampling points corresponding to the second pixel, the second color block includes colors of sampling points corresponding to a plurality of different pixels, and colors of sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area.
[0116] The second correspondence relationship can be the first correspondence relationship obtained according to the image data storage method described above. The second pixel can be one or more pixels that need to be written out to the memory; the second pixel can be one or more first pixels.
[0117] In some embodiments, a specific implementation of step 701 can be: taking the coordinates of the second pixel as a matching basis, obtaining an identifier block corresponding to the second pixel from the second correspondence relationship; and determining the consistency identifier of the second pixel from the identifier block corresponding to the second pixel.
[0118] Step 702: determining the second color block and the second color storage position of the second pixel in the second color block based on the coordinates of the second pixel and the second correspondence relationship.
[0119] The second color storage position can be a storage order of the color of the sampling point corresponding to the second pixel in the second color block, that is, a storage position of the color of the sampling point corresponding to the second pixel in the second color block.
[0120] In some embodiments, a specific implementation of step 702 can be: taking the coordinates of the second pixel as a matching basis, obtaining the second color block corresponding to the second pixel from the second correspondence relationship; and taking the coordinates of the second pixel as a matching basis, obtaining the second color storage position of the second pixel in the second color block from the second correspondence relationship.
[0121] Step 703: in a case where the consistency identifier of the second pixel represents that colors of a plurality of sampling points corresponding to the second pixel are completely same, writing out the consistency identifier of the second pixel and a color in any color storage area in the second color block at the second color storage position.
[0122] The color in any color storage area in the second color block at the second color storage position can be the color of the sampling point corresponding to the second pixel.
[0123] Since one sample point corresponding to the second pixel is stored in each color storage region of the second color block, when the colors of the multiple sample points corresponding to the second pixel are completely same, the color of the sample point corresponding to the second pixel stored in each color storage region of the second color block is same; at this time, the color of all the sample points corresponding to the second pixel can be represented according to the color of the sample point corresponding to the second pixel stored in any color storage region and the consistency identifier of the second pixel.
[0124] In some embodiments, when the consistency identifier of the second pixel represents that the colors of the multiple sample points corresponding to the second pixel are not completely same, the color in the second color storage position in all the color storage regions in the second color block is written.
[0125] The color in the second color storage position in all the color storage regions in the second color block can be written as the color of all the sample points corresponding to the second pixel.
[0126] In the embodiments of the present disclosure, when the colors of the multiple sample points corresponding to the second pixel are completely same, only the color of the sample point corresponding to the second pixel stored in any color storage region of the second color block and the consistency identifier of the second pixel are written, which maximally reduces the transmission bandwidth when writing and improves the performance and resource utilization of the computer device and reduces the power consumption of the computer device.
[0127] The embodiments of the present disclosure provide an image data writing method, which can be executed by a processor of a computer device. As shown in the method includes the following steps 801 to 806: Figure 8
[0128] Step 801, determining a first sub-correspondence relationship between pixel coordinates and identifier blocks and a second sub-correspondence relationship between pixel coordinates and identifier storage positions from the second correspondence relationship.
[0129] The second correspondence relationship can include the first sub-correspondence relationship between the pixel coordinates and the identifier blocks and the second sub-correspondence relationship between the pixel coordinates and the identifier storage positions. The first sub-correspondence relationship can refer to a correspondence relationship between the pixel coordinates and the identifier block addresses.
[0130] Step 802, determining a consistency identifier of the second pixel based on the first sub-correspondence relationship, the second sub-correspondence relationship, and the coordinates of the second pixel.
[0131] The second correspondence relationship represents a correspondence relationship between the coordinate of the second pixel, the consistency identifier of the second pixel and a second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on color consistency of a plurality of sampling points corresponding to the second pixel, the second color block includes colors of sampling points corresponding to a plurality of different pixels, and colors of sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area.
[0132] In some embodiments, when the first correspondence relationship is a direct association relationship between pixel coordinates and identifier block addresses, the specific implementation of step 802 can be: determining a second identifier block matching the coordinate of the second pixel from the first sub-correspondence relationship based on the coordinate of the second pixel as a matching basis; determining a storage position of the consistency identifier of the second pixel in the second identifier block from the second sub-correspondence relationship based on the coordinate of the second pixel as a matching basis; and obtaining the consistency identifier of the second pixel from the second identifier block based on the storage position of the consistency identifier of the second pixel in the second identifier block.
[0133] In some embodiments, the specific implementation of step 802 can be: determining a second identifier block corresponding to the second pixel based on the first sub-correspondence relationship and the coordinate of the second pixel; determining a second identifier storage position of the second pixel in the second identifier block based on the second sub-correspondence relationship and the coordinate of the second pixel; and determining the consistency identifier of the second pixel based on the second identifier block and the second identifier storage position.
[0134] The second identifier storage position can be a storage order of the consistency identifier of the second pixel in the second identifier block, that is, the storage position of the consistency identifier of the second pixel in the second identifier block.
[0135] In a feasible implementation, when the first sub-correspondence relationship is a conversion relationship between pixel coordinates and identifier block addresses, the specific implementation of "determining a second identifier block corresponding to the second pixel based on the first sub-correspondence relationship and the coordinate of the second pixel" can be: converting the coordinate of the second pixel according to the first sub-correspondence relationship to obtain an address of the second identifier block; and obtaining the second identifier block based on the address of the second identifier block.
[0136] In a feasible implementation, when the second sub-correspondence relationship refers to a conversion relationship between pixel coordinates and identifier storage positions, the specific implementation of "determining a second identifier storage position of the second pixel in the second identifier block based on the second sub-correspondence relationship and the coordinate of the second pixel" can be: converting the coordinate of the second pixel according to the second sub-correspondence relationship to obtain the second identifier storage position.
[0137] It should be noted that according to the coordinates of the second pixel, the second identification block corresponding to the second pixel can be determined from the first sub-correspondence relationship between the pixel coordinates and the identification blocks; according to the coordinates of the second pixel, the second identification storage location of the second pixel in the second identification block can be determined from the second sub-correspondence relationship between the pixel coordinates and the identification storage locations; and further, the consistency identification of the second pixel can be determined according to the second identification block and the second identification storage location, so as to facilitate subsequent writing of the color of the sampling point of the second pixel.
[0138] In step 803, a third sub-correspondence relationship between pixel coordinates and color blocks and a fourth sub-correspondence relationship between pixel coordinates and color storage locations are determined from the second correspondence relationship.
[0139] The second correspondence relationship can further include a third sub-correspondence relationship between pixel coordinates and color blocks and a fourth sub-correspondence relationship between pixel coordinates and color storage locations. The third sub-correspondence relationship can refer to a correspondence relationship between pixel coordinates and color block addresses.
[0140] In step 804, a second color block corresponding to the second pixel is determined based on the third sub-correspondence relationship and the coordinates of the second pixel.
[0141] In some embodiments, when the third sub-correspondence relationship is a direct association relationship between pixel coordinates and color block addresses, the specific implementation of step 804 can be that the second color block matching the coordinates of the second pixel is determined from the third sub-correspondence relationship based on the coordinates of the second pixel.
[0142] In some embodiments, when the third sub-correspondence relationship is a conversion relationship between pixel coordinates and color block addresses, the specific implementation of step 804 can be that the address of the second color block is obtained by converting the coordinates of the second pixel according to the third sub-correspondence relationship, and the second color block is obtained based on the address of the second color block.
[0143] In step 805, the second color storage location is determined based on the fourth sub-correspondence relationship and the coordinates of the second pixel.
[0144] In some embodiments, when the fourth sub-correspondence relationship is a direct association relationship between pixel coordinates and color storage locations, the specific implementation of step 805 can be that the second color storage location matching the coordinates of the second pixel is determined from the fourth sub-correspondence relationship based on the coordinates of the second pixel.
[0145] In some embodiments, when the fourth sub-correspondence relationship is a conversion relationship between pixel coordinates and color storage locations, the specific implementation of step 805 can be that the second color storage location is obtained by converting the coordinates of the second pixel according to the fourth sub-correspondence relationship.
[0146] Step 806, in a case where the consistency identifier of the second pixel indicates that the colors of the sampling points corresponding to the second pixel are completely identical, write out the consistency identifier of the second pixel and the color in the color storage region in the second color block at the second color storage position.
[0147] Here, the step 806 corresponds to the aforementioned step 703, and the specific embodiments of the step 703 can be referred to in implementation.
[0148] In some embodiments, the image data writing method provided by the embodiments of the present disclosure further includes steps 807 to 808 as follows:
[0149] Step 807, in a case where the consistency identifier of the second pixel indicates that the colors of the sampling points corresponding to the second pixel are not completely identical, compress the colors of all the sampling points in the second color block to obtain compressed colors.
[0150] Step 808, write out the consistency identifier of the second pixel and the compressed colors.
[0151] It should be noted that, since the consistency identifier occupies a smaller storage space, and the color occupies a larger storage space, only the colors of all the sampling points corresponding to the second pixel can be compressed.
[0152] Based on the foregoing embodiments, the image data writing method provided by the embodiments of the present disclosure further includes steps 809 to 810 as follows:
[0153] Step 809, before writing, add the consistency identifier of each second pixel to a target identifier block.
[0154] Step 810, in a case where the target identifier block has contained a first preset number of consistency identifiers of the second pixels, write out the target identifier block.
[0155] The first preset number can be the number M of pixels corresponding to a single identifier block.
[0156] It should be noted that, writing when the target identifier block has the first preset number of consistency identifiers of the second pixels can reduce the transmission bandwidth when writing, and improve the resource utilization.
[0157] Based on the foregoing embodiments, the image data writing method provided by the embodiments of the present disclosure further includes steps 811 to 812 as follows:
[0158] Step 811, before writing, add the color of each sampling point to be written of the second pixel to a target color block.
[0159] Step 812, in a case where the target color block has contained the second preset number of colors of the sampling points corresponding to the second pixels respectively, writing out the target color block.
[0160] The second preset number can be the number N of pixels corresponding to a single color block.
[0161] It should be noted that, in a case where the target color block has the second preset number of colors of the second pixels, writing out can further reduce the transmission bandwidth during writing out, and improve resource utilization.
[0162] In the embodiments of the present disclosure, in a case where the colors of the plurality of sampling points corresponding to the second pixels are completely identical, only the consistency identifier of the second pixel and the color of the sampling point corresponding to the second pixel stored in any color storage area of the second color block are written out, compared to writing out the colors of the plurality of sampling points corresponding to the second pixels, the transmission bandwidth during writing out is reduced to the greatest extent, the performance and resource utilization of the computer device are improved, and the power consumption of the computer device is reduced.
[0163] The embodiments of the present disclosure provide an image data reading method, which can be executed by a processor of a computer device. As shown in the method includes the following steps 901 to 903: Figure 9
[0164] Step 901, determining a consistency identifier of a third pixel based on a coordinate of the third pixel and a third correspondence relationship.
[0165] The third correspondence relationship represents a correspondence relationship among the coordinate of the third pixel, the consistency identifier of the third pixel, and a third color block corresponding to the third pixel; the consistency identifier of the third pixel is determined based on color consistency of a plurality of sampling points corresponding to the third pixel; the third color block includes colors of sampling points corresponding to a plurality of different pixels, and colors of sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area.
[0166] The third correspondence relationship can be the first correspondence relationship obtained according to the image data storage method described above. The third pixel can be one or more pixels that need to be read from the memory; and the third pixel can be one or more first pixels.
[0167] Here, the implementation of step 901 is similar to the implementation of step 701 described above, and in implementation, the specific implementation of step 701 and the detailed description of steps 801 to 802 corresponding to step 701 can be referred to.
[0168] Specifically, the specific implementation of step 901 can be: obtaining the identification block corresponding to the third pixel from the third correspondence relationship, taking the coordinates of the third pixel as the matching basis; and determining the consistency identification of the third pixel from the identification block corresponding to the third pixel.
[0169] Step 902: determining the third color block and the third color storage position of the third pixel in the third color block based on the coordinates of the third pixel and the third correspondence relationship.
[0170] The third color storage position can be the storage order of the color of the sampling point corresponding to the third pixel in the third color block, that is, the storage position of the color of the sampling point corresponding to the third pixel in the third color block.
[0171] Here, the implementation of step 902 is similar to the implementation of step 702 described above, and the specific implementation of step 702 and the detailed description of steps 803 to 805 corresponding to step 702 can be referred to in implementation.
[0172] Specifically, the specific implementation of step 902 can be: obtaining the third color block corresponding to the third pixel from the third correspondence relationship, taking the coordinates of the third pixel as the matching basis; and obtaining the third color storage position of the third pixel in the third color block from the third correspondence relationship, taking the coordinates of the third pixel as the matching basis.
[0173] Step 903: reading the color at the third color storage position in any color storage area in the third color block and the coordinates of the plurality of sampling points, in a case where the consistency identification of the third pixel represents that the colors of the plurality of sampling points corresponding to the third pixel are completely same.
[0174] The color at the third color storage position in any color storage area in the third color block can be the color of the sampling point corresponding to the third pixel.
[0175] Since the color of the sampling point corresponding to the third pixel is stored in each color storage area of the third color block, in a case where the colors of the plurality of sampling points corresponding to the third pixel are completely same, the colors of the sampling points corresponding to the third pixel stored in each color storage area of the third color block are same; at this time, the color of all the sampling points corresponding to the third pixel can be represented according to the color of the sampling point corresponding to the third pixel stored in any color storage area and the consistency identification of the third pixel.
[0176] In some embodiments, in a case where the consistency identification of the third pixel represents that the colors of the plurality of sampling points corresponding to the third pixel are not completely same, the colors at the third color storage positions in all color storage areas in the third color block are read.
[0177] Reading the color in the third color storage position in all color storage areas in the third color block can be reading the color of all sampling points corresponding to the third pixel.
[0178] In some embodiments, the image data reading method provided by the embodiments of the present disclosure further includes steps 904 to 905:
[0179] Step 904, in the case that the consistency identifier of the third pixel indicates that the colors of the plurality of sampling points corresponding to the third pixel are not completely the same, determining whether there are at least two sampling points with the same color in the plurality of sampling points.
[0180] Step 905, in the case that there are at least two sampling points with the same color in the plurality of sampling points corresponding to the third pixel, reading the color of any one of the at least two sampling points with the same color and the coordinates of the at least two sampling points from the third color block.
[0181] It should be noted that, in the case that the colors of the plurality of sampling points corresponding to the third pixel are not completely the same but there are at least two sampling points with the same color, the color of any one of the at least two sampling points with the same color and the coordinates of the at least two sampling points are used to represent the at least two sampling points with the same color, in other words, the at least two sampling points with the same color are read by merging the color of any one of the at least two sampling points with the same color and the coordinates of the at least two sampling points, which reduces the transmission bandwidth during reading, improves the performance and resource utilization of the computer device, and reduces the power consumption of the computer device.
[0182] In the embodiments of the present disclosure, in the case that the colors of the plurality of sampling points corresponding to the third pixel are completely the same, only the color of the sampling point corresponding to the third pixel stored in any color storage area of the third color block and the consistency identifier of the third pixel are read, which maximally reduces the transmission bandwidth during reading, improves the performance and resource utilization of the computer device, and reduces the power consumption of the computer device, compared with reading the colors of the plurality of sampling points corresponding to the third pixel.
[0183] The application of the image data processing method provided by the embodiments of the present disclosure in an actual scenario is described below.
[0184] The embodiments of the present disclosure design an identifier block (Flag buffer) for storing the consistency identifiers of pixels. As shown in Figure 6 the meaning of each bite in the identifier block is whether the colors of all sampling points of the pixel corresponding to the bite are consistent; if not, the colors of all sampling points are read; if consistent, only the color of the first sampling point (i.e. sampling point 0) is read.
[0185] In practical application, given a pixel coordinate (u, v), the corresponding identification block can be read and written. Specifically, the calculation formula of the address of the 32B identification block can be: (v+15) / 16*(width+15) / 16*32+(u+15) / 16*32; the calculation formula of the bit offset (identification storage location) in the 32B identification block can be: assuming that the low four bits of u in binary are U3U2U1U0, each Ui is 0 or 1; assuming that the low four bits of v in binary are V3V2V1V0, each Vi is 0 or 1; then the bit offset is U3V3U2V2U1V1U0V0.
[0186] As shown in FIG. 1, in a 4x Multi-Sample Anti-Aliasing (4x MSAA) scene, “4x” represents that 4 sampling points will be generated for each pixel, and the storage bit number occupied by a single sampling point is 4 bits. Therefore, a color block can be divided into 4×4 sampling point 0, 4×4 sampling point 1, 4×4 sampling point 2, and 4×4 sampling point 3, each of which is a color storage area with a size of 64B. Figure 5 In an 8x Multi-Sample Anti-Aliasing (8x MSAA) scene, “8x” represents that 8 sampling points will be generated for each pixel, and the storage bit number occupied by a single sampling point is 8 bits. Therefore, a color block can be divided into 2×2 sampling point 0, 2×2 sampling point 1, 2×2 sampling point 2, 2×2 sampling point 3, 2×2 sampling point 4, 2×2 sampling point 5, 2×2 sampling point 6, and 2×2 sampling point 7, each of which is a color storage area with a size of 32B.
[0187]
[0188] In practical applications, given a pixel coordinate (u, v), a storage location of a sample point (sample index (s)), a corresponding color block (color buffer) is read or written. Specifically, a calculation formula of a dimension of a 256B color block can be: assuming that MSAA is N times, N times means that each pixel contains N sample points, each sample point is M byte, and the dimension I of the 256B color block is I = SQRT (256 / N / M), I^2 = 256 / N / M; then the address of the 256B color block is calculated: (v+I-1) / I*(texture_width+I-1) / I*256+(u+I-1) / I*256; wherein (u, v) represents a pixel coordinate, I is a dimension of a color block, texture_width is a width of a color block, (v+I-1) / I*(texture_width+I-1) / I*256 represents an address offset of a current color block relative to a first block in a v direction (i.e., a row direction), and (u+I-1) / I*256 represents an address offset of the current color block relative to a first block of a color block row in a u direction (i.e., a column direction). Assuming that J = log2 (I), assuming that the low J-bit binary of u is Uj-1Uj-2…U0, each Ui is 0 or 1; and assuming that the low J-bit binary of v is Vj-1Vj-2…V0, each Vi is 0 or 1. A calculation formula of a sample point bit offset in the 256B can be: 256 / N*s+Uj-1Vj-1Uj-2Vj-2…U0V0*M.
[0189] Based on Figure 5 The storage manner of the color of the sample point corresponding to the pixel shown and the storage manner of the consistency identifier of the pixel shown are used to read or write the color of the sample point corresponding to the pixel. As shown in Figure 6 The storage manner of the color of the sample point corresponding to the pixel shown and the storage manner of the consistency identifier of the pixel shown are used to read or write the color of the sample point corresponding to the pixel. As shown in Figure 10 and Figure 11 A shader is a program running on a graphics processing unit (GPU) and is used to perform various calculations in the graphics rendering process, such as vertex transformation, rasterization, texture mapping, etc. A shader thread can be a single execution unit that performs various calculations in the graphics rendering process. One execution unit in a shader can process one pixel and its corresponding four sample points. A texture writer is used to create, edit or write image textures. A samples combiner is used to combine sample points with the same color. A texture compressor is used to reduce the size of image textures while trying to maintain the image quality as much as possible. A texture reader is used to read and parse image textures.
[0190] Referring to Figure 10 The specific flow of the image data writing method provided by the embodiment of the disclosure when applied to MSAA is as follows:
[0191] 1. The software initializes the flag buffer to all 0s through GPU DMA.
[0192] 2. The texture writer collects the colors of all sample points on a color block (256B).
[0193] a. If the colors of all sample points on the color block are consistent, the texture writer only needs to write the sub-block of sample point 0, that is, only 1 / 2~1 / 8 of 256B needs to be written. For example, if one identification block corresponds to 4*4 pixels, only 1 / 4 of 256B needs to be written; if one identification block corresponds to 2*2 pixels, only 1 / 8 of 256B needs to be written.
[0194] b. If the colors of two or more sample points are inconsistent, the texture writer needs to write the sub-blocks of all sample points, and set the bits corresponding to the identification block to 1.
[0195] c. After processing the color block of 16x16 pixels, the identification block is 32B, which can be written out.
[0196] 3. The sample point color storage area (sample color buffer) is compressed by the texture compressor and written out as a normal non-MSAA texture.
[0197] 4. The identification block is directly written out without any compression, because the 1-bit consistency identification is already a very high compression rate, and the cache residency strategy can be used for reading and writing the consistency identification, so that it can be in the cache most of the time.
[0198] Referring to Figure 11 The specific flow of the image data reading method provided by the embodiment of the disclosure when applied to MSAA is as follows:
[0199] 1. When the MSAA texture is completely written to the memory, after a certain period of time, the GPU will need to read it again. The texture reader will calculate the storage address of the consistency identification of the pixel in the identification block according to the pixel coordinates provided by the renderer and the conversion relationship between the identification block and the pixel coordinates, read the 32B identification block, and the read identification block will be cached in the texture reader.
[0200] 2. If the bit of the consistency identification of the required pixel is 0, the texture reader only needs to read the sub-block of sample point 0 of the color block (256B).
[0201] a、This case, only need to return to the renderer 1 sample point color and sample point bit mask; sample point bit mask is used to indicate the corresponding multiple sample points of the pixel, for example: sample color + full set bit mask (0xf / 0xff / etc); wherein, 0xf is used to indicate that a pixel corresponds to 4 sample points; 0xff is used to indicate that a pixel corresponds to 8 sample points; full set bit mask is used to indicate all sample points corresponding to a pixel.
[0202] 3、If the consistency identifier of the required pixel is 1, the texture reader needs to read the entire color block (256B).
[0203] a、This case, the texture reader can merge the same sample point color, plus the corresponding sample point bit mask (sample bit mask). For example, the color of sample point 0 and sample point 1 is consistent, then return a sample point color plus bit mask 0b11 (used to indicate that the color of sample point 0 and sample point 1 is consistent).
[0204] It should be noted that the cache residence strategy can be used for reading and writing of the consistency identifier, so that it is in the cache most of the time. When writing out, the user can set the priority of writing out; when reading, the priority of reading can be determined by the internal mechanism of the cache, for example, to ensure the efficiency of reading, the priority of reading is initially set to the highest, and when there is no reading operation for a period of time, the priority of reading is reduced to the lowest, so that the current reading operation is removed from the cache.
[0205] The sample point color storage format is different from related technologies in that: 1, a storage area (flag buffer) of the consistency identifier is added; 2, previously, the colors of multiple sample points of the same pixel were stored together, that is, grouping is performed according to the pixel. However, the embodiment of the present disclosure stores the sample points corresponding to different pixels together (for example, corresponding to 4*4, 4 sample points 1 are stored together, 4 sample points 2 are stored together, 4 sample points 3 are stored together, and 4 sample points 4 are stored together), that is, grouping is performed according to the sample points.
[0206] Taking 1080p, 4xMSAA, 4B per sample MSAA texture writing out as an example. Among them, 1080p refers to the resolution, that is, 1920x1080 pixels, that is, there are 1920 pixel points in the horizontal direction and 1080 pixel points in the vertical direction. 4xMSAA: indicates that there are 4 sample points for each pixel, which is used for anti-aliasing processing. 4B per sample MSAA texture: each sample point in the MSAA texture occupies 4 bytes.
[0207] a, Color block is 4x4 pixels * 4 samples * 4B.
[0208] b, Width of color block is 1920 / 4 = 480 blocks, height of color block is 1080 / 4 = 270 blocks.
[0209] c, Width of identity block is 1920 / 16 = 120 blocks, height of identity block is (1080+15) / 16 = 68 blocks.
[0210] d, Texture writer will pad 4x4 pixels = 256B color block and write it out.
[0211] e, If all samples of all pixels in 4x4 are the same, write out 4x4 pixels = 64B.
[0212] f, If all pixels in 4x4 have more than 2 samples of different colors, write out 4x4 pixels = 256B.
[0213] g, Set half of 8x4 storage area of identity corresponding to 4x4 pixels to 1.
[0214] h, After processing 16 4x4 pixels, the storage area of identity is padded to 16x16 identity block and can be written out.
[0215] Take 1080p, 4xMSAA, 4B per sample MSAA texture reading as an example.
[0216] a, If the renderer gives pixel coordinates (2, 2), it wants to read all 4 sample colors of pixel coordinates (2, 2).
[0217] b, The identity block corresponding to pixel coordinates (2, 2) is the 0th 32B.
[0218] c, The bit position of the identity corresponding to pixel coordinates (2, 2) is bit 12 in 32B or 256bit.
[0219] d, 4xMSAA, 4B per sample MSAA texture, the corresponding color block size is 4x4.
[0220] e, The color block corresponding to pixel coordinates (2, 2) is the 0th 256B.
[0221] f. If the consistency identifier bit is 1, all 4x4 samples (256B) need to be read.
[0222] g. The 12th sample point is obtained from each 4x4 sample 64B.
[0223] h. All the same sample points and the corresponding sample point identifiers are returned to the renderer each time, with a maximum of four times and a minimum of two times.
[0224] i. If the consistency identifier bit is 0, the first 4x4 sample point (64B) needs to be read.
[0225] j. The color of sample point 0 and the sample point bit mask (bit mask 0xf) are returned to the renderer.
[0226] It should be noted that the embodiment of the present disclosure uses the form of the sample point identifier of any pixel and the color (color+mask) of any sample point to replace the form of color replication four times; and uses a simple consistency identifier and a storage area of the sample point color compressed twice. In this way, the transmission bandwidth of the GPU inside and outside is saved, the calculation amount of the thread of the renderer is saved, the performance of the device is improved, and the power consumption of the device is reduced.
[0227] Based on the foregoing embodiment, the embodiment of the present disclosure provides an image data storage device, which comprises units and modules included in the units, and can be realized by a processor in a computer device; of course, it can also be realized by a specific logic circuit; in the implementation process, the processor can be a central processing unit (CPU), a microprocessor unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA).
[0228] Figure 12 The constituent structure of the image data storage device provided by the embodiment of the present disclosure is shown in Figure 12 The image data storage device 1200 comprises an obtaining module 1210, a first processing module 1220, and a storage module 1230, wherein:
[0229] The obtaining module 1210 is configured to obtain the colors of a plurality of sample points corresponding to a first pixel to be processed;
[0230] The first processing module 1220 is configured to determine a consistency identifier of the first pixel based on color consistency of the plurality of sampling points corresponding to the first pixel.
[0231] The storage module 1230 is configured to store colors of sampling points corresponding to the same sampling point identifier of different first pixels in a same color storage area based on the plurality of sampling point identifiers corresponding to each first pixel, to obtain a first color block; and the same sampling point identifier generation manner is the same for different first pixels.
[0232] The first processing module 1220 is further configured to establish a correspondence between the coordinates of the first pixels, the consistency identifiers of the first pixels and the first color blocks, to obtain a first correspondence.
[0233] In some embodiments, the storage module 1230 is further configured to set the consistency identifier of the first pixel as a first identifier in a case where the colors of the plurality of sampling points corresponding to the first pixel are completely same; and set the consistency identifier of the first pixel as a second identifier in a case where the colors of the plurality of sampling points corresponding to the first pixel are not completely same.
[0234] In some embodiments, the storage module 1230 is further configured to determine a number N of pixels corresponding to a single color storage area; N is a positive integer; store colors of sampling points corresponding to the same sampling point identifier of every N first pixels in a same color storage area based on the plurality of sampling point identifiers corresponding to each first pixel, to obtain a first color block corresponding to every N first pixels.
[0235] In some embodiments, the storage module 1230 is further configured to determine a first color storage position of every N first pixels based on the coordinates of every N first pixels; and store colors of sampling points corresponding to the same sampling point identifier of every N first pixels in a same color storage area according to the first color storage position based on the plurality of sampling point identifiers corresponding to each first pixel, to obtain a first color block corresponding to every N first pixels.
[0236] In some embodiments, the storage module 1230 is further configured to: determine the color of the sampling point with the i-th sampling point identifier corresponding to every N first pixels based on the plurality of sampling point identifiers corresponding to each of the first pixels; i is a positive integer; sequentially store the color of the sampling point with the i-th sampling point identifier corresponding to every N first pixels in the i-th color storage area according to the first color storage position; determine the color of the sampling point with the i+1-th sampling point identifier corresponding to every N first pixels based on the plurality of sampling point identifiers corresponding to each of the first pixels; sequentially store the color of the sampling point with the i+1-th sampling point identifier corresponding to every N first pixels in the i+1-th color storage area according to the first color storage position; and determine the first color block corresponding to every N first pixels based on the i-th color storage area and the i+1-th color storage area.
[0237] In some embodiments, the storage module 1230 is further configured to: determine the number M of pixels corresponding to a single identifier block; M is a positive integer; determine the first identifier storage position of every M first pixels based on the coordinates of the M first pixels; and store the consistency identifier of every M first pixels in the same storage area according to the first identifier storage position to obtain the first identifier block.
[0238] Based on the foregoing embodiments, the present disclosure provides an image data writing device, which includes various units and modules included in the units, and can be implemented by a processor in a computer device. Of course, the device can also be implemented by a specific logic circuit. In the implementation process, the processor can be a central processing unit (CPU), a micro processing unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA).
[0239] Figure 13 A schematic diagram of the composition structure of an image data writing device provided by the present disclosure is shown in FIG. 13. Figure 13 As shown in FIG. 13, the image data writing device 1300 includes a second processing module 1310 and a writing module 1320, wherein:
[0240] The second processing module 1310 is configured to determine the consistency identifier of the second pixel based on the coordinate of the second pixel to be written out and a second correspondence relationship, wherein the second correspondence relationship represents a correspondence relationship among the coordinate of the second pixel, the consistency identifier of the second pixel and a second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on the color consistency of a plurality of sampling points corresponding to the second pixel, the second color block comprises the colors of the sampling points corresponding to a plurality of different pixels, and the colors of the sampling points corresponding to the same sampling point identifier are stored in the same color storage area.
[0241] The second processing module 1310 is further configured to determine the second color block and the second color storage position of the second pixel in the second color block based on the coordinate of the second pixel and the second correspondence relationship.
[0242] The writing-out module 1320 is configured to write out the consistency identifier of the second pixel and the color in the second color storage position in any color storage area in the second color block in a case where the consistency identifier of the second pixel represents that the colors of the plurality of sampling points corresponding to the second pixel are completely same.
[0243] In some embodiments, the writing-out module 1320 is further configured to: in a case where the consistency identifier of the second pixel represents that the colors of the plurality of sampling points corresponding to the second pixel are not completely same, compress the colors of all the sampling points in the second color block to obtain compressed colors; and write out the consistency identifier of the second pixel and the compressed colors.
[0244] In some embodiments, the second processing module 1310 is further configured to: determine, from the second correspondence relationship, a first sub-correspondence relationship between pixel coordinates and identifier blocks and a second sub-correspondence relationship between pixel coordinates and identifier storage positions; and determine the consistency identifier of the second pixel based on the first sub-correspondence relationship, the second sub-correspondence relationship and the coordinate of the second pixel.
[0245] In some embodiments, the second processing module 1310 is further configured to: determine a second identifier block corresponding to the second pixel based on the first sub-correspondence relationship and the coordinate of the second pixel; determine a second identifier storage position of the second pixel in the second identifier block based on the second sub-correspondence relationship and the coordinate of the second pixel; and determine the consistency identifier of the second pixel based on the second identifier block and the second identifier storage position.
[0246] In some embodiments, the second processing module 1310 is further configured to: determine, from the second correspondence, a third sub-correspondence between pixel coordinates and color blocks, and a fourth sub-correspondence between pixel coordinates and color storage locations; determine, based on the third sub-correspondence and the coordinate of the second pixel, the second color block corresponding to the second pixel; and determine, based on the fourth sub-correspondence and the coordinate of the second pixel, the second color storage location.
[0247] In some embodiments, the write-out module 1320 is further configured to: before writing out, add the consistency identifier of each second pixel to a target identifier block; and write out the target identifier block if the target identifier block has already contained consistency identifiers of a first preset number of second pixels.
[0248] In some embodiments, the write-out module 1320 is further configured to: before writing out, add the color of the sampling point to be written out by each second pixel to a target color block; and write out the target color block if the target color block has already contained colors of sampling points corresponding to a second preset number of second pixels.
[0249] Based on the foregoing embodiments, the embodiments of the present disclosure provide an image data reading device, which includes units and modules included in the units, and can be implemented by a processor in a computer device. Of course, the device can also be implemented by a specific logic circuit. In the implementation process, the processor can be a central processing unit (CPU), a micro processing unit (MPU), a digital signal processor (DSP), or a field programmable gate array (FPGA).
[0250] Figure 14 A schematic diagram of the composition structure of an image data reading device provided by the embodiments of the present disclosure is shown in FIG. 14. Figure 14 As shown in FIG. 14, the image data reading device 1400 includes a third processing module 1410 and a reading module 1420, wherein:
[0251] The third processing module 1410 is configured to determine the consistency identifier of the third pixel based on the coordinate of the third pixel to be read and the third correspondence relationship, wherein the third correspondence relationship represents a correspondence relationship among the coordinate of the third pixel, the consistency identifier of the third pixel and the third color block corresponding to the third pixel; the consistency identifier of the third pixel is determined based on the color consistency of the plurality of sampling points corresponding to the third pixel, the third color block comprises the colors of the sampling points corresponding to the plurality of different pixels, and the colors of the sampling points corresponding to the same sampling point identifier of different pixels are stored in the same color storage area;
[0252] The third processing module 1410 is further configured to determine the third color block and the third color storage position of the third pixel in the third color block based on the coordinate of the third pixel and the third correspondence relationship.
[0253] The reading module 1420 is configured to read the color at the third color storage position in any color storage area in the third color block and the coordinate of the plurality of sampling points in a case where the consistency identifier of the third pixel represents that the colors of the plurality of sampling points corresponding to the third pixel are completely same.
[0254] The above description of the device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects to the method embodiments. In some embodiments, the device provided by the embodiments of the present disclosure has functions or includes modules that can be used to execute the methods described in the above method embodiments. For technical details not disclosed in the device embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure.
[0255] It should be noted that, in the embodiments of the present disclosure, if the above method is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present disclosure can be embodied in the form of a software product in essence or the part that contributes to the related art, which is stored in a storage medium, includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present disclosure. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various program code storage media. Therefore, the embodiments of the present disclosure are not limited to any specific hardware, software or firmware, or any combination of hardware, software and firmware.
[0256] The embodiment of the present disclosure provides a computer device, comprising a memory and a processor, the memory stores a computer program which can run on the processor, and the processor implements part or all steps of the above method when executing the program.
[0257] The embodiment of the present disclosure provides a computer readable storage medium, which stores a computer program, and the computer program implements part or all steps of the above method when executed by a processor. The computer readable storage medium can be transitory or non-transitory.
[0258] The embodiment of the present disclosure provides a computer program, comprising computer readable code, when the computer readable code runs in a computer device, a processor in the computer device executes part or all steps of the above method.
[0259] The embodiment of the present disclosure provides a computer program product, comprising a non-transitory computer readable storage medium storing a computer program, and the computer program is read and executed by a computer to implement part or all steps of the above method. The computer program product can be implemented by hardware, software or a combination thereof. In some embodiments, the computer program product is embodied as a computer storage medium, and in other embodiments, the computer program product is embodied as a software product, such as a software development kit (Software Development Kit, SDK) and the like.
[0260] It should be noted that: the above description of various embodiments tends to emphasize the differences between various embodiments, and the same or similar parts can be referred to each other. The above description of the device, storage medium, computer program and computer program product embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the device, storage medium, computer program and computer program product embodiments of the present disclosure, please refer to the description of the method embodiments of the present disclosure.
[0261] It should be noted that, Figure 15 A hardware entity diagram of a computer device in the embodiment of the present disclosure is shown in FIG. 15, which comprises a processor 1501, a communication interface 1502 and a memory 1503, wherein: Figure 15 The processor 1501 generally controls the overall operation of the computer device 1500.
[0262] The processor 1501 generally controls the overall operation of the computer device 1500.
[0263] The communication interface 1502 can enable the computer device to communicate with other terminals or servers through a network.
[0264] The memory 1503 is configured to store instructions and applications executable by the processor 1501, and can also cache data (e.g., image data, audio data, voice communication data, and video communication data) to be processed by the processor 1501 and modules in the computer device 1500, and can be implemented by FLASH or Random Access Memory (RAM). The processor 1501, the communication interface 1502, and the memory 1503 can perform data transmission through the bus 1504.
[0265] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present disclosure. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that the size of the sequence number of each step / process in various embodiments of the present disclosure does not mean the order of execution, and the execution order of each step / process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure. The sequence number of the above-mentioned embodiments of the present disclosure is only for description, not representing the advantages or disadvantages of the embodiments.
[0266] It should be noted that, in this document, the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or includes elements inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device including the element.
[0267] In several embodiments provided by the present disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division, and actual implementation can have another division manner. For example, multiple units or components can be combined, or can be integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the various components shown or discussed can be indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or in other forms.
[0268] The units described as separate components above can or can not be physically separate, and the components shown as units can or can not be physical units; they can be located in one place or distributed on multiple network units; and part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0269] In addition, each functional unit in each embodiment of the present disclosure can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit; the integrated unit can be realized in the form of hardware or in the form of hardware plus software functional units.
[0270] Those skilled in the art can understand that all or part of the steps of the above method embodiments can be completed by program instruction related hardware, and the foregoing program can be stored in a computer readable storage medium, and the program executes the steps including the above method embodiments when executed; and the foregoing storage medium includes mobile storage devices, read only memory (Read Only Memory, ROM), magnetic discs or optical discs, and various storage medium that can store program codes.
[0271] Alternatively, the integrated units of the present disclosure, if implemented in the form of software functional modules and sold or used as independent products, can also be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present disclosure can be embodied in the form of software products, and the computer software products are stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in the embodiments of the present disclosure. The foregoing storage medium includes mobile storage devices, ROM, magnetic discs or optical discs, and various storage medium that can store program codes.
[0272] The above is only an embodiment of the present disclosure, but the protection scope of the present disclosure is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present disclosure, which should be covered within the protection scope of the present disclosure.
Claims
1. An image data storage method, characterized in that, The image data storage method includes: Obtain the colors of multiple sampling points corresponding to the first pixel to be processed; Based on the color consistency of multiple sampling points corresponding to the first pixel, the consistency identifier of the first pixel is determined; Based on multiple sampling point identifiers corresponding to each first pixel, the colors of sampling points with the same sampling point identifier corresponding to different first pixels are stored in the same color storage area to obtain a first color block; different first pixels correspond to the same sampling point identifier generation method; the sampling point identifier is used to characterize the position of the corresponding sampling point in the first pixel; Establish the correspondence between the coordinates of the first pixel, the consistency identifier of the first pixel, and the first color block to obtain the first correspondence; Wherein, when the consistency identifier of any first pixel indicates that the color of the sampling point corresponding to any first pixel is completely the same, the color of all sampling points corresponding to any first pixel is obtained based on the consistency identifier of any first pixel and the color of any sampling point corresponding to any first pixel stored in the first color block.
2. The image data storage method according to claim 1, characterized in that, The step of determining the consistency identifier of the first pixel based on the color consistency of multiple sampling points corresponding to the first pixel includes: If the colors of multiple sampling points corresponding to the first pixel are exactly the same, the consistency flag of the first pixel is set as the first flag; If the colors of multiple sampling points corresponding to the first pixel are not completely the same, the consistency flag of the first pixel is set as the second flag.
3. The image data storage method according to claim 1, characterized in that, The step of storing the colors of sampling points with the same sampling point identifier corresponding to different first pixels in the same color storage area based on multiple sampling point identifiers corresponding to each first pixel to obtain a first color block includes: Determine the number N of pixels corresponding to a single color storage region; N is a positive integer. Based on the multiple sampling point identifiers corresponding to each first pixel, the colors of the sampling points with the same sampling point identifier corresponding to each N first pixels are stored in the same color storage area to obtain the first color block corresponding to each N first pixels.
4. The image data storage method according to claim 3, characterized in that, The step of storing the colors of sampling points with the same sampling point identifier corresponding to N first pixels in the same color storage area based on multiple sampling point identifiers corresponding to each first pixel to obtain a first color block corresponding to each N first pixels includes: Based on the coordinates of every N first pixels, determine the storage location of the first color for every N first pixels; Based on the multiple sampling point identifiers corresponding to each first pixel, according to the first color storage location, the colors of the sampling points with the same sampling point identifier corresponding to every N first pixels are stored in the same color storage area to obtain the first color block corresponding to every N first pixels.
5. The image data storage method according to claim 4, characterized in that, The step of storing the colors of sampling points with the same sampling point identifier corresponding to every N first pixels in the same color storage area according to the first color storage location, based on multiple sampling point identifiers corresponding to each first pixel, to obtain a first color block corresponding to every N first pixels, includes: Based on the multiple sampling point identifiers corresponding to each first pixel, determine the color of the sampling point with sampling point identifier i corresponding to every N first pixels; i is a positive integer. According to the first color storage location, the colors of the sampling points marked as i corresponding to every N first pixels are sequentially stored in the i-th color storage area; Based on the multiple sampling point identifiers corresponding to each first pixel, determine the color of the sampling point with sampling point identifier i+1 corresponding to each N first pixels; According to the first color storage location, the color of the sampling point marked as i+1 corresponding to every N first pixels is stored sequentially in the (i+1)th color storage area. Based on the i-th color storage region and the (i+1)-th color storage region, determine the first color block corresponding to each N first pixels.
6. The image data storage method according to any one of claims 1 to 5, characterized in that, The image data storage method further includes: Determine the number M of pixels corresponding to a single identifier block; M is a positive integer; Based on the coordinates of each M first pixels, determine the first identifier storage location for each M first pixels; According to the first identifier storage location, the consistency identifiers of every M first pixels are stored in the same storage area to obtain the first identifier block.
7. A method for writing image data, characterized in that, The image data writing method includes: Based on the coordinates of the second pixel to be written and the second correspondence, the consistency identifier of the second pixel is determined; the second correspondence represents the correspondence between the coordinates of the second pixel, the consistency identifier of the second pixel, and the second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on the color consistency of multiple sampling points corresponding to the second pixel, the second color block includes the colors of sampling points corresponding to multiple different pixels, and the colors of sampling points with the same sampling point identifier corresponding to different pixels are stored in the same color storage area; the sampling point identifier is used to represent the position of the corresponding sampling point in the second pixel; Based on the coordinates of the second pixel and the second correspondence, the second color block and the second color storage position of the second pixel in the second color block are determined; If the consistency identifier of the second pixel indicates that the colors of multiple sampling points corresponding to the second pixel are completely the same, write out the consistency identifier of the second pixel and the color in the second color storage position in any color storage area of the second color block.
8. The image data writing method according to claim 7, characterized in that, The image data writing method further includes: When the consistency identifier of the second pixel indicates that the colors of multiple sampling points corresponding to the second pixel are not completely the same, the colors of all sampling points in the second color block are compressed to obtain the compressed color. Write down the consistency identifier of the second pixel and the compressed color.
9. The image data writing method according to claim 7 or 8, characterized in that, The step of determining the consistency identifier of the second pixel based on the coordinates of the second pixel to be written and the second correspondence includes: From the second correspondence, determine the first sub-correspondence between pixel coordinates and identifier blocks, and the second sub-correspondence between pixel coordinates and identifier storage locations; Based on the first sub-correspondence, the second sub-correspondence, and the coordinates of the second pixel, the consistency identifier of the second pixel is determined.
10. The image data writing method according to claim 9, characterized in that, The step of determining the consistency identifier of the second pixel based on the first sub-correspondence, the second sub-correspondence, and the coordinates of the second pixel includes: Based on the first sub-correspondence relationship and the coordinates of the second pixel, the second identifier block corresponding to the second pixel is determined; Based on the second sub-correspondence and the coordinates of the second pixel, determine the second identifier storage location of the second pixel in the second identifier block; Based on the second identifier block and the second identifier storage location, the consistency identifier of the second pixel is determined.
11. The image data writing method according to claim 7 or 8, characterized in that, The step of determining the second color block and the second color storage location of the second pixel within the second color block based on the coordinates of the second pixel and the second correspondence includes: From the second correspondence, determine the third sub-correspondence between pixel coordinates and color blocks, and the fourth sub-correspondence between pixel coordinates and color storage locations; Based on the third sub-correspondence and the coordinates of the second pixel, the second color block corresponding to the second pixel is determined; Based on the fourth sub-correspondence and the coordinates of the second pixel, the storage location of the second color is determined.
12. The image data writing method according to claim 7, 8, or 10, characterized in that, The image data writing method further includes: Before writing, add the consistency flag of each second pixel to the target flag block; If the target identifier block already contains a first preset number of consistency identifiers for the second pixel, then write out the target identifier block.
13. The image data writing method according to claim 7, 8, or 10, characterized in that, The image data writing method further includes: Before writing, add the color of each sampling point of the second pixel to be written to the target color block; If the target color block already contains the colors of the sampling points corresponding to the second pixel of a second preset number, then write out the target color block.
14. A method for reading image data, characterized in that, The image data reading method includes: Based on the coordinates of the third pixel to be read and the third correspondence, the consistency identifier of the third pixel is determined; the third correspondence represents the correspondence between the coordinates of the third pixel, the consistency identifier of the third pixel, and the third color block corresponding to the third pixel; the consistency identifier of the third pixel is determined based on the color consistency of multiple sampling points corresponding to the third pixel, the third color block includes the colors of sampling points corresponding to multiple different pixels, and the colors of sampling points with the same sampling point identifier corresponding to different pixels are stored in the same color storage area; the sampling point identifier is used to represent the position of the corresponding sampling point in the third pixel; Based on the coordinates of the third pixel and the third correspondence, the third color block and the third color storage position of the third pixel in the third color block are determined; When the consistency identifier of the third pixel indicates that the colors of multiple sampling points corresponding to the third pixel are completely the same, the color at the third color storage position in any color storage area of the third color block and the consistency identifier of the third pixel are read.
15. The image data reading method according to claim 14, characterized in that, The image data reading method further includes: If the consistency identifier of the third pixel indicates that the colors of multiple sampling points corresponding to the third pixel are not completely the same, determine whether there are at least two sampling points with the same color among the multiple sampling points; If at least two sampling points of the same color exist among the multiple sampling points corresponding to the third pixel, the color of any one of the at least two sampling points of the same color and the coordinates of the at least two sampling points are read from the third color block.
16. An image data storage device, characterized in that, The image data storage device includes: The module is configured to obtain the colors of multiple sampling points corresponding to the first pixel to be processed. The first processing module is configured to determine the consistency identifier of the first pixel based on the color consistency of multiple sampling points corresponding to the first pixel. The storage module is configured to store the colors of sampling points with the same sampling point identifier corresponding to different first pixels in the same color storage area based on multiple sampling point identifiers corresponding to each first pixel, thereby obtaining a first color block; different first pixels correspond to the same sampling point identifier generation method; the sampling point identifier is used to characterize the position of the corresponding sampling point in the first pixel. The first processing module is further configured to establish a correspondence between the coordinates of the first pixel, the consistency identifier of the first pixel, and the first color block to obtain a first correspondence. Wherein, when the consistency identifier of any first pixel indicates that the color of the sampling point corresponding to any first pixel is completely the same, the color of all sampling points corresponding to any first pixel is obtained based on the consistency identifier of any first pixel and the color of any sampling point corresponding to any first pixel stored in the first color block.
17. An image data writing device, characterized in that, The image data writing device includes: The second processing module is configured to determine the consistency identifier of the second pixel based on the coordinates of the second pixel to be written and the second correspondence; the second correspondence represents the correspondence between the coordinates of the second pixel, the consistency identifier of the second pixel, and the second color block corresponding to the second pixel; the consistency identifier of the second pixel is determined based on the color consistency of multiple sampling points corresponding to the second pixel, the second color block includes the colors of sampling points corresponding to multiple different pixels, and the colors of sampling points with the same sampling point identifier corresponding to different pixels are stored in the same color storage area; the sampling point identifier is used to represent the position of the corresponding sampling point in the second pixel; The second processing module is further configured to determine the second color block and the second color storage position of the second pixel in the second color block based on the coordinates of the second pixel and the second correspondence. The write module is configured to write out the consistency identifier of the second pixel and the color at the second color storage position in any color storage area of the second color block when the consistency identifier of the second pixel indicates that the colors of multiple sampling points corresponding to the second pixel are completely the same.
18. An image data reading device, characterized in that, The image data reading device includes: The third processing module is configured to determine the consistency identifier of the third pixel based on the coordinates of the third pixel to be read and the third correspondence relationship; the third correspondence relationship represents the correspondence between the coordinates of the third pixel, the consistency identifier of the third pixel, and the third color block corresponding to the third pixel; the consistency identifier of the third pixel is determined based on the color consistency of multiple sampling points corresponding to the third pixel, the third color block includes the colors of sampling points corresponding to multiple different pixels, and the colors of sampling points with the same sampling point identifier corresponding to different pixels are stored in the same color storage area; the sampling point identifier is used to represent the position of the corresponding sampling point in the third pixel; The third processing module is further configured to determine the third color block and the third color storage position of the third pixel in the third color block based on the coordinates of the third pixel and the third correspondence. The reading module is configured to read the color at the third color storage position in any color storage area of the third color block and the consistency identifier of the third pixel when the consistency identifier of the third pixel indicates that the colors of multiple sampling points corresponding to the third pixel are completely the same.
19. A computer device comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 6, or claims 7 to 13, or claims 14 to 15.
20. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program performs the steps of the method as described in any one of claims 1 to 6, or claims 7 to 13, or claims 14 to 15.
Citation Information
Patent Citations
Three-dimensional reconstruction method and device, equipment and storage medium
CN117934728A
Pixel cutting method and device, equipment, storage medium and computer program product
CN119151953A