Skip to content

Proposal: Add KHR_DF_FLAG_OPAQUE semantic flag for opaque textures #30

@Unarmed1000

Description

@Unarmed1000

Currently, the Data Format Descriptor (DFD) supports the KHR_DF_FLAG_ALPHA_PREMULTIPLIED flag to indicate premultiplied alpha. However, there is no semantic flag to indicate that a texture is guaranteed to be fully opaque. This is particularly relevant for formats like ASTC, which can encode either opaque or transparent content depending on the encoder. Runtime engines and asset pipelines cannot reliably infer opacity from the format alone, which can lead to conservative rendering decisions or unnecessary blending operations.

Proposed Solution:
Introduce a new semantic flag in the Data Format Descriptor:

#define KHR_DF_FLAG_OPAQUE

Behavior:
Set when the texture is guaranteed to contain only opaque pixels (alpha = 1.0 for all pixels).
Mutually exclusive with KHR_DF_FLAG_ALPHA_PREMULTIPLIED and other alpha-related flags.
Optional and non-breaking; absence of the flag indicates no guarantee about opacity.

Rationale / Use Cases:

  • ASTC textures: Encoders often know that content is fully opaque but the format allows alpha. This flag communicates that guarantee.
  • Engine optimization: Renderers can skip alpha blending or enable more efficient paths.
  • Asset validation: Tools can automatically detect and enforce opaque-only usage.
  • Cross-API semantics: Provides a standardized way to communicate opacity regardless of runtime API.

Implementation Note:

  • Assign a new unique bit in the KHR_DF_FLAG enum.
  • Define interactions: setting both OPQUE and PREMULTIPLIED should be invalid.
  • No runtime decoding required; engines can rely on the flag metadata.

References:

I am not sure if this repo is the best place to do the proposal or its https://github.com/KhronosGroup/KTX-Software. so I created the proposal in both places. link

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions