]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/buffer.cpp
Fix reflection of image types from Spir-V modules
[libs/gl.git] / source / core / buffer.cpp
index 240fcd72754b67babe7a28b9ee2fe42a80f1fe4b..4a36937e7b745d1dd32f8c1e9ce19df0766037d7 100644 (file)
@@ -8,7 +8,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-void Buffer::storage(size_t sz)
+void Buffer::storage(size_t sz, BufferUsage u)
 {
        if(size>0)
        {
@@ -20,6 +20,7 @@ void Buffer::storage(size_t sz)
                throw invalid_argument("Buffer::storage");
 
        size = sz;
+       usage = u;
 
        allocate();
 }
@@ -45,5 +46,23 @@ void Buffer::require_size(size_t req_sz) const
                throw buffer_too_small(format("buffer has %d bytes; %d required", size, req_sz));
 }
 
+void *Buffer::map()
+{
+       if(!can_map() || mapped)
+               throw invalid_operation("Buffer::map");
+       void *result = BufferBackend::map();
+       mapped = true;
+       return result;
+}
+
+bool Buffer::unmap()
+{
+       if(!can_map() || !mapped)
+               throw invalid_operation("Buffer::map");
+       bool result = BufferBackend::unmap();
+       mapped = false;
+       return result;
+}
+
 } // namespace GL
 } // namespace Msp