Optimized partition selection for BC7 texture encoding
View Patent ↗An encoder may select a BC7 partition by computing gradient strengths between adjacent pixels in multiple directions and shortlisting candidate partitions based on strength. Gradient totals may be scaled to normalize different counts of adjacent pixel pairs across directions. A partition may then chosen from the shortlist by evaluating per channel extents within the partition subsets with optional weighting by subset size and reuse of intermediate minimum and maximum bounds. Alpha contributions may be omitted for blocks in which all pixels are fully opaque. The selected partition may be used to process a block for storage or transmission and later decompression at a rendering device, and the approach can be combined with mode selection predicted from features based on per channel ranges.
1 . An apparatus comprising:
at least one processor assembly configured to:
identify M candidate partitions from N partitions, N>M, for block compression 7 (BC7) of texture data at least in part by:
for at least a first block of the texture data, computing gradient strengths between adjacent pixels in plural directions, each direction being associated with a respective absolute gradient strength;
identifying the direction having the lowest absolute gradient strength; and
identifying the M candidate partitions based on the direction having the lowest absolute gradient strength;
use at least a first candidate partition of the M candidate partitions to process at least the first block of texture data for storage or transmission thereof for decompression at a rendering device to render at least one image; and
reuse at least a first calculation from the first candidate partition in calculating at least one operation of a second candidate partition of the M candidate partitions.
2 . The apparatus of claim 1 , wherein the at least one processor assembly is configured for not using alpha values of pixels on blocks of pixel data with alpha value not being less than 255.
3 . The apparatus of claim 1 , wherein the plural directions comprise horizontal and vertical.
4 . The apparatus of claim 3 , wherein the plural directions comprise two diagonal directions.
5 . The apparatus of claim 4 , wherein the at least one processor assembly is configured to:
apply a first scale factor to gradient strengths in the vertical and horizontal directions and a second scale factor to gradient strengths in the two diagonal directions to render scaled gradient strengths; and
use the gradient strengths to identify M candidate partitions.
6 . The apparatus of claim 1 , wherein the at least one processor assembly is configured to select the first one of the M candidate partitions to compress at least the first block of texture data at least in part by scoring each of the M partitions by:
summing per-channel extents of pixels in each subset of the respective partition to render channel sums;
weighting each channel sum by a number of pixels in each respective subset to establish the respective score of the respective partition; and
selecting from among the M candidate partitions the partition with a score less than the scores of the remaining candidate partitions among the M candidate partitions.
7 . The apparatus of claim 1 , wherein the first calculation comprises a min/max calculation that includes determining a minimum bound and a maximum bound for a value based on at least a subset of the first candidate partition.
8 . The apparatus of claim 7 , wherein the at least one processor assembly is configured to:
merge at least two min/max calculations to generate min/max bounds for plural subsets of the first candidate partition including determining the minimum bound and the maximum bound for the value based on the plural subsets of the first candidate partition; and
reuse the min/max bounds determined for the first candidate partition to execute at least one operation for the second candidate partition.
9 . The apparatus of claim 1 , wherein the at least one processor assembly is configured to:
select a BC7 mode of compression at least in part by:
for each block in a training set of blocks of pixels, computing an error resulting in compressing the block or component subsets of the block in each of plural BC7 modes;
for each block in the training set, computing at least one feature associated with a per-channel range of pixel values within the block or the component subsets;
inputting the features and errors to at least one machine learning (ML) model to train the model to predict per-mode compression error based on the features; and
subsequently using the ML model to select a BC7 mode of compression for the texture data.
10 . A device comprising:
at least one computer storage that is not a transitory signal and that comprises instructions executable by at least one processor assembly to:
identify, for at least first and second directions relative to a computer graphics texture data structure, respective first and second values derived from pixel values of the computer graphics texture data structure;
use one of the values to select a subset of M candidate partitions from N partitions, M<N; and
select a first candidate partition in the subset of M candidate partitions to encode the computer graphics texture data structure, selection of the first candidate partition being based on pixel extents in the first one of the candidate partitions in the subset of M candidate partitions; and
reuse at least a first calculation from the first candidate partition in calculating at least one operation of a second candidate partition in the subset of the M candidate partitions.
11 . The device of claim 10 , wherein the computer graphics texture data structure comprises at least one block.
12 . The device of claim 11 , wherein the block comprises a block compression (BC) 7 block.
13 . The device of claim 10 , wherein the first and second directions respectively comprise horizontal and vertical.
14 . The device of claim 13 , wherein the instructions are executable to:
identify for the horizontal, vertical, and two diagonal directions respective first, second, third, and fourth values derived from pixel values of at least one block.
15 . The device of claim 14 , wherein the first through fourth values respectively establish first through fourth gradient strengths, and the instructions are executable to:
apply a first scale factor to the respective gradient strengths in the vertical and horizontal directions and a second scale factor to the respective gradient strengths in the two diagonal directions to render scaled gradient strengths; and
use the gradient strengths to identify the M candidate partitions.
16 . The device of claim 10 , wherein the instructions are executable to select the first one of the candidate partitions at least in part by:
for each of the M candidate partitions, summing per-channel extents of pixels in each subset of the respective partition to render channel sums;
weighting each channel sum by the number of pixels in each respective subset to establish the respective score of the respective partition; and
selecting from among the M candidate partitions the partition with a score less than the scores of the remaining candidate partitions among the M candidate partitions.
17 . The device of claim 10 , wherein the instructions are executable to:
reuse at least a first calculation from a first candidate partition in at least one operation of a second candidate partition.
18 . The device of claim 17 , wherein the first calculation comprises a min/max calculation that includes determining a minimum bound and a maximum bound for a value based on at least a subset of the first candidate partition, and the instructions are executable to:
merge at least two min/max calculations to generate min/max bounds for plural subsets of the first candidate partition including determining the minimum bound and the maximum bound for the value based on the plural subsets of the first candidate partition; and
reuse the min/max bounds determined for the first candidate partition to calculate at least one operation for the second candidate partition.
19 . A method comprising:
identifying, from among N possible partitions for a block compression 7 (BC7) block of texture data, M candidate partitions, M<N, based at least in part on gradient calculations in at least two directions relative to the block;
identifying a first candidate partition of the M candidate partitions based on extents of pixels in the block;
using the first candidate partition of the M candidate partitions to process the block of texture data for transmission thereof and decompression at a rendering device to render images; and
reusing at least a first calculation from the first candidate partition in calculating at least one operation of a second candidate partition of the M candidate partitions.