#include <msp/gl/extensions/arb_buffer_storage.h>
#include <msp/gl/extensions/arb_direct_state_access.h>
#include <msp/gl/extensions/arb_map_buffer_range.h>
+#include <msp/gl/extensions/khr_debug.h>
#include <msp/strings/format.h>
#include "buffer.h"
+#include "deviceinfo.h"
#include "error.h"
#include "misc.h"
#include "vertexsetup.h"
void Buffer::storage(unsigned sz)
{
if(size>0)
- throw invalid_operation("Buffer::storage");
+ {
+ if(sz!=size)
+ throw incompatible_data("Buffer::storage");
+ return;
+ }
if(sz==0)
throw invalid_argument("Buffer::storage");
return true;
}
+void Buffer::set_debug_name(const string &name)
+{
+#ifdef DEBUG
+ if(KHR_debug)
+ glObjectLabel(GL_BUFFER, id, name.size(), name.c_str());
+#else
+ (void)name;
+#endif
+}
+
vector<const BufferRange *> BufferRange::bound_uniform;
{
if(type==UNIFORM_BUFFER)
{
- if(index>=get_n_uniform_buffer_bindings())
+ if(index>=Limits::get_global().max_uniform_bindings)
throw out_of_range("BufferRange::binding");
if(bound_uniform.size()<=index)
bound_uniform.resize(index+1);
unsigned BufferRange::get_n_uniform_buffer_bindings()
{
- static unsigned count = get_i(GL_MAX_UNIFORM_BUFFER_BINDINGS);
- return count;
+ return Limits::get_global().max_uniform_bindings;
}
unsigned BufferRange::get_uniform_buffer_alignment()
{
- static unsigned align = get_i(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT);
- return align;
+ return Limits::get_global().uniform_buffer_alignment;
}
} // namespace GL