You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error increases when BC_FLAGS_USE_3SUBSETS flag is specified #92
When I call DirectX::D3DXEncodeBC7() with DirectX::BC_FLAGS_USE_3SUBSETS, the overall output error increases. This is incorrect: the overall error should decrease. As far as I can tell this is a bug and could be indicative of a deeper issue with this encoder. By comparison, ispc_texcomp does not exhibit this behavior:
Ok, the bug is caused by D3DX_BC7::Refine() not correctly computing the block error in a way that factors in the actual coded pbits. It computes the error using the endpoints before the LSB's are slammed to the pbits, causing the encoder to choose blocks that actually increase error. This will wreck quality in many modes.
I've attached a simple fix which introduces a new helper function D3DX_BC7::FixEndpointPBits(), which Refine() calls after it computes new endpoints. It could be easily improved further for more gains (it doesn't round the component values correctly factoring in the pbits), but it's definitely far better than what's there which is broken. I don't use git often but if you want I can submit a PR.
With this single fix applied the encoding quality across my test corpus increased from 44.25 to 46.02 with 3 subsets enabled, and 45.64 with 3 subsets disabled. (My encoder and ispc_texcomp get >46.5 dB with 3 subsets enabled, so this isn't that bad now.) This fix boosts the encoder's default (2 subset modes only) quality above what it was previously capable of using 3 subset modes.
Activity
richgel999 commentedon Apr 24, 2018
Ok, the bug is caused by D3DX_BC7::Refine() not correctly computing the block error in a way that factors in the actual coded pbits. It computes the error using the endpoints before the LSB's are slammed to the pbits, causing the encoder to choose blocks that actually increase error. This will wreck quality in many modes.
I've attached a simple fix which introduces a new helper function D3DX_BC7::FixEndpointPBits(), which Refine() calls after it computes new endpoints. It could be easily improved further for more gains (it doesn't round the component values correctly factoring in the pbits), but it's definitely far better than what's there which is broken. I don't use git often but if you want I can submit a PR.
With this single fix applied the encoding quality across my test corpus increased from 44.25 to 46.02 with 3 subsets enabled, and 45.64 with 3 subsets disabled. (My encoder and ispc_texcomp get >46.5 dB with 3 subsets enabled, so this isn't that bad now.) This fix boosts the encoder's default (2 subset modes only) quality above what it was previously capable of using 3 subset modes.
BC6HBC7.zip
walbourn commentedon Apr 24, 2018
Please submit it as a pull request. Thanks!
walbourn commentedon May 10, 2018
See this pull request
walbourn commentedon Jul 4, 2018
Fixed this specific issue in this commit