mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-26 04:11:36 +00:00
Force triangle strip workaround for AMD GPUs. (#659)
This commit is contained in:
parent
8915b06a95
commit
34a23d48db
1 changed files with 10 additions and 14 deletions
|
|
@ -285,7 +285,7 @@ static bool g_vulkan = false;
|
||||||
static constexpr bool g_vulkan = true;
|
static constexpr bool g_vulkan = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool g_mesaTriangleStripWorkaround = false;
|
static bool g_triangleStripWorkaround = false;
|
||||||
|
|
||||||
static constexpr bool g_hardwareResolve = true;
|
static constexpr bool g_hardwareResolve = true;
|
||||||
static constexpr bool g_hardwareDepthResolve = true;
|
static constexpr bool g_hardwareDepthResolve = true;
|
||||||
|
|
@ -1702,13 +1702,9 @@ bool Video::CreateHostDevice(const char *sdlVideoDriver)
|
||||||
|
|
||||||
g_vulkan = (interfaceFunction == CreateVulkanInterfaceWrapper);
|
g_vulkan = (interfaceFunction == CreateVulkanInterfaceWrapper);
|
||||||
#endif
|
#endif
|
||||||
|
// Enable triangle strip workaround if we are on AMD, as there is a bug where
|
||||||
if (interfaceFunction == CreateVulkanInterfaceWrapper)
|
// restart indices cause triangles to be culled incorrectly. Converting them to degenerate triangles fixes it.
|
||||||
{
|
g_triangleStripWorkaround = (deviceDescription.vendor == RenderDeviceVendor::AMD);
|
||||||
// Enable triangle strip workaround if we are on the Mesa RADV driver, as it currently has a bug where
|
|
||||||
// restart indices cause triangles to be culled incorrectly. Converting them to degenerate triangles fixes it.
|
|
||||||
g_mesaTriangleStripWorkaround = deviceDescription.name.find(" (RADV ") != std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -2329,7 +2325,7 @@ static void DrawProfiler()
|
||||||
ImGui::Text("Present Wait: %s", g_capabilities.presentWait ? "Supported" : "Unsupported");
|
ImGui::Text("Present Wait: %s", g_capabilities.presentWait ? "Supported" : "Unsupported");
|
||||||
ImGui::Text("Triangle Fan: %s", g_capabilities.triangleFan ? "Supported" : "Unsupported");
|
ImGui::Text("Triangle Fan: %s", g_capabilities.triangleFan ? "Supported" : "Unsupported");
|
||||||
ImGui::Text("Dynamic Depth Bias: %s", g_capabilities.dynamicDepthBias ? "Supported" : "Unsupported");
|
ImGui::Text("Dynamic Depth Bias: %s", g_capabilities.dynamicDepthBias ? "Supported" : "Unsupported");
|
||||||
ImGui::Text("Triangle Strip Workaround: %s", g_mesaTriangleStripWorkaround ? "Enabled" : "Disabled");
|
ImGui::Text("Triangle Strip Workaround: %s", g_triangleStripWorkaround ? "Enabled" : "Disabled");
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
ImGui::Text("API: %s", g_vulkan ? "Vulkan" : "D3D12");
|
ImGui::Text("API: %s", g_vulkan ? "Vulkan" : "D3D12");
|
||||||
|
|
@ -7428,8 +7424,8 @@ bool FxShadowMapMidAsmHook(PPCRegister& r4, PPCRegister& r5, PPCRegister& r6, PP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// There is a driver bug on Mesa where restart indices cause incorrect culling and prevent some triangles from being rendered.
|
// There is a bug on AMD where restart indices cause incorrect culling and prevent some triangles from being rendered.
|
||||||
// Restart indices can be converted to degenerate triangles as a workaround until this issue gets fixed.
|
// This seems to happen on both Windows AMD drivers and Mesa. Converting restart indices to degenerate triangles fixes it.
|
||||||
static void ConvertToDegenerateTriangles(uint16_t* indices, uint32_t indexCount, uint16_t*& newIndices, uint32_t& newIndexCount)
|
static void ConvertToDegenerateTriangles(uint16_t* indices, uint32_t indexCount, uint16_t*& newIndices, uint32_t& newIndexCount)
|
||||||
{
|
{
|
||||||
newIndices = reinterpret_cast<uint16_t*>(g_userHeap.Alloc(indexCount * sizeof(uint16_t) * 3));
|
newIndices = reinterpret_cast<uint16_t*>(g_userHeap.Alloc(indexCount * sizeof(uint16_t) * 3));
|
||||||
|
|
@ -7482,7 +7478,7 @@ PPC_FUNC(sub_82E44AF8)
|
||||||
uint16_t* newIndicesToFree = nullptr;
|
uint16_t* newIndicesToFree = nullptr;
|
||||||
|
|
||||||
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
||||||
if (g_mesaTriangleStripWorkaround && !databaseData->IsMadeOne())
|
if (g_triangleStripWorkaround && !databaseData->IsMadeOne())
|
||||||
{
|
{
|
||||||
auto meshResource = reinterpret_cast<MeshResource*>(base + ctx.r4.u32);
|
auto meshResource = reinterpret_cast<MeshResource*>(base + ctx.r4.u32);
|
||||||
|
|
||||||
|
|
@ -7545,7 +7541,7 @@ PPC_FUNC(sub_82E3AFC8)
|
||||||
uint16_t* newIndices = nullptr;
|
uint16_t* newIndices = nullptr;
|
||||||
|
|
||||||
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
||||||
if (g_mesaTriangleStripWorkaround && !databaseData->IsMadeOne())
|
if (g_triangleStripWorkaround && !databaseData->IsMadeOne())
|
||||||
{
|
{
|
||||||
auto lightAndIndexBufferResource = reinterpret_cast<LightAndIndexBufferResourceV1*>(base + ctx.r4.u32);
|
auto lightAndIndexBufferResource = reinterpret_cast<LightAndIndexBufferResourceV1*>(base + ctx.r4.u32);
|
||||||
|
|
||||||
|
|
@ -7584,7 +7580,7 @@ PPC_FUNC(sub_82E3B1C0)
|
||||||
uint16_t* newIndices = nullptr;
|
uint16_t* newIndices = nullptr;
|
||||||
|
|
||||||
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
auto databaseData = reinterpret_cast<Hedgehog::Database::CDatabaseData*>(base + ctx.r3.u32);
|
||||||
if (g_mesaTriangleStripWorkaround && !databaseData->IsMadeOne())
|
if (g_triangleStripWorkaround && !databaseData->IsMadeOne())
|
||||||
{
|
{
|
||||||
auto lightAndIndexBufferResource = reinterpret_cast<LightAndIndexBufferResourceV5*>(base + ctx.r4.u32);
|
auto lightAndIndexBufferResource = reinterpret_cast<LightAndIndexBufferResourceV5*>(base + ctx.r4.u32);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue