diff options
author | Markus Wick <markus@selfnet.de> | 2018-08-29 00:27:03 +0200 |
---|---|---|
committer | Markus Wick <markus@selfnet.de> | 2018-09-05 08:03:50 +0200 |
commit | 50a806ea671114c92b7905182a0a9140148415b2 (patch) | |
tree | 9a70d16050f9ee4edb84e923ed92fc15ed9d4482 /src/video_core/renderer_opengl/gl_buffer_cache.h | |
parent | Merge pull request #1240 from degasus/optimizations (diff) | |
download | yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar.gz yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar.bz2 yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar.lz yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar.xz yuzu-50a806ea671114c92b7905182a0a9140148415b2.tar.zst yuzu-50a806ea671114c92b7905182a0a9140148415b2.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_buffer_cache.h')
-rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h new file mode 100644 index 000000000..9c7ad27e6 --- /dev/null +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h @@ -0,0 +1,57 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <unordered_map> + +#include "common/common_types.h" +#include "video_core/rasterizer_cache.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" +#include "video_core/renderer_opengl/gl_stream_buffer.h" + +namespace OpenGL { + +struct CachedBufferEntry final { + VAddr GetAddr() const { + return addr; + } + + size_t GetSizeInBytes() const { + return size; + } + + VAddr addr; + size_t size; + GLintptr offset; + size_t alignment; +}; + +class OGLBufferCache final : public RasterizerCache<std::shared_ptr<CachedBufferEntry>> { +public: + OGLBufferCache(size_t size); + + GLintptr UploadMemory(Tegra::GPUVAddr gpu_addr, size_t size, size_t alignment = 4, + bool cache = true); + + GLintptr UploadHostMemory(const void* raw_pointer, size_t size, size_t alignment = 4); + + void Map(size_t max_size); + void Unmap(); + + GLuint GetHandle(); + +protected: + void AlignBuffer(size_t alignment); + +private: + OGLStreamBuffer stream_buffer; + + u8* buffer_ptr; + GLintptr buffer_offset; + GLintptr buffer_offset_base; +}; + +} // namespace OpenGL |