summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Liam2024-02-23 22:38:21 -0500
committerGravatar Liam2024-02-26 11:16:14 -0500
commitd66ca8b73145c9e891415f11ce68125ff2b99b9b (patch)
tree70c4d8b3e8aa80222940fe6e490d62bf42bc0443 /src/core
parentMerge pull request #13164 from merryhime/reset-submodules (diff)
downloadyuzu-d66ca8b73145c9e891415f11ce68125ff2b99b9b.tar.gz
yuzu-d66ca8b73145c9e891415f11ce68125ff2b99b9b.tar.xz
yuzu-d66ca8b73145c9e891415f11ce68125ff2b99b9b.zip
video_core: make gpu context aware of rendering program
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp21
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_gpu.h3
2 files changed, 18 insertions, 6 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
index bf12d69a5..efc9cca1c 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp
@@ -5,6 +5,7 @@
5#include "common/assert.h" 5#include "common/assert.h"
6#include "common/logging/log.h" 6#include "common/logging/log.h"
7#include "core/core.h" 7#include "core/core.h"
8#include "core/hle/kernel/k_process.h"
8#include "core/hle/service/nvdrv/core/container.h" 9#include "core/hle/service/nvdrv/core/container.h"
9#include "core/hle/service/nvdrv/core/nvmap.h" 10#include "core/hle/service/nvdrv/core/nvmap.h"
10#include "core/hle/service/nvdrv/core/syncpoint_manager.h" 11#include "core/hle/service/nvdrv/core/syncpoint_manager.h"
@@ -75,7 +76,7 @@ NvResult nvhost_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> inpu
75 case 0xd: 76 case 0xd:
76 return WrapFixed(this, &nvhost_gpu::SetChannelPriority, input, output); 77 return WrapFixed(this, &nvhost_gpu::SetChannelPriority, input, output);
77 case 0x1a: 78 case 0x1a:
78 return WrapFixed(this, &nvhost_gpu::AllocGPFIFOEx2, input, output); 79 return WrapFixed(this, &nvhost_gpu::AllocGPFIFOEx2, input, output, fd);
79 case 0x1b: 80 case 0x1b:
80 return WrapFixedVariable(this, &nvhost_gpu::SubmitGPFIFOBase1, input, output, true); 81 return WrapFixedVariable(this, &nvhost_gpu::SubmitGPFIFOBase1, input, output, true);
81 case 0x1d: 82 case 0x1d:
@@ -120,8 +121,13 @@ NvResult nvhost_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span<const u8> inpu
120 return NvResult::NotImplemented; 121 return NvResult::NotImplemented;
121} 122}
122 123
123void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {} 124void nvhost_gpu::OnOpen(NvCore::SessionId session_id, DeviceFD fd) {
124void nvhost_gpu::OnClose(DeviceFD fd) {} 125 sessions[fd] = session_id;
126}
127
128void nvhost_gpu::OnClose(DeviceFD fd) {
129 sessions.erase(fd);
130}
125 131
126NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) { 132NvResult nvhost_gpu::SetNVMAPfd(IoctlSetNvmapFD& params) {
127 LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd); 133 LOG_DEBUG(Service_NVDRV, "called, fd={}", params.nvmap_fd);
@@ -161,7 +167,7 @@ NvResult nvhost_gpu::SetChannelPriority(IoctlChannelSetPriority& params) {
161 return NvResult::Success; 167 return NvResult::Success;
162} 168}
163 169
164NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params) { 170NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params, DeviceFD fd) {
165 LOG_WARNING(Service_NVDRV, 171 LOG_WARNING(Service_NVDRV,
166 "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, " 172 "(STUBBED) called, num_entries={:X}, flags={:X}, unk0={:X}, "
167 "unk1={:X}, unk2={:X}, unk3={:X}", 173 "unk1={:X}, unk2={:X}, unk3={:X}",
@@ -173,7 +179,12 @@ NvResult nvhost_gpu::AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params) {
173 return NvResult::AlreadyAllocated; 179 return NvResult::AlreadyAllocated;
174 } 180 }
175 181
176 system.GPU().InitChannel(*channel_state); 182 u64 program_id{};
183 if (auto* const session = core.GetSession(sessions[fd]); session != nullptr) {
184 program_id = session->process->GetProgramId();
185 }
186
187 system.GPU().InitChannel(*channel_state, program_id);
177 188
178 params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint); 189 params.fence_out = syncpoint_manager.GetSyncpointFence(channel_syncpoint);
179 190
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
index e34a978db..e0aeef953 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h
@@ -192,7 +192,7 @@ private:
192 NvResult ZCullBind(IoctlZCullBind& params); 192 NvResult ZCullBind(IoctlZCullBind& params);
193 NvResult SetErrorNotifier(IoctlSetErrorNotifier& params); 193 NvResult SetErrorNotifier(IoctlSetErrorNotifier& params);
194 NvResult SetChannelPriority(IoctlChannelSetPriority& params); 194 NvResult SetChannelPriority(IoctlChannelSetPriority& params);
195 NvResult AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params); 195 NvResult AllocGPFIFOEx2(IoctlAllocGpfifoEx2& params, DeviceFD fd);
196 NvResult AllocateObjectContext(IoctlAllocObjCtx& params); 196 NvResult AllocateObjectContext(IoctlAllocObjCtx& params);
197 197
198 NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, Tegra::CommandList&& entries); 198 NvResult SubmitGPFIFOImpl(IoctlSubmitGpfifo& params, Tegra::CommandList&& entries);
@@ -210,6 +210,7 @@ private:
210 NvCore::SyncpointManager& syncpoint_manager; 210 NvCore::SyncpointManager& syncpoint_manager;
211 NvCore::NvMap& nvmap; 211 NvCore::NvMap& nvmap;
212 std::shared_ptr<Tegra::Control::ChannelState> channel_state; 212 std::shared_ptr<Tegra::Control::ChannelState> channel_state;
213 std::unordered_map<DeviceFD, NvCore::SessionId> sessions;
213 u32 channel_syncpoint; 214 u32 channel_syncpoint;
214 std::mutex channel_mutex; 215 std::mutex channel_mutex;
215 216