Fix Metroid

This commit is contained in:
liberodark 2025-12-06 01:13:59 +01:00
parent ff71937776
commit 7f5880e47a
5 changed files with 101 additions and 6 deletions

View file

@ -254,6 +254,51 @@ void CommandBuffer::GenerateBiquadFilterCommand(const s32 node_id, EffectInfoBas
const s16 buffer_offset, const s8 channel,
const bool needs_init,
const bool use_float_processing) {
if (behavior->IsEffectInfoVersion2Supported()) {
const auto& parameter_v2{
*reinterpret_cast<BiquadFilterInfo::ParameterVersion2*>(effect_info.GetParameter())};
if (!IsChannelCountValid(static_cast<u16>(parameter_v2.channel_count)) || channel < 0 ||
channel >= parameter_v2.channel_count) {
return;
}
if (!parameter_v2.enable) {
GenerateCopyMixBufferCommand(node_id, effect_info, buffer_offset, channel);
return;
}
const s16 input_index = buffer_offset + parameter_v2.inputs[channel];
const s16 output_index = buffer_offset + parameter_v2.outputs[channel];
if (input_index < 0) {
return;
}
s16 effective_output = output_index;
if (output_index < 0) {
effective_output = input_index;
}
auto& cmd{GenerateStart<BiquadFilterCommand, CommandId::BiquadFilter>(node_id)};
const auto state{reinterpret_cast<VoiceState::BiquadFilterState*>(
effect_info.GetStateBuffer() + channel * sizeof(VoiceState::BiquadFilterState))};
cmd.input = input_index;
cmd.output = effective_output;
cmd.biquad_float.numerator = parameter_v2.b;
cmd.biquad_float.denominator = parameter_v2.a;
cmd.use_float_coefficients = true;
cmd.state = memory_pool->Translate(CpuAddr(state), sizeof(VoiceState::BiquadFilterState));
cmd.needs_init = needs_init;
cmd.use_float_processing = use_float_processing;
GenerateEnd<BiquadFilterCommand>(cmd);
return;
}
auto& cmd{GenerateStart<BiquadFilterCommand, CommandId::BiquadFilter>(node_id)};
const auto& parameter{
@ -590,6 +635,17 @@ void CommandBuffer::GenerateClearMixCommand(const s32 node_id) {
void CommandBuffer::GenerateCopyMixBufferCommand(const s32 node_id, EffectInfoBase& effect_info,
const s16 buffer_offset, const s8 channel) {
if (behavior->IsEffectInfoVersion2Supported()) {
auto& cmd{GenerateStart<CopyMixBufferCommand, CommandId::CopyMixBuffer>(node_id)};
const auto& parameter_v2{
*reinterpret_cast<BiquadFilterInfo::ParameterVersion2*>(effect_info.GetParameter())};
cmd.input_index = buffer_offset + parameter_v2.inputs[channel];
cmd.output_index = buffer_offset + parameter_v2.outputs[channel];
GenerateEnd<CopyMixBufferCommand>(cmd);
return;
}
auto& cmd{GenerateStart<CopyMixBufferCommand, CommandId::CopyMixBuffer>(node_id)};
const auto& parameter{

View file

@ -361,6 +361,27 @@ void CommandGenerator::GenerateAuxCommand(const s16 buffer_offset, EffectInfoBas
void CommandGenerator::GenerateBiquadFilterEffectCommand(const s16 buffer_offset,
EffectInfoBase& effect_info,
const s32 node_id) {
if (render_context.behavior->IsEffectInfoVersion2Supported()) {
const auto& parameter_v2{
*reinterpret_cast<BiquadFilterInfo::ParameterVersion2*>(effect_info.GetParameter())};
const bool needs_init = false;
const bool use_float_processing = render_context.behavior->UseBiquadFilterFloatProcessing();
const s8 channels = parameter_v2.channel_count > 0 ? parameter_v2.channel_count : 2;
if (effect_info.IsEnabled()) {
for (s8 channel = 0; channel < channels; channel++) {
command_buffer.GenerateBiquadFilterCommand(
node_id, effect_info, buffer_offset, channel, needs_init, use_float_processing);
}
} else {
for (s8 channel = 0; channel < channels; channel++) {
command_buffer.GenerateCopyMixBufferCommand(node_id, effect_info, buffer_offset,
channel);
}
}
return;
}
const auto& parameter{
*reinterpret_cast<BiquadFilterInfo::ParameterVersion1*>(effect_info.GetParameter())};
if (effect_info.IsEnabled()) {

View file

@ -25,12 +25,12 @@ public:
"BiquadFilterInfo::ParameterVersion1 has the wrong size!");
struct ParameterVersion2 {
/* 0x00 */ std::array<s8, MaxChannels> inputs;
/* 0x06 */ std::array<s8, MaxChannels> outputs;
/* 0x0C */ std::array<s16, 3> b;
/* 0x12 */ std::array<s16, 2> a;
/* 0x16 */ s8 channel_count;
/* 0x17 */ ParameterState state;
bool enable;
s8 channel_count;
s8 inputs[MaxChannels];
s8 outputs[MaxChannels];
std::array<f32, 3> b;
std::array<f32, 2> a;
};
static_assert(sizeof(ParameterVersion2) <= sizeof(EffectInfoBase::InParameterVersion2),
"BiquadFilterInfo::ParameterVersion2 has the wrong size!");

View file

@ -44,6 +44,8 @@ NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8>
return WrapFixed(this, &nvhost_ctrl_gpu::GetTPCMasks1, input, output);
case 0x7:
return WrapFixed(this, &nvhost_ctrl_gpu::FlushL2, input, output);
case 0x13:
return WrapFixed(this, &nvhost_ctrl_gpu::GetGpuLoad, input, output);
case 0x14:
return WrapFixed(this, &nvhost_ctrl_gpu::GetActiveSlotMask, input, output);
case 0x1c:
@ -74,6 +76,8 @@ NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8>
case 0x6:
return WrapFixedInlOut(this, &nvhost_ctrl_gpu::GetTPCMasks3, input, output,
inline_output);
case 0x13:
return WrapFixed(this, &nvhost_ctrl_gpu::GetGpuLoad, input, output);
default:
break;
}
@ -247,6 +251,13 @@ NvResult nvhost_ctrl_gpu::GetGpuTime(IoctlGetGpuTime& params) {
return NvResult::Success;
}
NvResult nvhost_ctrl_gpu::GetGpuLoad(IoctlGetGpuLoad& params) {
LOG_DEBUG(Service_NVDRV, "called");
params.load = 0;
params.padding = 0;
return NvResult::Success;
}
Kernel::KEvent* nvhost_ctrl_gpu::QueryEvent(u32 event_id) {
switch (event_id) {
case 1:

View file

@ -151,6 +151,12 @@ private:
};
static_assert(sizeof(IoctlGetGpuTime) == 0x10, "IoctlGetGpuTime is incorrect size");
struct IoctlGetGpuLoad {
u32_le load;
u32_le padding;
};
static_assert(sizeof(IoctlGetGpuLoad) == 8, "IoctlGetGpuLoad is incorrect size");
NvResult GetCharacteristics1(IoctlCharacteristics& params);
NvResult GetCharacteristics3(IoctlCharacteristics& params,
std::span<IoctlGpuCharacteristics> gpu_characteristics);
@ -165,6 +171,7 @@ private:
NvResult ZBCQueryTable(IoctlZbcQueryTable& params);
NvResult FlushL2(IoctlFlushL2& params);
NvResult GetGpuTime(IoctlGetGpuTime& params);
NvResult GetGpuLoad(IoctlGetGpuLoad& params);
EventInterface& events_interface;