On Vulkan static buffers will be stored on non-host-visible memory and
can't be mapped. Already-mapped buffers also can't be mapped.
bool OpenGLBuffer::unmap()
{
- // TODO check if it's mapped
if(ARB_direct_state_access)
return glUnmapNamedBuffer(id);
else if(OES_mapbuffer)
void allocate();
void sub_data(size_t, size_t, const void *);
+ bool can_map() const { return true; }
void *map();
bool unmap();
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
void require_size(std::size_t) const;
- using BufferBackend::map;
- using BufferBackend::unmap;
+ void *map();
+ bool unmap();
using BufferBackend::set_debug_name;
};