Skip to content

flip_vert_y for geometry shaders does not produce expected results #2455

@sskk-y3ataka

Description

@sskk-y3ataka

The current vertex.flip_vert_y implementation adds gl_Position.y flipping at SPIRBlock::Return.

SPIRV-Cross/spirv_glsl.cpp

Lines 17911 to 17917 in 72b5b7c

case SPIRBlock::Return:
{
for (auto &line : current_function->fixup_hooks_out)
line();
if (processing_entry_point)
emit_fixup();

However, this does not affect the EmitVertex calls, so the vertices emitted in geometry shaders remain unflipped, which appears to be unintended.

Relevant issue: #1469

Small thoughts:

  • Basically we could flip Y just before every EmitVertex call to resolve this issue. However, the code may use gl_Position after the EmitVertex call (I won't write such a code though), so the modification should be rolled back immediately to maintain the original behavior.
  • For VS-GS or VS-TCS-TES (or similar) pipelines, we can refer to the gl_Position output from the previous stage. So it might be necessary to flip the input initially. However, if the geometry shader is used in isolation, flipping the input is not necessary...
    • It might be useful to add an option to specify how the input should be handled...

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