mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-10-12 02:22:27 +00:00
gnmdriver: Implement sceGnmSetGsRingSizes and sceGnmSetupMipStatsReport (#5179)
* gnmdriver: Implement sceGnmSetGsRingSizes - Match Sony libSceGnmDriver 1 MB alignment and [4 MB, 8 MB] range validation - Return 0x08000000 on invalid size parameter - Program Liverpool VGT_ESGS_RING_SIZE and VGT_GSVS_RING_SIZE registers * gnmdriver: Implement sceGnmSetupMipStatsReport - Match Sony libSceGnmDriver 64-byte alignment and 48-bit address validation (0x80000001) - Validate report buffer size >= 0x1040 and (size & 0x7FF) == 0x40 (0x80000002) - Zero output buffer and write 64-byte header size
This commit is contained in:
@@ -1591,8 +1591,22 @@ s32 PS4_SYSV_ABI sceGnmSetEsShader(u32* cmdbuf, u32 size, const u32* es_regs, u3
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceGnmSetGsRingSizes() {
|
||||
LOG_ERROR(Lib_GnmDriver, "(STUBBED) called");
|
||||
s32 PS4_SYSV_ABI sceGnmSetGsRingSizes(u32 esgs_ring_size, u32 gsvs_ring_size) {
|
||||
LOG_TRACE(Lib_GnmDriver, "esgs_ring_size = {:#x}, gsvs_ring_size = {:#x}", esgs_ring_size,
|
||||
gsvs_ring_size);
|
||||
// Sony libSceGnmDriver validates 1 MB alignment and [4 MB, 8 MB] range.
|
||||
constexpr u32 MinRingSize = 0x400000; // 4 MB
|
||||
constexpr u32 MaxRingSize = 0x800000; // 8 MB
|
||||
constexpr u32 RingAlignment = 0x100000; // 1 MB
|
||||
if (esgs_ring_size < MinRingSize || esgs_ring_size > MaxRingSize ||
|
||||
((esgs_ring_size & (RingAlignment - 1)) != 0) || gsvs_ring_size < MinRingSize ||
|
||||
gsvs_ring_size > MaxRingSize || ((gsvs_ring_size & (RingAlignment - 1)) != 0)) {
|
||||
return 0x08000000;
|
||||
}
|
||||
if (liverpool) {
|
||||
liverpool->regs.vgt_esgs_ring_size = esgs_ring_size >> 8;
|
||||
liverpool->regs.vgt_gsvs_ring_size = gsvs_ring_size >> 8;
|
||||
}
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
@@ -1786,8 +1800,24 @@ int PS4_SYSV_ABI sceGnmSetSpiEnableSqCountersForUnitInstance() {
|
||||
return ORBIS_GNM_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceGnmSetupMipStatsReport() {
|
||||
LOG_ERROR(Lib_GnmDriver, "(STUBBED) called");
|
||||
s32 PS4_SYSV_ABI sceGnmSetupMipStatsReport(void* output_buffer, u32 size_in_bytes,
|
||||
u8 intervals_between_reports,
|
||||
u8 num_reports_before_reset, u32 mip_stats_reset_force) {
|
||||
LOG_DEBUG(
|
||||
Lib_GnmDriver,
|
||||
"(STUBBED) output_buffer = {}, size_in_bytes = {:#x}, intervals = {}, num_reports = {}, "
|
||||
"force_reset = {}",
|
||||
output_buffer, size_in_bytes, intervals_between_reports, num_reports_before_reset,
|
||||
mip_stats_reset_force);
|
||||
if (!output_buffer ||
|
||||
(reinterpret_cast<uintptr_t>(output_buffer) & 0xffffff000000003fULL) != 0) {
|
||||
return 0x80000001;
|
||||
}
|
||||
if (size_in_bytes < 0x1040 || (size_in_bytes & 0x7ff) != 0x40) {
|
||||
return 0x80000002;
|
||||
}
|
||||
std::memset(output_buffer, 0, size_in_bytes);
|
||||
*static_cast<u32*>(output_buffer) = 0x40u;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
@@ -157,7 +157,7 @@ s32 PS4_SYSV_ABI sceGnmSetEmbeddedPsShader(u32* cmdbuf, u32 size, u32 shader_id,
|
||||
u32 shader_modifier);
|
||||
s32 PS4_SYSV_ABI sceGnmSetEmbeddedVsShader(u32* cmdbuf, u32 size, u32 shader_id, u32 modifier);
|
||||
s32 PS4_SYSV_ABI sceGnmSetEsShader(u32* cmdbuf, u32 size, const u32* es_regs, u32 shader_modifier);
|
||||
int PS4_SYSV_ABI sceGnmSetGsRingSizes();
|
||||
s32 PS4_SYSV_ABI sceGnmSetGsRingSizes(u32 esgs_ring_size, u32 gsvs_ring_size);
|
||||
s32 PS4_SYSV_ABI sceGnmSetGsShader(u32* cmdbuf, u32 size, const u32* gs_regs);
|
||||
s32 PS4_SYSV_ABI sceGnmSetHsShader(u32* cmdbuf, u32 size, const u32* hs_regs, u32 param4);
|
||||
s32 PS4_SYSV_ABI sceGnmSetLsShader(u32* cmdbuf, u32 size, const u32* ls_regs, u32 shader_modifier);
|
||||
@@ -167,7 +167,9 @@ int PS4_SYSV_ABI sceGnmSetResourceRegistrationUserMemory();
|
||||
int PS4_SYSV_ABI sceGnmSetResourceUserData();
|
||||
int PS4_SYSV_ABI sceGnmSetSpiEnableSqCounters();
|
||||
int PS4_SYSV_ABI sceGnmSetSpiEnableSqCountersForUnitInstance();
|
||||
int PS4_SYSV_ABI sceGnmSetupMipStatsReport();
|
||||
s32 PS4_SYSV_ABI sceGnmSetupMipStatsReport(void* output_buffer, u32 size_in_bytes,
|
||||
u8 intervals_between_reports,
|
||||
u8 num_reports_before_reset, u32 mip_stats_reset_force);
|
||||
s32 PS4_SYSV_ABI sceGnmSetVgtControl(u32* cmdbuf, u32 size, u32 prim_group_sz_minus_one,
|
||||
u32 partial_vs_wave_mode, u32 wd_switch_only_on_eop_mode);
|
||||
s32 PS4_SYSV_ABI sceGnmSetVsShader(u32* cmdbuf, u32 size, const u32* vs_regs, u32 shader_modifier);
|
||||
|
||||
Reference in New Issue
Block a user