Module: Mesa Branch: staging/22.3 Commit: 78c8b6491ce1df731ed36b5860692e512205286e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=78c8b6491ce1df731ed36b5860692e512205286e
Author: Samuel Pitoiset <[email protected]> Date: Wed Jan 11 17:04:56 2023 +0100 radv: add a layer for fixing rendering issues with RAGE2 This game seems to incorrectly set the render area and since we switched to full dynamic rendering, the framebuffer dimensions is no longer used. Forcing the render area to be the framebuffer dimensions restore the previous logic and it fixes rendering issues. Fixes: c7d0d328d56 ("radv: Set the window scissor to the render area, not framebuffer") Signed-off-by: Samuel Pitoiset <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20900> (cherry picked from commit 1a93cd15563a5d0bb6faf12c5d4c852cb3534415) --- .pick_status.json | 2 +- src/amd/vulkan/00-radv-defaults.conf | 1 + src/amd/vulkan/layers/radv_rage2.c | 54 ++++++++++++++++++++++++++++++++++++ src/amd/vulkan/meson.build | 3 +- src/amd/vulkan/radv_device.c | 4 +++ 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 3153cbaf913..39ec1db16e2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -229,7 +229,7 @@ "description": "radv: add a layer for fixing rendering issues with RAGE2", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "c7d0d328d569c15c01c5830af838faac8a8b3c62" }, diff --git a/src/amd/vulkan/00-radv-defaults.conf b/src/amd/vulkan/00-radv-defaults.conf index 0ede6ef321c..712715445d3 100644 --- a/src/amd/vulkan/00-radv-defaults.conf +++ b/src/amd/vulkan/00-radv-defaults.conf @@ -71,6 +71,7 @@ Application bugs worked around in this file: <application name="RAGE 2" executable="RAGE2.exe"> <option name="radv_enable_mrt_output_nan_fixup" value="true" /> + <option name="radv_app_layer" value="rage2" /> </application> <application name="Path of Exile (64-bit, Steam)" executable="PathOfExile_x64Steam.exe"> diff --git a/src/amd/vulkan/layers/radv_rage2.c b/src/amd/vulkan/layers/radv_rage2.c new file mode 100644 index 00000000000..52438db6c26 --- /dev/null +++ b/src/amd/vulkan/layers/radv_rage2.c @@ -0,0 +1,54 @@ +/* + * Copyright © 2023 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "radv_private.h" +#include "vk_framebuffer.h" +#include "vk_common_entrypoints.h" + +VKAPI_ATTR void VKAPI_CALL +rage2_CmdBeginRenderPass(VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + VkSubpassContents contents) +{ + VK_FROM_HANDLE(vk_framebuffer, framebuffer, pRenderPassBegin->framebuffer); + + VkRenderPassBeginInfo render_pass_begin = { + .sType = pRenderPassBegin->sType, + .pNext = pRenderPassBegin->pNext, + .renderPass = pRenderPassBegin->renderPass, + .framebuffer = pRenderPassBegin->framebuffer, + .clearValueCount = pRenderPassBegin->clearValueCount, + .pClearValues = pRenderPassBegin->pClearValues, + }; + + /* RAGE2 seems to incorrectly set the render area and with dynamic rendering the concept of + * framebuffer dimensions goes away. Forcing the render area to be the framebuffer dimensions + * restores previous logic and it fixes rendering issues. + */ + render_pass_begin.renderArea.offset.x = 0; + render_pass_begin.renderArea.offset.y = 0; + render_pass_begin.renderArea.extent.width = framebuffer->width; + render_pass_begin.renderArea.extent.height = framebuffer->height; + + vk_common_CmdBeginRenderPass(commandBuffer, &render_pass_begin, contents); +} diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index ad75d68b15f..5f714bda774 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -26,7 +26,7 @@ radv_entrypoints = custom_target( prog_python, '@INPUT0@', '--xml', '@INPUT1@', '--proto', '--weak', '--out-h', '@OUTPUT0@', '--out-c', '@OUTPUT1@', '--prefix', 'radv', '--device-prefix', 'sqtt', '--device-prefix', 'metro_exodus', - '--device-prefix', 'rra', + '--device-prefix', 'rra', '--device-prefix', 'rage2', ], depend_files : vk_entrypoints_gen_depend_files, ) @@ -34,6 +34,7 @@ radv_entrypoints = custom_target( libradv_files = files( 'bvh/bvh.h', 'layers/radv_metro_exodus.c', + 'layers/radv_rage2.c', 'layers/radv_rra_layer.c', 'layers/radv_sqtt_layer.c', 'winsys/null/radv_null_bo.c', diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 17a65969b92..692d4db7b4c 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3607,6 +3607,10 @@ radv_CreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCr */ vk_device_dispatch_table_from_entrypoints(&dispatch_table, &metro_exodus_device_entrypoints, true); vk_device_dispatch_table_from_entrypoints(&dispatch_table, &radv_device_entrypoints, false); + } else if (physical_device->instance->vk.app_info.app_name && + !strcmp(physical_device->instance->vk.app_info.app_name, "rage2")) { + vk_device_dispatch_table_from_entrypoints(&dispatch_table, &rage2_device_entrypoints, true); + vk_device_dispatch_table_from_entrypoints(&dispatch_table, &radv_device_entrypoints, false); } else if (radv_thread_trace_enabled()) { vk_device_dispatch_table_from_entrypoints(&dispatch_table, &sqtt_device_entrypoints, true); vk_device_dispatch_table_from_entrypoints(&dispatch_table, &radv_device_entrypoints, false);
