Repository: skyline-emu/skyline
File: app/src/main/cpp/skyline/gpu/gpfifo.cpp (C++)

Code before:
                    subchannels.at(params.subChannel) = state.gpu->maxwellDma;
                    break;
                default:
                    throw exception("Unknown engine 0x{:X} cannot be bound to subchannel {}", params.argument, params.subChannel);
            }

            state.logger->Info("Bound GPU engine 0x{:X} to subchannel {}", params.argument, params.subChannel);
            return;
        } else if (params.method < constant::GpfifoRegisterCount) {
            gpfifoEngine.CallMethod(params);
        } else {
            if (subchannels.at(params.subChannel) == nullptr)
                throw exception("Calling method on unbound channel");

            subchannels.at(params.subChannel)->CallMethod(params);
        }
    }

    void GPFIFO::Process(const std::vector<u32> &segment) {
        for (auto entry{segment.begin()}; entry != segment.end(); entry++) {
            // An entry containing all zeroes is a NOP, skip over it
            if (*entry == 0)
                continue;

            auto methodHeader{reinterpret_cast<const PushBufferMethodHeader *>(&*entry)};

            switch (methodHeader->secOp) {
                case PushBufferMethodHeader::SecOp::IncMethod:
                    for (u16 i{}; i < methodHeader->methodCount; i++)
                        Send(MethodParams{static_cast<u16>(methodHeader->methodAddress + i), *++entry, methodHeader->methodSubChannel, i == methodHeader->methodCount - 1});

                    break;
                case PushBufferMethodHeader::SecOp::NonIncMethod:
                    for (u16 i{}; i < methodHeader->methodCount; i++)
                        Send(MethodParams{methodHeader->methodAddress, *++entry, methodHeader->methodSubChannel, i == methodHeader->methodCount - 1});

                    break;
                case PushBufferMethodHeader::SecOp::OneInc:
                    for (u16 i{}; i < methodHeader->methodCount; i++)
                        Send(MethodParams{static_cast<u16>(methodHeader->methodAddress + static_cast<bool>(i)), *++entry, methodHeader->methodSubChannel, i == methodHeader->methodCount - 1});

                    break;
                case PushBufferMethodHeader::SecOp::ImmdDataMethod:
                    Send(MethodParams{methodHeader->methodAddress, methodHeader->immdData, methodHeader->methodSubChannel, true});
                    break;
                case PushBufferMethodHeader::SecOp::EndPbSegment:
                    return;
                default:
                    break;
            }
        }

Review comment (suggestion):
Use `{}` instead of `%u` and change the `static_cast` to `u8`, this isn't `printf`

Code after:
                    subchannels.at(params.subChannel) = state.gpu->maxwellDma;
                    break;
                default:
                    throw exception("Unknown engine 0x{:X} cannot be bound to subchannel {}", params.argument, params.subChannel);
            }

            state.logger->Info("Bound GPU engine 0x{:X} to subchannel {}", params.argument, params.subChannel);
            return;
        } else if (params.method < constant::GpfifoRegisterCount) {
            gpfifoEngine.CallMethod(params);
        } else {
            if (subchannels.at(params.subChannel) == nullptr)
                throw exception("Calling method on unbound channel");

            subchannels.at(params.subChannel)->CallMethod(params);
        }
    }

    void GPFIFO::Process(GpEntry gpEntry) {
        if (!gpEntry.size) {
            // This is a GPFIFO control entry, all control entries have a zero length and contain no pushbuffers
            switch (gpEntry.opcode) {
                case GpEntry::Opcode::Nop:
                    return;
                default:
                    state.logger->Warn("Unsupported GpEntry control opcode used: {}", static_cast<u8>(gpEntry.opcode));
                    return;
            }
        }

        pushBufferData.resize(gpEntry.size);
        state.gpu->memoryManager.Read<u32>(pushBufferData, gpEntry.Address());

        for (auto entry{pushBufferData.begin()}; entry != pushBufferData.end(); entry++) {
            // An entry containing all zeroes is a NOP, skip over it
            if (*entry == 0)
                continue;

            PushBufferMethodHeader methodHeader{.raw = *entry};

            switch (methodHeader.secOp) {
                case PushBufferMethodHeader::SecOp::IncMethod:
                    for (u16 i{}; i < methodHeader.methodCount; i++)
                        Send(MethodParams{static_cast<u16>(methodHeader.methodAddress + i), *++entry, methodHeader.methodSubChannel, i == methodHeader.methodCount - 1});

                    break;
                case PushBufferMethodHeader::SecOp::NonIncMethod:
                    for (u16 i{}; i < methodHeader.methodCount; i++)
                        Send(MethodParams{methodHeader.methodAddress, *++entry, methodHeader.methodSubChannel, i == methodHeader.methodCount - 1});

                    break;