summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/memory.h68
-rw-r--r--src/video_core/memory_manager.h3
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp4
4 files changed, 75 insertions, 4 deletions
diff --git a/src/core/memory.h b/src/core/memory.h
index 97750f851..b92d678a4 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -294,6 +294,24 @@ public:
294 void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, 294 void ReadBlock(const Kernel::Process& process, VAddr src_addr, void* dest_buffer,
295 std::size_t size); 295 std::size_t size);
296 296
297 /**
298 * Reads a contiguous block of bytes from a specified process' address space.
299 * This unsafe version does not trigger GPU flushing.
300 *
301 * @param process The process to read the data from.
302 * @param src_addr The virtual address to begin reading from.
303 * @param dest_buffer The buffer to place the read bytes into.
304 * @param size The amount of data to read, in bytes.
305 *
306 * @note If a size of 0 is specified, then this function reads nothing and
307 * no attempts to access memory are made at all.
308 *
309 * @pre dest_buffer must be at least size bytes in length, otherwise a
310 * buffer overrun will occur.
311 *
312 * @post The range [dest_buffer, size) contains the read bytes from the
313 * process' address space.
314 */
297 void ReadBlockUnsafe(const Kernel::Process& process, VAddr src_addr, void* dest_buffer, 315 void ReadBlockUnsafe(const Kernel::Process& process, VAddr src_addr, void* dest_buffer,
298 std::size_t size); 316 std::size_t size);
299 317
@@ -315,6 +333,23 @@ public:
315 */ 333 */
316 void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size); 334 void ReadBlock(VAddr src_addr, void* dest_buffer, std::size_t size);
317 335
336 /**
337 * Reads a contiguous block of bytes from the current process' address space.
338 * This unsafe version does not trigger GPU flushing.
339 *
340 * @param src_addr The virtual address to begin reading from.
341 * @param dest_buffer The buffer to place the read bytes into.
342 * @param size The amount of data to read, in bytes.
343 *
344 * @note If a size of 0 is specified, then this function reads nothing and
345 * no attempts to access memory are made at all.
346 *
347 * @pre dest_buffer must be at least size bytes in length, otherwise a
348 * buffer overrun will occur.
349 *
350 * @post The range [dest_buffer, size) contains the read bytes from the
351 * current process' address space.
352 */
318 void ReadBlockUnsafe(VAddr src_addr, void* dest_buffer, std::size_t size); 353 void ReadBlockUnsafe(VAddr src_addr, void* dest_buffer, std::size_t size);
319 354
320 /** 355 /**
@@ -340,6 +375,23 @@ public:
340 void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, 375 void WriteBlock(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,
341 std::size_t size); 376 std::size_t size);
342 377
378 /**
379 * Writes a range of bytes into a given process' address space at the specified
380 * virtual address.
381 * This unsafe version does not invalidate GPU Memory.
382 *
383 * @param process The process to write data into the address space of.
384 * @param dest_addr The destination virtual address to begin writing the data at.
385 * @param src_buffer The data to write into the process' address space.
386 * @param size The size of the data to write, in bytes.
387 *
388 * @post The address range [dest_addr, size) in the process' address space
389 * contains the data that was within src_buffer.
390 *
391 * @post If an attempt is made to write into an unmapped region of memory, the writes
392 * will be ignored and an error will be logged.
393 *
394 */
343 void WriteBlockUnsafe(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer, 395 void WriteBlockUnsafe(const Kernel::Process& process, VAddr dest_addr, const void* src_buffer,
344 std::size_t size); 396 std::size_t size);
345 397
@@ -364,6 +416,22 @@ public:
364 */ 416 */
365 void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size); 417 void WriteBlock(VAddr dest_addr, const void* src_buffer, std::size_t size);
366 418
419 /**
420 * Writes a range of bytes into the current process' address space at the specified
421 * virtual address.
422 * This unsafe version does not invalidate GPU Memory.
423 *
424 * @param dest_addr The destination virtual address to begin writing the data at.
425 * @param src_buffer The data to write into the current process' address space.
426 * @param size The size of the data to write, in bytes.
427 *
428 * @post The address range [dest_addr, size) in the current process' address space
429 * contains the data that was within src_buffer.
430 *
431 * @post If an attempt is made to write into an unmapped region of memory, the writes
432 * will be ignored and an error will be logged.
433 *
434 */
367 void WriteBlockUnsafe(VAddr dest_addr, const void* src_buffer, std::size_t size); 435 void WriteBlockUnsafe(VAddr dest_addr, const void* src_buffer, std::size_t size);
368 436
369 /** 437 /**
diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h
index 987400fdd..0d9468535 100644
--- a/src/video_core/memory_manager.h
+++ b/src/video_core/memory_manager.h
@@ -97,6 +97,9 @@ public:
97 void WriteBlockUnsafe(GPUVAddr dest_addr, const void* src_buffer, std::size_t size); 97 void WriteBlockUnsafe(GPUVAddr dest_addr, const void* src_buffer, std::size_t size);
98 void CopyBlockUnsafe(GPUVAddr dest_addr, GPUVAddr src_addr, std::size_t size); 98 void CopyBlockUnsafe(GPUVAddr dest_addr, GPUVAddr src_addr, std::size_t size);
99 99
100 /**
101 * IsGranularRange checks if a gpu region can be simply read with a pointer
102 */
100 bool IsGranularRange(GPUVAddr gpu_addr, std::size_t size); 103 bool IsGranularRange(GPUVAddr gpu_addr, std::size_t size);
101 104
102private: 105private:
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 93a6c72f8..368f399df 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -658,7 +658,7 @@ void RasterizerOpenGL::FlushAll() {}
658 658
659void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) { 659void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {
660 MICROPROFILE_SCOPE(OpenGL_CacheManagement); 660 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
661 if (!addr || !size) { 661 if (addr == 0 || size == 0) {
662 return; 662 return;
663 } 663 }
664 texture_cache.FlushRegion(addr, size); 664 texture_cache.FlushRegion(addr, size);
@@ -668,7 +668,7 @@ void RasterizerOpenGL::FlushRegion(VAddr addr, u64 size) {
668 668
669void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) { 669void RasterizerOpenGL::InvalidateRegion(VAddr addr, u64 size) {
670 MICROPROFILE_SCOPE(OpenGL_CacheManagement); 670 MICROPROFILE_SCOPE(OpenGL_CacheManagement);
671 if (!addr || !size) { 671 if (addr == 0 || size == 0) {
672 return; 672 return;
673 } 673 }
674 texture_cache.InvalidateRegion(addr, size); 674 texture_cache.InvalidateRegion(addr, size);
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 1466018fa..30eaeba6c 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -496,7 +496,7 @@ void RasterizerVulkan::Query(GPUVAddr gpu_addr, VideoCore::QueryType type,
496void RasterizerVulkan::FlushAll() {} 496void RasterizerVulkan::FlushAll() {}
497 497
498void RasterizerVulkan::FlushRegion(VAddr addr, u64 size) { 498void RasterizerVulkan::FlushRegion(VAddr addr, u64 size) {
499 if (!addr || !size) { 499 if (addr == 0 || size == 0) {
500 return; 500 return;
501 } 501 }
502 CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr)); 502 CacheAddr cache_addr = ToCacheAddr(system.Memory().GetPointer(addr));
@@ -506,7 +506,7 @@ void RasterizerVulkan::FlushRegion(VAddr addr, u64 size) {
506} 506}
507 507
508void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size) { 508void RasterizerVulkan::InvalidateRegion(VAddr addr, u64 size) {
509 if (!addr || !size) { 509 if (addr == 0 || size == 0) {
510 return; 510 return;
511 } 511 }
512 texture_cache.InvalidateRegion(addr, size); 512 texture_cache.InvalidateRegion(addr, size);