Skip to content

Error increases when BC_FLAGS_USE_3SUBSETS flag is specified #92

Closed

Description

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:

More info

Activity

  1. richgel999 commented on Apr 24, 2018

    @richgel999
    Author

    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

  2. walbourn commented on Apr 24, 2018

    @walbourn
    Collaborator

    Please submit it as a pull request. Thanks!

  3. walbourn commented on May 10, 2018

    @walbourn
    Collaborator
  4. walbourn commented on Jul 4, 2018

    @walbourn
    Collaborator

    Fixed this specific issue in this commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bcRelated to DirectX Block Compressionbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions