From 0ee97a0d8527c2212e5f47b4ed2b1bb3c41ab062 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Sun, 4 Feb 2018 23:06:21 -0800 Subject: [PATCH] Fixed up naming/structs/enums. Used vector instead of array for "gpfifo_entry" --- .../hle/service/nvdrv/devices/nvhost_gpu.cpp | 34 +++++++++---------- .../hle/service/nvdrv/devices/nvhost_gpu.h | 31 ++++++++--------- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 81c7a4c8d6..ba51bce19e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -15,22 +15,22 @@ u32 nvhost_gpu::ioctl(u32 command, const std::vector& input, std::vector LOG_DEBUG(Service_NVDRV, "Got Ioctl 0x%x, inputsz: 0x%x, outputsz: 0x%x", command, input.size(), output.size()); - switch (command) { - case IocSetNVMAPfdCommand: + switch (static_cast(command)) { + case IoctlCommand::IocSetNVMAPfdCommand: return SetNVMAPfd(input, output); - case IocSetClientDataCommand: + case IoctlCommand::IocSetClientDataCommand: return SetClientData(input, output); - case IocGetClientDataCommand: + case IoctlCommand::IocGetClientDataCommand: return GetClientData(input, output); - case IocZCullBind: + case IoctlCommand::IocZCullBind: return ZCullBind(input, output); - case IocSetErrorNotifierCommand: + case IoctlCommand::IocSetErrorNotifierCommand: return SetErrorNotifier(input, output); - case IocChannelSetPriorityCommand: + case IoctlCommand::IocChannelSetPriorityCommand: return SetChannelPriority(input, output); - case IocAllocGPFIFOEx2Command: + case IoctlCommand::IocAllocGPFIFOEx2Command: return AllocGPFIFOEx2(input, output); - case IocAllocObjCtxCommand: + case IoctlCommand::IocAllocObjCtxCommand: return AllocateObjectContext(input, output); } @@ -103,10 +103,10 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector& input, std::vector& ou std::memcpy(¶ms, input.data(), input.size()); LOG_WARNING(Service_NVDRV, "(STUBBED) called, num_entries=%x, flags=%x, unk0=%x, unk1=%x, unk2=%x, unk3=%x", - params.__num_entries, params.__flags, params.__unk0, params.__unk1, params.__unk2, - params.__unk3); - params.__fence_out.id = 0; - params.__fence_out.value = 0; + params.num_entries, params.flags, params.unk0, params.unk1, params.unk2, + params.unk3); + params.fence_out.id = 0; + params.fence_out.value = 0; std::memcpy(output.data(), ¶ms, output.size()); return 0; } @@ -129,9 +129,10 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector& input, std::vector& outp LOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo=%lx, num_entries=%x, flags=%x", params.gpfifo, params.num_entries, params.flags); - gpfifo_entry* entries = new gpfifo_entry[params.num_entries]; - std::memcpy(entries, &input.data()[24], params.num_entries * 8); - for (int i = 0; i < params.num_entries; i++) { + auto entries = std::vector(); + entries.resize(params.num_entries); + std::memcpy(&entries[0], &input.data()[24], params.num_entries * 8); + for (u32 i = 0; i < params.num_entries; i++) { u32 unk1 = (entries[i].entry1 >> 8) & 0x3; u32 sz = (entries[i].entry1 >> 10) & 0x1fffff; u32 unk2 = entries[i].entry1 >> 31; @@ -141,7 +142,6 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector& input, std::vector& outp params.fence_out.id = 0; params.fence_out.value = 0; std::memcpy(output.data(), ¶ms, output.size()); - delete[] entries; return 0; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index 623d769c5d..f07a0f2e1a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h @@ -21,7 +21,7 @@ public: u32 ioctl(u32 command, const std::vector& input, std::vector& output) override; private: - enum IoctlCommands { + enum class IoctlCommand : u32 { IocSetNVMAPfdCommand = 0x40044801, IocSetClientDataCommand = 0x40084714, IocGetClientDataCommand = 0x80084715, @@ -33,12 +33,12 @@ private: }; enum CtxObjects { - _2D = 0x902D, - _3D = 0xB197, - _Compute = 0xB1C0, - _Kepler = 0xA140, - _DMA = 0xB0B5, - _Channel_GPFIFO = 0xB06F, + Ctx2D = 0x902D, + Ctx3D = 0xB197, + CtxCompute = 0xB1C0, + CtxKepler = 0xA140, + CtxDMA = 0xB0B5, + CtxChannelGPFIFO = 0xB06F, }; struct set_nvmap_fd { @@ -68,13 +68,13 @@ private: }; struct alloc_gpfifo_ex2 { - u32_le __num_entries; // in - u32_le __flags; // in - u32_le __unk0; // in (1 works) - struct fence __fence_out; // out - u32_le __unk1; // in - u32_le __unk2; // in - u32_le __unk3; // in + u32_le num_entries; // in + u32_le flags; // in + u32_le unk0; // in (1 works) + fence fence_out; // out + u32_le unk1; // in + u32_le unk2; // in + u32_le unk3; // in }; struct alloc_obj_ctx { @@ -93,8 +93,7 @@ private: u64_le gpfifo; // (ignored) pointer to gpfifo fence structs u32_le num_entries; // number of fence objects being submitted u32_le flags; - struct fence fence_out; // returned new fence object for others to wait on - struct gpfifo_entry entries[]; // depends on num_entries + fence fence_out; // returned new fence object for others to wait on }; u32_le nvmap_fd{};