X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fbuffer.cpp;h=013a136a560a2a5866ee6bf7c343b0102cf9e246;hb=4d146fba83f1ee7b8bd2249648a66db51857730f;hp=17e833d71dfee347e7f3b46c885bc674aa0de864;hpb=4ae2ffa3057af9524a84ba322c0db32d6fcae8f2;p=libs%2Fgl.git diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 17e833d7..013a136a 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -2,8 +2,10 @@ #include #include #include +#include #include #include "buffer.h" +#include "deviceinfo.h" #include "error.h" #include "misc.h" #include "vertexsetup.h" @@ -146,26 +148,16 @@ BufferRange *Buffer::create_range(unsigned s, unsigned o) void *Buffer::map() { + static Require _req(ARB_map_buffer_range); + allocate(); - if(ARB_map_buffer_range) - { - if(ARB_direct_state_access) - return glMapNamedBufferRange(id, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); - else - { - BindRestore _bind(this, type); - return glMapBufferRange(type, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); - } - } - else if(ARB_direct_state_access) - return glMapNamedBuffer(id, GL_READ_WRITE); - else if(OES_mapbuffer) + if(ARB_direct_state_access) + return glMapNamedBufferRange(id, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); + else { BindRestore _bind(this, type); - return glMapBuffer(type, GL_READ_WRITE); + return glMapBufferRange(type, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT); } - else - throw invalid_operation("Buffer::map"); } bool Buffer::unmap() @@ -237,6 +229,16 @@ bool Buffer::set_current(BufferType type, const Buffer *buf) 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 BufferRange::bound_uniform; @@ -286,7 +288,7 @@ const BufferRange *&BufferRange::binding(BufferType type, unsigned index) { 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); @@ -308,14 +310,12 @@ bool BufferRange::set_current(BufferType type, unsigned index, const BufferRange 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