diff --git a/.pick_status.json b/.pick_status.json index e5a1adcdd97..2f428991efa 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4,7 +4,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/layers/radv_rage2.c b/src/amd/vulkan/layers/radv_rage2.c new file mode 100644 index 00000000000..036bd9bfff3 --- /dev/null +++ b/src/amd/vulkan/layers/radv_rage2.c @@ -0,0 +1,56 @@ +/* + * 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); + RADV_FROM_HANDLE(radv_cmd_buffer, cmd_buffer, commandBuffer); + struct radv_device *device = cmd_buffer->device; + + 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; + + device->layer_dispatch.app.CmdBeginRenderPass(commandBuffer, &render_pass_begin, contents); +} diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index 7f0bcfa102a..d7cd1f0d039 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -34,6 +34,7 @@ radv_entrypoints_gen_command += [ # Application layer entrypoints '--device-prefix', 'metro_exodus', + '--device-prefix', 'rage2', ] radv_entrypoints = custom_target( @@ -47,6 +48,7 @@ radv_entrypoints = custom_target( libradv_files = files( 'bvh/bvh.h', 'layers/radv_metro_exodus.c', + 'layers/radv_rage2.c', 'layers/radv_rmv_layer.c', 'layers/radv_rra_layer.c', 'layers/radv_sqtt_layer.c', diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index b57dae0a08d..3131bb3d4c5 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3650,8 +3650,11 @@ init_dispatch_tables(struct radv_device *device, struct radv_physical_device *ph b.tables[RADV_RRA_DISPATCH_TABLE] = &device->layer_dispatch.rra; b.tables[RADV_RMV_DISPATCH_TABLE] = &device->layer_dispatch.rmv; - if (!strcmp(physical_device->instance->app_layer, "metroexodus")) + if (!strcmp(physical_device->instance->app_layer, "metroexodus")) { add_entrypoints(&b, &metro_exodus_device_entrypoints, RADV_APP_DISPATCH_TABLE); + } else if (!strcmp(physical_device->instance->app_layer, "rage2")) { + add_entrypoints(&b, &rage2_device_entrypoints, RADV_APP_DISPATCH_TABLE); + } if (radv_thread_trace_enabled()) add_entrypoints(&b, &sqtt_device_entrypoints, RADV_RGP_DISPATCH_TABLE); diff --git a/src/util/00-radv-defaults.conf b/src/util/00-radv-defaults.conf index 68717c5ee31..180067215ec 100644 --- a/src/util/00-radv-defaults.conf +++ b/src/util/00-radv-defaults.conf @@ -75,6 +75,7 @@ Application bugs worked around in this file: