Skip to content

Commit

Permalink
bb hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
0xGingi committed Oct 1, 2024
1 parent 4fd9467 commit 95cebdc
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/core/libraries/kernel/thread_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,8 +1066,16 @@ ScePthread PThreadPool::Create(const char* name) {
return p;
}
}

#ifdef _WIN64
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_detached = false;
ret->is_almost_done = false;
Expand Down
73 changes: 72 additions & 1 deletion src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,77 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
image_infos.clear();

info->PushUd(binding, push_data);

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 || // Release
dst_sharp.base_address == 0x1928e0000 || // ReleaseWithDebInfo
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) {
bool is_storage = true;
if (desc.is_gds_buffer) {
Expand Down Expand Up @@ -204,7 +275,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache,
vk::PipelineStageFlagBits2::eComputeShader)) {
buffer_barriers.emplace_back(*barrier);
}
if (desc.is_written) {
if (desc.is_written && info->pgm_hash != 0xfefebf9f) { // Not skipping 0x3d5ebf4e as well, otherwise video player will be black
texture_cache.InvalidateMemoryFromGPU(address, size);
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
}

bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
static constexpr std::array<u64, 0> skip_hashes = {};
static constexpr std::array<u64, 11> skip_hashes = {0xa509af23, 0x4ca76892, 0xa954e79d,
0x42f2a521, 0x2da7fe60, 0x1635154c,
0x8e3f8dc4, 0xc0cbc309, 0x77d1c63,
0xff7a6d7c, 0xddfbac23, 0x3d5ebf4e};
if (std::ranges::contains(skip_hashes, shader_hash)) {
LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash);
return true;
Expand Down

0 comments on commit 95cebdc

Please sign in to comment.