From 8dbf1e42f41c797f64cacf2d2f3497d8979b4b36 Mon Sep 17 00:00:00 2001 From: Ishan09811 <156402647+Ishan09811@users.noreply.github.com> Date: Sun, 6 Oct 2024 01:23:48 +0530 Subject: [PATCH] =?UTF-8?q?Revert=20"Integrate=20GPU=20memory=20mapping=20?= =?UTF-8?q?using=20adrenotools=5Fmem=5Fgpu=5Fallocate=20and=20a=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 3fdef75d032a47225021da4b1bc8ec55f3922c30. --- app/src/main/cpp/skyline/gpu.cpp | 38 ++++++++------------------------ 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu.cpp b/app/src/main/cpp/skyline/gpu.cpp index e25f6027..07ff48ae 100644 --- a/app/src/main/cpp/skyline/gpu.cpp +++ b/app/src/main/cpp/skyline/gpu.cpp @@ -343,8 +343,7 @@ namespace skyline::gpu { static PFN_vkGetInstanceProcAddr LoadVulkanDriver(const DeviceState &state, adrenotools_gpu_mapping *mapping) { void *libvulkanHandle{}; - void *userMappingHandle = nullptr; - uint64_t gpuMemSize = 0; + void *userMappingHandle = nullptr; // New void* pointer for user mapping handle // If the user has selected a custom driver, try to load it if (!(*state.settings->gpuDriver).empty()) { @@ -356,24 +355,15 @@ namespace skyline::gpu { (state.os->privateAppFilesPath + "gpu_drivers/" + *state.settings->gpuDriver + "/").c_str(), (*state.settings->gpuDriverLibraryName).c_str(), (state.os->publicAppFilesPath + "gpu/vk_file_redirect/").c_str(), - reinterpret_cast(&userMappingHandle) + reinterpret_cast(&userMappingHandle) // Use reinterpret_cast to pass as void** ); + // Cast the userMappingHandle back to adrenotools_gpu_mapping* if (libvulkanHandle) { mapping = reinterpret_cast(userMappingHandle); + } - // GPU memory allocation - if (!adrenotools_mem_gpu_allocate(userMappingHandle, &gpuMemSize)) { - LOGW("Failed to allocate GPU memory."); - return nullptr; - } - - // CPU-side memory mapping - if (!adrenotools_mem_cpu_map(userMappingHandle, mapping->host_ptr, gpuMemSize)) { - LOGW("Failed to map GPU memory to CPU."); - return nullptr; - } - } else { + if (!libvulkanHandle) { char *error = dlerror(); LOGW("Failed to load custom Vulkan driver {}/{}: {}", *state.settings->gpuDriver, *state.settings->gpuDriverLibraryName, error ? error : ""); } @@ -388,24 +378,15 @@ namespace skyline::gpu { nullptr, nullptr, (state.os->publicAppFilesPath + "gpu/vk_file_redirect/").c_str(), - reinterpret_cast(&userMappingHandle) + reinterpret_cast(&userMappingHandle) // Use reinterpret_cast for user mapping handle ); + // Cast the userMappingHandle back to adrenotools_gpu_mapping* if (libvulkanHandle) { mapping = reinterpret_cast(userMappingHandle); + } - // GPU memory allocation - if (!adrenotools_mem_gpu_allocate(userMappingHandle, &gpuMemSize)) { - LOGW("Failed to allocate GPU memory."); - return nullptr; - } - - // CPU-side memory mapping - if (!adrenotools_mem_cpu_map(userMappingHandle, mapping->host_ptr, gpuMemSize)) { - LOGW("Failed to map GPU memory to CPU."); - return nullptr; - } - } else { + if (!libvulkanHandle) { char *error = dlerror(); LOGW("Failed to load builtin Vulkan driver: {}", error ? error : ""); } @@ -417,7 +398,6 @@ namespace skyline::gpu { } - GPU::GPU(const DeviceState &state) : state(state), vkContext(LoadVulkanDriver(state, &adrenotoolsImportMapping)),