mirror of
https://github.com/Liondarkz/issn_pc.git
synced 2026-11-07 12:47:50 -10:00
- Caminhos e conteúdo: GOW3_ -> ISSN_, Gow3 -> Issn, gow3 -> issn, tags "gow3:" -> "port:". Créditos e links ao gow3_pc (Felipe Prado) mantidos; a documentação herdada do port do God of War III foi para docs/base/. - run.py aceita as variáveis GOW3_ antigas (viram ISSN_ quando a nova não está definida). - build.sh: se o patch antigo do fsr-vulkan já estiver aplicado no submódulo, volta ao commit fixado e aplica o novo. - Menu do jogo: os cheats do God of War III só aparecem quando algum é suportado. - Launcher 0.2.0: tema novo, seção inFAMOUS (Efeitos, prioridade do compute, distância de detalhe), "Salvar relatório de bug", sem os cheats do GoW3, atualização pelos releases deste repositório (silenciosa enquanto ele for privado), traduções em português. - README-Windows: 0.2.0 e novidades. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XzE465ySHDfaMBVSJyYtNw
104 lines
3.8 KiB
C++
104 lines
3.8 KiB
C++
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
#include <cstdlib>
|
|
#include <cstdio>
|
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
|
|
|
// Keep the dispatcher's ABI consistent with the renderer library.
|
|
#undef NDEBUG
|
|
#include <cassert>
|
|
|
|
namespace Vulkan {
|
|
bool InitializePipelineBinaryCache(vk::Device device, bool supported,
|
|
vk::PipelineBinaryKeyKHR& global_key);
|
|
}
|
|
|
|
namespace {
|
|
unsigned key_queries{};
|
|
VkResult key_result = VK_SUCCESS;
|
|
uint32_t key_size = 2;
|
|
|
|
void SetCache(const char* value) {
|
|
#ifdef _WIN32
|
|
_putenv_s("ISSN_PIPELINE_BINARIES", value);
|
|
#else
|
|
if (*value) setenv("ISSN_PIPELINE_BINARIES", value, 1);
|
|
else unsetenv("ISSN_PIPELINE_BINARIES");
|
|
#endif
|
|
}
|
|
|
|
VKAPI_ATTR VkResult VKAPI_CALL GetKey(VkDevice, const VkPipelineCreateInfoKHR* info,
|
|
VkPipelineBinaryKeyKHR* key) {
|
|
assert(!info);
|
|
++key_queries;
|
|
key->keySize = key_size;
|
|
key->key[0] = 7;
|
|
return key_result;
|
|
}
|
|
|
|
void TestFallbacks() {
|
|
auto& dispatch = VULKAN_HPP_DEFAULT_DISPATCHER;
|
|
const auto original = dispatch;
|
|
dispatch.vkGetPipelineKeyKHR = GetKey;
|
|
dispatch.vkCreatePipelineBinariesKHR = [](VkDevice, const VkPipelineBinaryCreateInfoKHR*,
|
|
const VkAllocationCallbacks*, VkPipelineBinaryHandlesInfoKHR*) -> VkResult {
|
|
std::abort();
|
|
};
|
|
dispatch.vkGetPipelineBinaryDataKHR = [](VkDevice, const VkPipelineBinaryDataInfoKHR*,
|
|
VkPipelineBinaryKeyKHR*, size_t*, void*) -> VkResult { std::abort(); };
|
|
dispatch.vkDestroyPipelineBinaryKHR = [](VkDevice, VkPipelineBinaryKHR,
|
|
const VkAllocationCallbacks*) { std::abort(); };
|
|
dispatch.vkReleaseCapturedPipelineDataKHR = [](VkDevice,
|
|
const VkReleaseCapturedPipelineDataInfoKHR*, const VkAllocationCallbacks*) -> VkResult {
|
|
std::abort();
|
|
};
|
|
const vk::Device device{reinterpret_cast<VkDevice>(uintptr_t{1})};
|
|
vk::PipelineBinaryKeyKHR key{.keySize = 2};
|
|
SetCache("0");
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 0 && key.keySize == 0);
|
|
|
|
SetCache("1");
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, false, key));
|
|
assert(key_queries == 0 && key.keySize == 0);
|
|
|
|
const auto get_data = dispatch.vkGetPipelineBinaryDataKHR;
|
|
dispatch.vkGetPipelineBinaryDataKHR = nullptr;
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 0 && key.keySize == 0);
|
|
dispatch.vkGetPipelineBinaryDataKHR = get_data;
|
|
|
|
key_result = VK_ERROR_UNKNOWN;
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 1 && key.keySize == 0);
|
|
|
|
key_result = VK_SUCCESS;
|
|
key_size = 0;
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 2 && key.keySize == 0);
|
|
|
|
key_size = VK_MAX_PIPELINE_BINARY_KEY_SIZE_KHR + 1;
|
|
assert(!Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 3 && key.keySize == 0);
|
|
|
|
SetCache("");
|
|
key_size = VK_MAX_PIPELINE_BINARY_KEY_SIZE_KHR;
|
|
assert(Vulkan::InitializePipelineBinaryCache(device, true, key));
|
|
assert(key_queries == 4 && key.keySize == key_size && key.key[0] == 7);
|
|
dispatch = original;
|
|
}
|
|
}
|
|
|
|
int main(int argc, char**) {
|
|
const bool enabled = argc > 1;
|
|
SetCache(enabled ? "1" : "0");
|
|
Vulkan::Instance instance{s32{-1}, false};
|
|
if (!enabled && instance.GetPipelineBinaryGlobalKey().keySize != 0) {
|
|
std::fputs("FAIL: disabled binary cache initialized a global key\n", stderr);
|
|
return 1;
|
|
}
|
|
std::printf("Real device: binary cache %s, global key size %u\n",
|
|
enabled ? "requested" : "disabled", instance.GetPipelineBinaryGlobalKey().keySize);
|
|
TestFallbacks();
|
|
std::puts("pipeline-binary-initialization-test: passed");
|
|
}
|