[PR #1857] [MERGED] renderer_vulkan: Implement rectlist emulation with tessellation #2351

Closed
opened 2026-02-27 21:16:10 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/1857
Author: @raphaelthegreat
Created: 12/23/2024
Status: Merged
Merged: 12/24/2024
Merged by: @raphaelthegreat

Base: mainHead: rectlist-tess


📝 Commits (8)

  • 3485a30 renderer_vulkan: Implement rectlist emulation with tessellation
  • 0925d58 clang format
  • cff8124 renderer_vulkan: Use tessellation for quad primitive as well
  • 7366c9a vk_rasterizer: Handle viewport enable flags
  • df4613a review
  • 9a183f4 shader_recompiler: Fix quad/rect list FS passthrough semantics.
  • a00d077 spirv: Bump to 1.5
  • 5699888 remove pragma

📊 Changes

15 files changed (+426 additions, -123 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 src/common/io_file.h (+1 -1)
📝 src/shader_recompiler/backend/spirv/emit_spirv.cpp (+1 -0)
src/shader_recompiler/backend/spirv/emit_spirv_quad_rect.cpp (+329 -0)
src/shader_recompiler/backend/spirv/emit_spirv_quad_rect.h (+24 -0)
📝 src/shader_recompiler/runtime_info.h (+1 -1)
📝 src/video_core/buffer_cache/buffer_cache.cpp (+2 -45)
📝 src/video_core/renderer_vulkan/liverpool_to_vk.cpp (+2 -2)
📝 src/video_core/renderer_vulkan/liverpool_to_vk.h (+0 -28)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp (+34 -17)
📝 src/video_core/renderer_vulkan/vk_graphics_pipeline.h (+2 -6)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.cpp (+6 -5)
📝 src/video_core/renderer_vulkan/vk_pipeline_cache.h (+2 -1)
📝 src/video_core/renderer_vulkan/vk_rasterizer.cpp (+16 -17)
📝 src/video_core/renderer_vulkan/vk_shader_util.cpp (+4 -0)

📄 Description

RectLists are a primitive types that renders a quad, given only 3 vertices, by interpolating the fourth one. There is no similar primitive provided by the vulkan API, so we have to emulate it. On main this is a bit of a hack, where we change it to either TriangleStrip/TriangleFan and adjust the number of drawn vertices.

For this to work however, several assumptions must be true. The shader must auto-generate the vertices (no vertex buffer bound), it must also generate a proper fourth vertex to form a quad and only draw 1 quad. These requirements often are true, but not always. And even if they are, sometimes it still doesn't render properly due to changes in ordering.

In this PR we remove the hacks and implement RectList primitive using auxiliary tessellation shaders. The interpolation method is referenced from GRVK: github.com/libcg/grvk@03d43a5a/src/amdilc/amdilc_rect_gs_compiler.c (L141)

Most existing implementations use a geometry shader for this, but we opted not to for several reasons. Firstly macos doesn't support geoshaders and thus would not be able to benefit, while tessellation shaders should be supported. Also tessellation shaders will work in all cases of RectList usage without interfering with pipeline. It is possible for guest to configure RectLists together with a guest geometry shaders, which would break if we had to insert our own geometry shader. Using tessellation requires patch primitive type instead, so this problem doesn't exist.

Should fix cases of poking triangles in the screen.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/1857 **Author:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Created:** 12/23/2024 **Status:** ✅ Merged **Merged:** 12/24/2024 **Merged by:** [@raphaelthegreat](https://github.com/raphaelthegreat) **Base:** `main` ← **Head:** `rectlist-tess` --- ### 📝 Commits (8) - [`3485a30`](https://github.com/shadps4-emu/shadPS4/commit/3485a30337d996be50eda0f66b7d6edfc02adc96) renderer_vulkan: Implement rectlist emulation with tessellation - [`0925d58`](https://github.com/shadps4-emu/shadPS4/commit/0925d58924a6abde8f5167c40db7f0c4e73ae18a) clang format - [`cff8124`](https://github.com/shadps4-emu/shadPS4/commit/cff8124943e8b67fa54b02ee532d38db87d8edeb) renderer_vulkan: Use tessellation for quad primitive as well - [`7366c9a`](https://github.com/shadps4-emu/shadPS4/commit/7366c9af416dd7ca96a704d26670db028c8bf507) vk_rasterizer: Handle viewport enable flags - [`df4613a`](https://github.com/shadps4-emu/shadPS4/commit/df4613a82e3fe06e97bac53a2d35ce35e7f7429c) review - [`9a183f4`](https://github.com/shadps4-emu/shadPS4/commit/9a183f482022dbc6a8800b1b27fff13e71e5f3f8) shader_recompiler: Fix quad/rect list FS passthrough semantics. - [`a00d077`](https://github.com/shadps4-emu/shadPS4/commit/a00d077447fc0a1d2c6f18e5934c759b2b0c1ae1) spirv: Bump to 1.5 - [`5699888`](https://github.com/shadps4-emu/shadPS4/commit/56998887c6332a938d29d0c85e72695326cde016) remove pragma ### 📊 Changes **15 files changed** (+426 additions, -123 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `src/common/io_file.h` (+1 -1) 📝 `src/shader_recompiler/backend/spirv/emit_spirv.cpp` (+1 -0) ➕ `src/shader_recompiler/backend/spirv/emit_spirv_quad_rect.cpp` (+329 -0) ➕ `src/shader_recompiler/backend/spirv/emit_spirv_quad_rect.h` (+24 -0) 📝 `src/shader_recompiler/runtime_info.h` (+1 -1) 📝 `src/video_core/buffer_cache/buffer_cache.cpp` (+2 -45) 📝 `src/video_core/renderer_vulkan/liverpool_to_vk.cpp` (+2 -2) 📝 `src/video_core/renderer_vulkan/liverpool_to_vk.h` (+0 -28) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp` (+34 -17) 📝 `src/video_core/renderer_vulkan/vk_graphics_pipeline.h` (+2 -6) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.cpp` (+6 -5) 📝 `src/video_core/renderer_vulkan/vk_pipeline_cache.h` (+2 -1) 📝 `src/video_core/renderer_vulkan/vk_rasterizer.cpp` (+16 -17) 📝 `src/video_core/renderer_vulkan/vk_shader_util.cpp` (+4 -0) </details> ### 📄 Description RectLists are a primitive types that renders a quad, given only 3 vertices, by interpolating the fourth one. There is no similar primitive provided by the vulkan API, so we have to emulate it. On main this is a bit of a hack, where we change it to either TriangleStrip/TriangleFan and adjust the number of drawn vertices. For this to work however, several assumptions must be true. The shader must auto-generate the vertices (no vertex buffer bound), it must also generate a proper fourth vertex to form a quad and only draw 1 quad. These requirements often are true, but not always. And even if they are, sometimes it still doesn't render properly due to changes in ordering. In this PR we remove the hacks and implement RectList primitive using auxiliary tessellation shaders. The interpolation method is referenced from GRVK: https://github.com/libcg/grvk/blob/03d43a5a/src/amdilc/amdilc_rect_gs_compiler.c#L141 Most existing implementations use a geometry shader for this, but we opted not to for several reasons. Firstly macos doesn't support geoshaders and thus would not be able to benefit, while tessellation shaders should be supported. Also tessellation shaders will work in all cases of RectList usage without interfering with pipeline. It is possible for guest to configure RectLists together with a guest geometry shaders, which would break if we had to insert our own geometry shader. Using tessellation requires patch primitive type instead, so this problem doesn't exist. Should fix cases of poking triangles in the screen. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 21:16:10 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#2351
No description provided.