Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Integrate GPU memory mapping using adrenotools_mem_gpu_allocate and a…" #31

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions app/src/main/cpp/skyline/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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<void**>(&userMappingHandle)
reinterpret_cast<void**>(&userMappingHandle) // Use reinterpret_cast to pass as void**
);

// Cast the userMappingHandle back to adrenotools_gpu_mapping*
if (libvulkanHandle) {
mapping = reinterpret_cast<adrenotools_gpu_mapping*>(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 : "");
}
Expand All @@ -388,24 +378,15 @@ namespace skyline::gpu {
nullptr,
nullptr,
(state.os->publicAppFilesPath + "gpu/vk_file_redirect/").c_str(),
reinterpret_cast<void**>(&userMappingHandle)
reinterpret_cast<void**>(&userMappingHandle) // Use reinterpret_cast for user mapping handle
);

// Cast the userMappingHandle back to adrenotools_gpu_mapping*
if (libvulkanHandle) {
mapping = reinterpret_cast<adrenotools_gpu_mapping*>(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 : "");
}
Expand All @@ -417,7 +398,6 @@ namespace skyline::gpu {
}



GPU::GPU(const DeviceState &state)
: state(state),
vkContext(LoadVulkanDriver(state, &adrenotoolsImportMapping)),
Expand Down
Loading