Skip to content

Instantly share code, notes, and snippets.

@gwihlidal
Last active March 16, 2023 09:35
Show Gist options
  • Select an option

  • Save gwihlidal/ad83a0979eb33bbe5556a01904ddf2e5 to your computer and use it in GitHub Desktop.

Select an option

Save gwihlidal/ad83a0979eb33bbe5556a01904ddf2e5 to your computer and use it in GitHub Desktop.

Revisions

  1. gwihlidal revised this gist Apr 30, 2018. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions NegativeViewportHeight.cpp
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,10 @@
    // Unlike the original AMD extension which just negated height.

    VkViewport viewport = {};
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.height = -drawState->viewport.height;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
  2. gwihlidal revised this gist Apr 30, 2018. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions NegativeViewportHeight.cpp
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,10 @@
    // Unlike the original AMD extension which just negated height.

    VkViewport viewport = {};
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.height = -drawState->viewport.height;
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.height = -drawState->viewport.height;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
  3. gwihlidal revised this gist Apr 30, 2018. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions NegativeViewportHeight.cpp
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,10 @@
    // Unlike the original AMD extension which just negated height.

    VkViewport viewport = {};
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.height = -drawState->viewport.height;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    viewport.height = -drawState->viewport.height;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
  4. gwihlidal revised this gist Apr 30, 2018. No changes.
  5. gwihlidal created this gist Apr 30, 2018.
    17 changes: 17 additions & 0 deletions NegativeViewportHeight.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    // With the VK_KHR_maintenance1 extension, you can specify negative viewport height.
    // This allows negative height to be specified in the height field to perform a
    // y-inversion of the clip-space to framebuffer-space transform. This allows you
    // to avoid having to use gl_Position.y = -gl_Position.y, and makes porting to other
    // APIs like DirectX12 much easier.

    // You negate the height *and* move the "origin" to the bottom left.
    // Unlike the original AMD extension which just negated height.

    VkViewport viewport = {};
    viewport.x = drawState->viewport.x;
    viewport.y = drawState->viewport.height - drawState->viewport.y;
    viewport.width = drawState->viewport.width;
    viewport.height = -drawState->viewport.height;
    viewport.minDepth = drawState->viewport.minZ;
    viewport.maxDepth = drawState->viewport.maxZ;
    vkCmdSetViewport(commandBuffer, 0, 1, &viewport);