From ba89826b750512b6ad0691fc2f970ae740e9ca52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tapani=20P=C3=A4lli?= Date: Wed, 12 Nov 2025 09:05:01 +0200 Subject: [PATCH] anv: add furmark workaround layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14274 Signed-off-by: Tapani Pälli Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/vulkan/anv_device.c | 9 ++++ src/intel/vulkan/layers/anv_furmark.c | 61 +++++++++++++++++++++++++++ src/intel/vulkan/meson.build | 2 + 3 files changed, 72 insertions(+) create mode 100644 src/intel/vulkan/layers/anv_furmark.c diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 542aadf5fde..1d8d02b275a 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -355,6 +355,15 @@ VkResult anv_CreateDevice( true); override_initial_entrypoints = false; } + + if (physical_device->info.ver < 12 && + physical_device->instance->vk.app_info.app_name && + !strcmp(physical_device->instance->vk.app_info.app_name, "GeeXLab")) { + vk_device_dispatch_table_from_entrypoints(&dispatch_table, + &anv_furmark_device_entrypoints, + true); + override_initial_entrypoints = false; + } #if DETECT_OS_ANDROID vk_device_dispatch_table_from_entrypoints(&dispatch_table, &anv_android_device_entrypoints, diff --git a/src/intel/vulkan/layers/anv_furmark.c b/src/intel/vulkan/layers/anv_furmark.c new file mode 100644 index 00000000000..57d23a48f25 --- /dev/null +++ b/src/intel/vulkan/layers/anv_furmark.c @@ -0,0 +1,61 @@ +/* + * Copyright © 2025 Intel 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 "anv_private.h" +#include "vk_common_entrypoints.h" + +/** + * Furmark VK rendering corruption is happening because the benchmark does + * invalid layout transition. Here we override the initial layout to fix it. + */ + +void anv_furmark_CmdPipelineBarrier2( + VkCommandBuffer commandBuffer, + const VkDependencyInfo* pDependencyInfo) +{ + ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer); + const VkDependencyInfo *dep_info = pDependencyInfo; + const struct intel_device_info *devinfo = cmd_buffer->device->info; + + for (uint32_t i = 0; i < dep_info->imageMemoryBarrierCount; i++) { + VkImageMemoryBarrier2 *img_barrier = (VkImageMemoryBarrier2*) + &dep_info->pImageMemoryBarriers[i]; + VkImageLayout old_layout = img_barrier->oldLayout; + VkImageLayout new_layout = img_barrier->newLayout; + if (old_layout == VK_IMAGE_LAYOUT_UNDEFINED && + new_layout == VK_IMAGE_LAYOUT_PRESENT_SRC_KHR) { + img_barrier->oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; + } + } + + switch (devinfo->verx10) { + case 90: + gfx9_CmdPipelineBarrier2(commandBuffer, pDependencyInfo); + break; + case 110: + gfx11_CmdPipelineBarrier2(commandBuffer, pDependencyInfo); + break; + default: + UNREACHABLE("Should not happen"); + } +} diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index a9640fdd0bd..2d1cc9fdacb 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -25,6 +25,7 @@ anv_entrypoints = custom_target( '--device-prefix', 'gfx20', '--device-prefix', 'gfx30', '--device-prefix', 'anv_doom64', + '--device-prefix', 'anv_furmark', '--device-prefix', 'anv_hitman3', '--device-prefix', 'anv_android', '--device-prefix', 'anv_rmv', @@ -140,6 +141,7 @@ libanv_files = files( 'i915/anv_queue.h', 'layers/anv_android_layer.c', 'layers/anv_doom64.c', + 'layers/anv_furmark.c', 'layers/anv_hitman3.c', 'layers/anv_rmv_layer.c', 'xe/anv_batch_chain.c',