Fix CircularQueue and improve debug logging + exefs loading

CircularQueue was looping around too early resulting in the wrong
pushbuffers being used. The debug logging is useful for interpreting the
GPU method call logs.

Exefs loading was changed to check if an NSO exists before trying to
read it, preventing exceptions that get annoying while debugging.
This commit is contained in:
Billy Laws 2020-11-15 19:44:13 +00:00 committed by ◱ PixelyIon
parent c161ef0cac
commit 8bf08ed66f
7 changed files with 25 additions and 20 deletions

View File

@ -69,28 +69,24 @@ namespace skyline {
inline void Push(const Type &item) {
std::unique_lock lock(productionMutex);
auto next{end + 1};
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
if (next == start) {
end = (end == reinterpret_cast<Type *>(vector.end().base()) - 1) ? reinterpret_cast<Type *>(vector.begin().base()) : end;
if (start == end + 1) {
std::unique_lock consumeLock(consumptionMutex);
consumeCondition.wait(consumeLock, [=]() { return next != start; });
consumeCondition.wait(consumeLock, [=]() { return start != end + 1; });
}
*next = item;
end = next;
*end = item;
produceCondition.notify_one();
}
inline void Append(span<Type> buffer) {
std::unique_lock lock(productionMutex);
for (auto &item : buffer) {
auto next{end + 1};
next = (next == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : next;
if (next == start) {
end = (end == reinterpret_cast<Type *>(vector.end().base()) - 1) ? reinterpret_cast<Type *>(vector.begin().base()) : end;
if (start == end + 1) {
std::unique_lock consumeLock(consumptionMutex);
consumeCondition.wait(consumeLock, [=]() { return next != start; });
consumeCondition.wait(consumeLock, [=]() { return start != end + 1; });
}
*next = item;
end = next;
*(end++) = item;
}
produceCondition.notify_one();
}
@ -102,9 +98,8 @@ namespace skyline {
template<typename TransformedType, typename Transformation>
inline void AppendTranform(span<TransformedType> buffer, Transformation transformation) {
std::unique_lock lock(productionMutex);
auto next{end};
for (auto &item : buffer) {
end = (end == reinterpret_cast<Type *>(vector.end().base())) ? reinterpret_cast<Type *>(vector.begin().base()) : end;
end = (end == reinterpret_cast<Type *>(vector.end().base()) - 1) ? reinterpret_cast<Type *>(vector.begin().base()) : end;
if (start == end + 1) {
std::unique_lock consumeLock(consumptionMutex);
consumeCondition.wait(consumeLock, [=]() { return start != end + 1; });

View File

@ -117,6 +117,7 @@ namespace skyline::gpu::engine {
shadowRegisters.mme.shadowRamControl = static_cast<Registers::MmeShadowRamControl>(params.argument);
break;
case MAXWELL3D_OFFSET(syncpointAction):
state.logger->Debug("Increment syncpoint: {}", static_cast<u16>(registers.syncpointAction.id));
state.gpu->syncpoints.at(registers.syncpointAction.id).Increment();
break;
case MAXWELL3D_OFFSET(semaphore.info):

View File

@ -93,6 +93,8 @@ namespace skyline::gpu::gpfifo {
pushBuffers->Process([this](PushBuffer &pushBuffer) {
if (pushBuffer.segment.empty())
pushBuffer.Fetch(state.gpu->memoryManager);
state.logger->Debug("Processing pushbuffer: 0x{:X}", pushBuffer.gpEntry.Address());
Process(pushBuffer.segment);
});
} catch (const signal::SignalException &e) {

View File

@ -67,6 +67,10 @@ namespace skyline::gpu {
Sync sync : 1;
};
};
constexpr u64 Address() {
return (static_cast<u64>(getHi) << 32) | (static_cast<u64>(get) << 2);
}
};
static_assert(sizeof(GpEntry) == sizeof(u64));
@ -140,7 +144,7 @@ namespace skyline::gpu {
inline void Fetch(const vmm::MemoryManager &memoryManager) {
segment.resize(gpEntry.size);
memoryManager.Read<u32>(segment, (static_cast<u64>(gpEntry.getHi) << 32) | (static_cast<u64>(gpEntry.get) << 2));
memoryManager.Read<u32>(segment, gpEntry.Address());
}
};

View File

@ -29,9 +29,9 @@ namespace skyline::loader {
state.logger->Info("Loaded nso 'rtld' at 0x{:X} (.text @ 0x{:X})", base, entry);
for (const auto &nso : {"main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) {
nsoFile = exeFs->OpenFile(nso);
if (nsoFile == nullptr)
if (exeFs->FileExists(nso))
nsoFile = exeFs->OpenFile(nso);
else
continue;
loadInfo = NsoLoader::LoadNso(nsoFile, process, state, offset);

View File

@ -61,7 +61,10 @@ namespace skyline::service::hid {
Result IHidServer::AcquireNpadStyleSetUpdateEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
auto id{request.Pop<NpadId>()};
response.copyHandles.push_back(state.process->InsertItem(state.input->npad.at(id).updateEvent));
auto handle{state.process->InsertItem(state.input->npad.at(id).updateEvent)};
state.logger->Debug("Npad {} Style Set Update Event Handle: 0x{:X}", id, handle);
response.copyHandles.push_back(handle);
return {};
}

View File

@ -76,7 +76,7 @@ namespace skyline::service::nvdrv {
if (event != nullptr) {
auto handle{state.process->InsertItem<type::KEvent>(event)};
state.logger->Debug("QueryEvent: FD: {}, Event ID: {}, Handle: {}", fd, eventId, handle);
state.logger->Debug("QueryEvent: FD: {}, Event ID: {}, Handle: 0x{:X}", fd, eventId, handle);
response.copyHandles.push_back(handle);
response.Push(device::NvStatus::Success);