Compare commits

..

1 Commits

Author SHA1 Message Date
IndecisiveTurtle 481e18a245 video_core: Some bloodborne hacks 2024-08-31 01:54:21 +03:00
4 changed files with 86 additions and 7 deletions

View File

@ -1070,7 +1070,16 @@ ScePthread PThreadPool::Create() {
} }
} }
#ifdef _WIN64
auto* ret = new PthreadInternal{}; auto* ret = new PthreadInternal{};
#else
// TODO: Linux specific hack
static u8* hint_address = reinterpret_cast<u8*>(0x7FFFFC000ULL);
auto* ret = reinterpret_cast<PthreadInternal*>(
mmap(hint_address, sizeof(PthreadInternal), PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0));
hint_address += Common::AlignUp(sizeof(PthreadInternal), 4_KB);
#endif
ret->is_free = false; ret->is_free = false;
ret->is_detached = false; ret->is_detached = false;
ret->is_almost_done = false; ret->is_almost_done = false;

View File

@ -107,6 +107,74 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
Shader::PushData push_data{}; Shader::PushData push_data{};
u32 binding{}; u32 binding{};
if (info->pgm_hash == 0x3d5ebf4e) {
const auto& src = info->texture_buffers[0];
const auto src_sharp = src.GetSharp(*info);
const auto& dst = info->texture_buffers[1];
const auto dst_sharp = dst.GetSharp(*info);
if (dst_sharp.base_address == 0x510e0000 || dst_sharp.base_address == 0x1926e0000 ||
dst_sharp.base_address == 0x1d42e0000) {
VideoCore::ImageViewInfo view_info;
view_info.format = vk::Format::eR8G8B8A8Unorm;
view_info.type = vk::ImageViewType::e2D;
view_info.range.extent.layers = 1;
view_info.range.extent.levels = 1;
AmdGpu::Image src_image;
src_image.base_address = src_sharp.base_address >> 8;
src_image.base_level = 0;
src_image.width = 1920 - 1;
src_image.height = 1080 - 1;
src_image.depth = 1;
src_image.data_format = u64(AmdGpu::DataFormat::Format8_8_8_8);
src_image.num_format = u64(AmdGpu::NumberFormat::Unorm);
src_image.dst_sel_x = 4;
src_image.dst_sel_y = 5;
src_image.dst_sel_z = 6;
src_image.dst_sel_w = 7;
src_image.pitch = 1920 - 1;
src_image.type = u64(AmdGpu::ImageType::Color2D);
src_image.tiling_index = u64(AmdGpu::TilingMode::Display_MacroTiled);
VideoCore::ImageInfo src_info{src_image};
const auto src_id = texture_cache.FindImage(src_info);
auto& src_img = texture_cache.GetImage(src_id);
src_img.Transit(vk::ImageLayout::eTransferSrcOptimal,
vk::AccessFlagBits::eTransferRead);
src_image.base_address = dst_sharp.base_address >> 8;
VideoCore::ImageInfo dst_info{src_image};
const auto dst_id = texture_cache.FindImage(dst_info);
auto& dst_img = texture_cache.GetImage(dst_id);
dst_img.Transit(vk::ImageLayout::eTransferDstOptimal,
vk::AccessFlagBits::eTransferWrite);
const auto cmdbuf = scheduler.CommandBuffer();
scheduler.EndRendering();
const vk::ImageCopy copy = {
.srcSubresource =
{
.aspectMask = vk::ImageAspectFlagBits::eColor,
.mipLevel = 0,
.baseArrayLayer = 0,
.layerCount = 1,
},
.srcOffset = {0, 0, 0},
.dstSubresource =
{
.aspectMask = vk::ImageAspectFlagBits::eColor,
.mipLevel = 0,
.baseArrayLayer = 0,
.layerCount = 1,
},
.dstOffset = {0, 0, 0},
.extent = {1920, 1080, 1},
};
cmdbuf.copyImage(src_img.image, vk::ImageLayout::eTransferSrcOptimal, dst_img.image,
vk::ImageLayout::eTransferDstOptimal, copy);
return false;
}
}
for (const auto& desc : info->buffers) { for (const auto& desc : info->buffers) {
const auto vsharp = desc.GetSharp(*info); const auto vsharp = desc.GetSharp(*info);
const bool is_storage = desc.IsStorage(vsharp); const bool is_storage = desc.IsStorage(vsharp);
@ -166,7 +234,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
LOG_WARNING(Render_Vulkan, "Unexpected metadata read by a CS shader (buffer)"); LOG_WARNING(Render_Vulkan, "Unexpected metadata read by a CS shader (buffer)");
} }
} }
if (desc.is_written) { if (desc.is_written && info->pgm_hash != 0xfefebf9f && info->pgm_hash != 0x3d5ebf4e) {
texture_cache.InvalidateMemory(address, size); texture_cache.InvalidateMemory(address, size);
} }
const u32 alignment = instance.TexelBufferMinAlignment(); const u32 alignment = instance.TexelBufferMinAlignment();

View File

@ -220,12 +220,12 @@ bool Instance::CreateDevice() {
const bool maintenance5 = add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME); const bool maintenance5 = add_extension(VK_KHR_MAINTENANCE_5_EXTENSION_NAME);
add_extension(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME); add_extension(VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME);
add_extension(VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME); add_extension(VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME);
const bool has_sync2 = add_extension(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME);
if (Config::isMarkersEnabled()) { if (has_sync2) {
const bool has_sync2 = add_extension(VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME); has_nv_checkpoints = Config::isMarkersEnabled()
if (has_sync2) { ? add_extension(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME)
has_nv_checkpoints = add_extension(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME); : false;
}
} }
#ifdef __APPLE__ #ifdef __APPLE__

View File

@ -64,7 +64,9 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
} }
bool ShouldSkipShader(u64 shader_hash, const char* shader_type) { bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
static constexpr std::array<u64, 0> skip_hashes = {}; static constexpr std::array<u64, 7> skip_hashes = {0xa509af23, 0x4ca76892, 0xa954e79d,
0x42f2a521, 0x2da7fe60, 0x1635154c,
0x8e3f8dc4};
if (std::ranges::contains(skip_hashes, shader_hash)) { if (std::ranges::contains(skip_hashes, shader_hash)) {
LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash); LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash);
return true; return true;