diff options
| author | 2023-06-24 21:58:23 -0400 | |
|---|---|---|
| committer | 2023-06-30 21:49:59 -0400 | |
| commit | 310b6cf4af940fa07666400426bbcca815c5375c (patch) | |
| tree | d3de4ddab952c5404be38035ece48773c0be41ac /src/core/hle/service/nvdrv | |
| parent | ring_buffer: Fix const usage on std::span (diff) | |
| download | yuzu-310b6cf4af940fa07666400426bbcca815c5375c.tar.gz yuzu-310b6cf4af940fa07666400426bbcca815c5375c.tar.xz yuzu-310b6cf4af940fa07666400426bbcca815c5375c.zip | |
general: Use ScratchBuffer where possible
Diffstat (limited to 'src/core/hle/service/nvdrv')
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.cpp | 25 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.h | 5 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 348207e25..c8a880e84 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // SPDX-FileCopyrightText: 2021 Skyline Team and Contributors | 2 | // SPDX-FileCopyrightText: 2021 Skyline Team and Contributors |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later | 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | 4 | ||
| 5 | #include <cinttypes> | ||
| 6 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 6 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/kernel/k_event.h" |
| @@ -63,12 +62,12 @@ void NVDRV::Ioctl1(HLERequestContext& ctx) { | |||
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | // Check device | 64 | // Check device |
| 66 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 65 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 67 | const auto input_buffer = ctx.ReadBuffer(0); | 66 | const auto input_buffer = ctx.ReadBuffer(0); |
| 68 | 67 | ||
| 69 | const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, tmp_output); | 68 | const auto nv_result = nvdrv->Ioctl1(fd, command, input_buffer, output_buffer); |
| 70 | if (command.is_out != 0) { | 69 | if (command.is_out != 0) { |
| 71 | ctx.WriteBuffer(tmp_output); | 70 | ctx.WriteBuffer(output_buffer); |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | IPC::ResponseBuilder rb{ctx, 3}; | 73 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -90,12 +89,12 @@ void NVDRV::Ioctl2(HLERequestContext& ctx) { | |||
| 90 | 89 | ||
| 91 | const auto input_buffer = ctx.ReadBuffer(0); | 90 | const auto input_buffer = ctx.ReadBuffer(0); |
| 92 | const auto input_inlined_buffer = ctx.ReadBuffer(1); | 91 | const auto input_inlined_buffer = ctx.ReadBuffer(1); |
| 93 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 92 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 94 | 93 | ||
| 95 | const auto nv_result = | 94 | const auto nv_result = |
| 96 | nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, tmp_output); | 95 | nvdrv->Ioctl2(fd, command, input_buffer, input_inlined_buffer, output_buffer); |
| 97 | if (command.is_out != 0) { | 96 | if (command.is_out != 0) { |
| 98 | ctx.WriteBuffer(tmp_output); | 97 | ctx.WriteBuffer(output_buffer); |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | IPC::ResponseBuilder rb{ctx, 3}; | 100 | IPC::ResponseBuilder rb{ctx, 3}; |
| @@ -116,12 +115,14 @@ void NVDRV::Ioctl3(HLERequestContext& ctx) { | |||
| 116 | } | 115 | } |
| 117 | 116 | ||
| 118 | const auto input_buffer = ctx.ReadBuffer(0); | 117 | const auto input_buffer = ctx.ReadBuffer(0); |
| 119 | tmp_output.resize_destructive(ctx.GetWriteBufferSize(0)); | 118 | output_buffer.resize_destructive(ctx.GetWriteBufferSize(0)); |
| 120 | tmp_output_inline.resize_destructive(ctx.GetWriteBufferSize(1)); | 119 | inline_output_buffer.resize_destructive(ctx.GetWriteBufferSize(1)); |
| 121 | const auto nv_result = nvdrv->Ioctl3(fd, command, input_buffer, tmp_output, tmp_output_inline); | 120 | |
| 121 | const auto nv_result = | ||
| 122 | nvdrv->Ioctl3(fd, command, input_buffer, output_buffer, inline_output_buffer); | ||
| 122 | if (command.is_out != 0) { | 123 | if (command.is_out != 0) { |
| 123 | ctx.WriteBuffer(tmp_output, 0); | 124 | ctx.WriteBuffer(output_buffer, 0); |
| 124 | ctx.WriteBuffer(tmp_output_inline, 1); | 125 | ctx.WriteBuffer(inline_output_buffer, 1); |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 127 | IPC::ResponseBuilder rb{ctx, 3}; | 128 | IPC::ResponseBuilder rb{ctx, 3}; |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.h b/src/core/hle/service/nvdrv/nvdrv_interface.h index 4b593ff90..6e98115dc 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.h +++ b/src/core/hle/service/nvdrv/nvdrv_interface.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | |||
| 7 | #include "common/scratch_buffer.h" | 8 | #include "common/scratch_buffer.h" |
| 8 | #include "core/hle/service/nvdrv/nvdrv.h" | 9 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| @@ -34,8 +35,8 @@ private: | |||
| 34 | 35 | ||
| 35 | u64 pid{}; | 36 | u64 pid{}; |
| 36 | bool is_initialized{}; | 37 | bool is_initialized{}; |
| 37 | Common::ScratchBuffer<u8> tmp_output; | 38 | Common::ScratchBuffer<u8> output_buffer; |
| 38 | Common::ScratchBuffer<u8> tmp_output_inline; | 39 | Common::ScratchBuffer<u8> inline_output_buffer; |
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | } // namespace Service::Nvidia | 42 | } // namespace Service::Nvidia |