summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Morph2021-01-28 01:18:06 -0500
committerGravatar Morph2021-01-28 01:32:24 -0500
commit008afa5d5951b5390fccdd9c677718bc4335cc35 (patch)
tree6d39403c7cf7357af2efb7815cacc9c2a4964663 /src/core
parentMerge pull request #5786 from ReinUsesLisp/glsl-cbuf (diff)
downloadyuzu-008afa5d5951b5390fccdd9c677718bc4335cc35.tar.gz
yuzu-008afa5d5951b5390fccdd9c677718bc4335cc35.tar.xz
yuzu-008afa5d5951b5390fccdd9c677718bc4335cc35.zip
hle_ipc: Add Can(Read, Write)Buffer
Allows us to test whether a buffer can be read from or written to memory
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp22
-rw-r--r--src/core/hle/kernel/hle_ipc.h6
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 83decf6cf..a419f9602 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -338,6 +338,28 @@ std::size_t HLERequestContext::GetWriteBufferSize(std::size_t buffer_index) cons
338 return 0; 338 return 0;
339} 339}
340 340
341bool HLERequestContext::CanReadBuffer(std::size_t buffer_index) const {
342 const bool is_buffer_a{BufferDescriptorA().size() > buffer_index &&
343 BufferDescriptorA()[buffer_index].Size()};
344
345 if (is_buffer_a) {
346 return BufferDescriptorA().size() > buffer_index;
347 } else {
348 return BufferDescriptorX().size() > buffer_index;
349 }
350}
351
352bool HLERequestContext::CanWriteBuffer(std::size_t buffer_index) const {
353 const bool is_buffer_b{BufferDescriptorB().size() > buffer_index &&
354 BufferDescriptorB()[buffer_index].Size()};
355
356 if (is_buffer_b) {
357 return BufferDescriptorB().size() > buffer_index;
358 } else {
359 return BufferDescriptorC().size() > buffer_index;
360 }
361}
362
341std::string HLERequestContext::Description() const { 363std::string HLERequestContext::Description() const {
342 if (!command_header) { 364 if (!command_header) {
343 return "No command header available"; 365 return "No command header available";
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index b112e1ebd..698f607e6 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -207,6 +207,12 @@ public:
207 /// Helper function to get the size of the output buffer 207 /// Helper function to get the size of the output buffer
208 std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const; 208 std::size_t GetWriteBufferSize(std::size_t buffer_index = 0) const;
209 209
210 /// Helper function to test whether the input buffer at buffer_index can be read
211 bool CanReadBuffer(std::size_t buffer_index = 0) const;
212
213 /// Helper function to test whether the output buffer at buffer_index can be written
214 bool CanWriteBuffer(std::size_t buffer_index = 0) const;
215
210 template <typename T> 216 template <typename T>
211 std::shared_ptr<T> GetCopyObject(std::size_t index) { 217 std::shared_ptr<T> GetCopyObject(std::size_t index) {
212 return DynamicObjectCast<T>(copy_objects.at(index)); 218 return DynamicObjectCast<T>(copy_objects.at(index));