← 输入框|github.com|刷新
Skip to content

Consider associating the texture with its clear color value #284

Closed

Description

@kvark

We could consider having the clear color to be a part of the TextureDescriptor. Justification:

  1. D3D12 specifically has this specified at resource creation and I vaguely recall this matching some of the specifics of AMD hardware (but need to investigate more to confirm this).
  2. it's not a common thing to vary the clear color for a particular texture.
  3. straightforward clear operation (in RenderPassDescriptor) just being an enum of "clear"/"load" (related to Consolidate *loadOp and clear* into a unioned field #283 and Optional clear values #276).
  4. we could still provide an API for clearing with custom values, perhaps as a simple clearImage that is performed out of the pass, or clearAttachment within a pass.

Activity

  1. kdashg commented on May 8, 2019

    @kdashg
    Contributor

    This could be cool. Would we make RenderPassDesc.clearColor nullable, or just ask users to try to match the TextureDesc.clearColor and RenderPassDesc.clearColor?

  2. kvark commented on May 8, 2019

    @kvark
    ContributorAuthor

    I think we wouldn't have RenderPassDesc.clearColor at all. If the user decides they need to clear a render target with a different color, we can either:

    • ask them to call CommandEncoder.clearImage() that has a color parameter
    • ask them to call RenderPassEncoder.clearAttachment() that has a color parameter
    • or ask them to just draw a quad :P
  3. magcius commented on May 8, 2019

    @magcius

    The reason for the "clear color" on the texture is for fast clear semantics. The idea is that framebuffer compression likely has a few colors it can associate with "cleared target", and a clear will mark it as that value. Not all framebuffer compression can have more than one "fast clear" color (NVIDIA can support multiple, AMD can only support one, not sure about other GPUs), and some do not allow making fast clear customizable, hardcoding to either transparent or opaque black. They rely on users either marking loads as DONT_CARE, or setting their clear color to the one they support.

    I can't remember if there's a way to get the "preferred clear color" for a render target in Vulkan. If there was, I would suggest exposing that, though it might be unpredictable across platforms.

  4. kainino0x commented on Jul 22, 2019

    @kainino0x
    Contributor

    For the record, though we just merged #283, this may end up overriding that change.

  5. kainino0x commented on Jul 22, 2019

    @kainino0x
    Contributor

    @kvark maybe we could put this on the agenda for next meeting? Since the topic is relatively fresh in our minds.

  6. kvark commented on Jul 23, 2019

    @kvark
    ContributorAuthor

    @kainino0x sure, let's talk about this a bit next time. The change was initially motivated as a solution to clear value specification that we were discussing. Now there is less of an appeal, but it could still be useful, as long as we explicitly design it for fast clears.

  7. kainino0x commented on Jul 24, 2019

    @kainino0x
    Contributor

    Yeah, it makes a lot of sense to me especially since D3D12 already exposes pOptimizedClearValue, and if we ever want to add clear color to RenderPassDescriptor, it would be a nonbreaking change. (Of course, having it there and adding it here later would also be nonbreaking.)

  8. kainino0x commented on Feb 14, 2020

    @kainino0x
    Contributor

    (F2F) Direct from the D3D12 team: "Don't do this." Closed!

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

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