[vk, hle] fix storage buffer cache, unstubbed TryPopFriendInvitation (#129)

This fixes Jamboree + unstubes friend invitation channel which spammed a lot while testing jamboree.

Culprit was: #2

Co-authored-by: Maufeat <sahyno1996@gmail.com>
Co-authored-by: crueter <crueter@eden-emu.dev>
Reviewed-on: eden-emu/eden#129
Co-authored-by: Maufeat <maufeat@eden-emu.dev>
Co-committed-by: Maufeat <maufeat@eden-emu.dev>
This commit is contained in:
Maufeat 2025-07-27 02:37:29 +02:00 committed by weakboson
parent aa880d3ca9
commit ca2fa770f7
4 changed files with 28 additions and 6 deletions

View file

@ -92,6 +92,7 @@ struct Applet {
// Channels
std::deque<std::vector<u8>> user_channel_launch_parameter{};
std::deque<std::vector<u8>> preselected_user_launch_parameter{};
std::deque<std::vector<u8>> friend_invitation_storage_channel{};
// Caller applet
std::weak_ptr<Applet> caller_applet{};

View file

@ -456,8 +456,21 @@ Result IApplicationFunctions::GetFriendInvitationStorageChannelEvent(
Result IApplicationFunctions::TryPopFromFriendInvitationStorageChannel(
Out<SharedPointer<IStorage>> out_storage) {
LOG_INFO(Service_AM, "(STUBBED) called");
R_THROW(AM::ResultNoDataInChannel);
LOG_DEBUG(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
auto& channel = m_applet->friend_invitation_storage_channel;
if (channel.empty()) {
return AM::ResultNoDataInChannel;
}
auto data = channel.back();
channel.pop_back();
*out_storage = std::make_shared<IStorage>(system, std::move(data));
R_SUCCEED();
}
Result IApplicationFunctions::GetNotificationStorageChannelEvent(

View file

@ -467,6 +467,10 @@ void BufferCache<P>::BindComputeStorageBuffer(size_t ssbo_index, u32 cbuf_index,
channel_state->written_compute_storage_buffers |= (is_written ? 1U : 0U) << ssbo_index;
const auto& launch_desc = kepler_compute->launch_description;
if (((launch_desc.const_buffer_enable_mask >> cbuf_index) & 1) == 0) {
LOG_WARNING(HW_GPU, "Skipped binding SSBO: cbuf index {} is not enabled", cbuf_index);
return;
}
ASSERT(((launch_desc.const_buffer_enable_mask >> cbuf_index) & 1) != 0);
const auto& cbufs = launch_desc.const_buffer_config;
@ -1700,6 +1704,11 @@ template <class P>
Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
bool is_written) const {
const GPUVAddr gpu_addr = gpu_memory->Read<u64>(ssbo_addr);
if (gpu_addr == 0) {
return NULL_BINDING;
}
const auto size = [&]() {
const bool is_nvn_cbuf = cbuf_index == 0;
// The NVN driver buffer (index 0) is known to pack the SSBO address followed by its size.
@ -1722,7 +1731,7 @@ Binding BufferCache<P>::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index,
const std::optional<DAddr> aligned_device_addr = gpu_memory->GpuToCpuAddress(aligned_gpu_addr);
if (!aligned_device_addr || size == 0) {
LOG_WARNING(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
LOG_DEBUG(HW_GPU, "Failed to find storage buffer for cbuf index {}", cbuf_index);
return NULL_BINDING;
}
const std::optional<DAddr> device_addr = gpu_memory->GpuToCpuAddress(gpu_addr);

View file

@ -324,9 +324,8 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
size_t ssbo_index{};
for (const auto& desc : info.storage_buffers_descriptors) {
ASSERT(desc.count == 1);
if (!buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index,
desc.cbuf_offset, desc.is_written))
return false;
buffer_cache.BindGraphicsStorageBuffer(stage, ssbo_index, desc.cbuf_index,
desc.cbuf_offset, desc.is_written);
++ssbo_index;
}
}