diff options
| author | Alex Barney <thealexbarney@gmail.com> | 2019-03-03 19:45:25 -0600 |
|---|---|---|
| committer | jduncanator <1518948+jduncanator@users.noreply.github.com> | 2019-03-04 12:45:25 +1100 |
| commit | 1f554c1093dde6a4d3ed80fae2675abfb6c12fac (patch) | |
| tree | bbbdfb87999168288777ac404081f3e49c7440ae /Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs | |
| parent | 8e71ea0812f6b56ff819dbda951b463bcb5eb8dc (diff) | |
Do naming refactoring on Ryujinx.Graphics (#611)
* Renaming part 1
* Renaming part 2
* Renaming part 3
* Renaming part 4
* Renaming part 5
* Renaming part 6
* Renaming part 7
* Renaming part 8
* Renaming part 9
* Renaming part 10
* General cleanup
* Thought I got all of these
* Apply #595
* Additional renaming
* Tweaks from feedback
* Rename files
Diffstat (limited to 'Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs')
| -rw-r--r-- | Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs b/Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs new file mode 100644 index 00000000..e076be33 --- /dev/null +++ b/Ryujinx.Graphics/Gal/OpenGL/OglConstBuffer.cs @@ -0,0 +1,74 @@ +using OpenTK.Graphics.OpenGL; +using System; + +namespace Ryujinx.Graphics.Gal.OpenGL +{ + class OglConstBuffer : IGalConstBuffer + { + private const long MaxConstBufferCacheSize = 64 * 1024 * 1024; + + private OglCachedResource<OglStreamBuffer> _cache; + + public OglConstBuffer() + { + _cache = new OglCachedResource<OglStreamBuffer>(DeleteBuffer, MaxConstBufferCacheSize); + } + + public void LockCache() + { + _cache.Lock(); + } + + public void UnlockCache() + { + _cache.Unlock(); + } + + public void Create(long key, long size) + { + OglStreamBuffer buffer = new OglStreamBuffer(BufferTarget.UniformBuffer, size); + + _cache.AddOrUpdate(key, buffer, size); + } + + public bool IsCached(long key, long size) + { + return _cache.TryGetSize(key, out long cachedSize) && cachedSize == size; + } + + public void SetData(long key, long size, IntPtr hostAddress) + { + if (_cache.TryGetValue(key, out OglStreamBuffer buffer)) + { + buffer.SetData(size, hostAddress); + } + } + + public void SetData(long key, byte[] data) + { + if (_cache.TryGetValue(key, out OglStreamBuffer buffer)) + { + buffer.SetData(data); + } + } + + public bool TryGetUbo(long key, out int uboHandle) + { + if (_cache.TryGetValue(key, out OglStreamBuffer buffer)) + { + uboHandle = buffer.Handle; + + return true; + } + + uboHandle = 0; + + return false; + } + + private static void DeleteBuffer(OglStreamBuffer buffer) + { + buffer.Dispose(); + } + } +}
\ No newline at end of file |
