Merge branch 'main' into Feature/initial-ps4-ime-keyboard

This commit is contained in:
georgemoralis 2025-04-16 08:00:28 +03:00 committed by GitHub
commit 52085045a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 50 additions and 15 deletions

2
.gitmodules vendored
View file

@ -97,7 +97,7 @@
shallow = true
[submodule "externals/MoltenVK/SPIRV-Cross"]
path = externals/MoltenVK/SPIRV-Cross
url = https://github.com/KhronosGroup/SPIRV-Cross
url = https://github.com/billhollings/SPIRV-Cross
shallow = true
[submodule "externals/MoltenVK/MoltenVK"]
path = externals/MoltenVK/MoltenVK

@ -1 +1 @@
Subproject commit 83510e0f3835c3c43651dda087305abc42572e17
Subproject commit 067fc6c85b02f37dfda58eeda49d8458e093ed60

@ -1 +1 @@
Subproject commit 68300dc07ac3dc592dbbdb87e02d5180f984ad12
Subproject commit 185833a61cbe29ce3bfb5a499ffb3dfeaee3bbe7

View file

@ -235,9 +235,12 @@ std::pair<const IR::Inst*, bool> TryDisableAnisoLod0(const IR::Inst* inst) {
return {prod2, true};
}
SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) {
SharpLocation AttemptTrackSharp(const IR::Inst* inst, auto& visited_insts) {
// Search until we find a potential sharp source.
const auto pred = [](const IR::Inst* inst) -> std::optional<const IR::Inst*> {
const auto pred = [&visited_insts](const IR::Inst* inst) -> std::optional<const IR::Inst*> {
if (std::ranges::find(visited_insts, inst) != visited_insts.end()) {
return std::nullopt;
}
if (inst->GetOpcode() == IR::Opcode::GetUserData ||
inst->GetOpcode() == IR::Opcode::ReadConst) {
return inst;
@ -247,6 +250,7 @@ SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) {
const auto result = IR::BreadthFirstSearch(inst, pred);
ASSERT_MSG(result, "Unable to track sharp source");
inst = result.value();
visited_insts.emplace_back(inst);
if (inst->GetOpcode() == IR::Opcode::GetUserData) {
return static_cast<u32>(inst->Arg(0).ScalarReg());
} else {
@ -256,6 +260,29 @@ SharpLocation TrackSharp(const IR::Inst* inst, const Shader::Info& info) {
}
}
/// Tracks a sharp with validation of the chosen data type.
template <typename DataType>
std::pair<SharpLocation, DataType> TrackSharp(const IR::Inst* inst, const Info& info) {
boost::container::small_vector<const IR::Inst*, 4> visited_insts{};
while (true) {
const auto prev_size = visited_insts.size();
const auto sharp = AttemptTrackSharp(inst, visited_insts);
if (const auto data = info.ReadUdSharp<DataType>(sharp); data.Valid()) {
return std::make_pair(sharp, data);
}
if (prev_size == visited_insts.size()) {
// No change in visited instructions, we've run out of paths.
UNREACHABLE_MSG("Unable to find valid sharp.");
}
}
}
/// Tracks a sharp without data validation.
SharpLocation TrackSharp(const IR::Inst* inst, const Info& info) {
boost::container::static_vector<const IR::Inst*, 1> visited_insts{};
return AttemptTrackSharp(inst, visited_insts);
}
s32 TryHandleInlineCbuf(IR::Inst& inst, Info& info, Descriptors& descriptors,
AmdGpu::Buffer& cbuf) {
@ -293,8 +320,8 @@ void PatchBufferSharp(IR::Block& block, IR::Inst& inst, Info& info, Descriptors&
if (binding = TryHandleInlineCbuf(inst, info, descriptors, buffer); binding == -1) {
IR::Inst* handle = inst.Arg(0).InstRecursive();
IR::Inst* producer = handle->Arg(0).InstRecursive();
const auto sharp = TrackSharp(producer, info);
buffer = info.ReadUdSharp<AmdGpu::Buffer>(sharp);
SharpLocation sharp;
std::tie(sharp, buffer) = TrackSharp<AmdGpu::Buffer>(producer, info);
binding = descriptors.Add(BufferResource{
.sharp_idx = sharp,
.used_types = BufferDataType(inst, buffer.GetNumberFmt()),

View file

@ -249,7 +249,7 @@ bool Instance::CreateDevice() {
add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME);
add_extension(VK_EXT_TOOLING_INFO_EXTENSION_NAME);
const bool maintenance4 = add_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME);
add_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME);
add_extension(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
add_extension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
@ -422,9 +422,6 @@ bool Instance::CreateDevice() {
#endif
};
if (!maintenance4) {
device_chain.unlink<vk::PhysicalDeviceMaintenance4FeaturesKHR>();
}
if (!custom_border_color) {
device_chain.unlink<vk::PhysicalDeviceCustomBorderColorFeaturesEXT>();
}

View file

@ -930,12 +930,17 @@ bool Rasterizer::IsMapped(VAddr addr, u64 size) {
// There is no memory, so not mapped.
return false;
}
return mapped_ranges.find(boost::icl::interval<VAddr>::right_open(addr, addr + size)) !=
mapped_ranges.end();
const auto range = decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
std::shared_lock lock{mapped_ranges_mutex};
return boost::icl::contains(mapped_ranges, range);
}
void Rasterizer::MapMemory(VAddr addr, u64 size) {
mapped_ranges += boost::icl::interval<VAddr>::right_open(addr, addr + size);
{
std::unique_lock lock{mapped_ranges_mutex};
mapped_ranges += decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
}
page_manager.OnGpuMap(addr, size);
}
@ -943,7 +948,10 @@ void Rasterizer::UnmapMemory(VAddr addr, u64 size) {
buffer_cache.InvalidateMemory(addr, size);
texture_cache.UnmapMemory(addr, size);
page_manager.OnGpuUnmap(addr, size);
mapped_ranges -= boost::icl::interval<VAddr>::right_open(addr, addr + size);
{
std::unique_lock lock{mapped_ranges_mutex};
mapped_ranges -= decltype(mapped_ranges)::interval_type::right_open(addr, addr + size);
}
}
void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) const {

View file

@ -3,6 +3,8 @@
#pragma once
#include <shared_mutex>
#include "video_core/buffer_cache/buffer_cache.h"
#include "video_core/page_manager.h"
#include "video_core/renderer_vulkan/vk_pipeline_cache.h"
@ -106,6 +108,7 @@ private:
AmdGpu::Liverpool* liverpool;
Core::MemoryManager* memory;
boost::icl::interval_set<VAddr> mapped_ranges;
std::shared_mutex mapped_ranges_mutex;
PipelineCache pipeline_cache;
boost::container::static_vector<