Skip to content

AttachmentBlend::Default returns a non-intuitive value #2767

@tom-leys

Description

@tom-leys

Version of vulkano

0.35.2

OS (incl. version)

Linux Pop OS

Selected physical device

NVIDIA GeForce RTX 5070

Driver (incl. version)

NVIDIA-SMI 570.172.08

Issue description

I would expect AttachmentBlend::Default (used in pipeline construction) to discard dest and overwrite src as-is. Instead it n^2 (squares) source (shader output) before writing it to texture.

If the shader returns 0.5 flat grey, the current blend will cause 0.25 to be stored into the output texture.

Instead of

fn default() -> Self {
        Self {
            src_color_blend_factor: BlendFactor::SrcColor,
            dst_color_blend_factor: BlendFactor::Zero,
            color_blend_op: BlendOp::Add,
            src_alpha_blend_factor: BlendFactor::SrcColor,
            dst_alpha_blend_factor: BlendFactor::Zero,
            alpha_blend_op: BlendOp::Add,
        }
    }

A sensible default would be

fn default() -> Self {
        Self {
                src_color_blend_factor: BlendFactor::One,
                dst_color_blend_factor: BlendFactor::Zero,
                color_blend_op: BlendOp::Add,
                src_alpha_blend_factor: BlendFactor::One,
                dst_alpha_blend_factor: BlendFactor::Zero,
                alpha_blend_op: BlendOp::Add,        
          }
    }

Minimal reproducible example

You could use the triangle example, set up the blend as default and hardcode the output of the fragment shader to always return 0.5. Then look in renderdoc at the output texture to read back the exact value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions