]> git.tdb.fi Git - libs/gl.git/commitdiff
Deprecate some Buffer features which don't translate to Vulkan
authorMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 00:48:21 +0000 (02:48 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 25 Jan 2021 00:48:21 +0000 (02:48 +0200)
source/buffer.cpp
source/buffer.h
source/bufferable.cpp
source/programdata.cpp
source/texture2d.cpp

index 91aa4028a1bc3d9279fffddc7912825762a03c36..35975f1712ed2973c10a926d55812a9efb1c2f3c 100644 (file)
@@ -85,31 +85,24 @@ BufferRange *Buffer::create_range(unsigned s, unsigned o)
        return new BufferRange(*this, s, o);
 }
 
-void *Buffer::map(BufferAccess access)
+void *Buffer::map()
 {
        if(ARB_map_buffer_range)
        {
-               GLenum access_bits = 0;
-               if(access==READ_ONLY)
-                       access_bits = GL_MAP_READ_BIT;
-               else if(access==WRITE_ONLY)
-                       access_bits = GL_MAP_WRITE_BIT;
-               else if(access==READ_WRITE)
-                       access_bits = GL_MAP_READ_BIT|GL_MAP_WRITE_BIT;
                if(ARB_direct_state_access)
-                       return glMapNamedBufferRange(id, 0, size, access_bits);
+                       return glMapNamedBufferRange(id, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT);
                else
                {
                        BindRestore _bind(this, type);
-                       return glMapBufferRange(type, 0, size, access_bits);
+                       return glMapBufferRange(type, 0, size, GL_MAP_READ_BIT|GL_MAP_WRITE_BIT);
                }
        }
        else if(ARB_direct_state_access)
-               return glMapNamedBuffer(id, access);
+               return glMapNamedBuffer(id, GL_READ_WRITE);
        else if(OES_mapbuffer)
        {
                BindRestore _bind(this, type);
-               return glMapBuffer(type, access);
+               return glMapBuffer(type, GL_READ_WRITE);
        }
        else
                throw invalid_operation("Buffer::map");
index fc9ace78c0ac0f48194a20fdcb1a8e4012be01e1..2961cdb315ae70802847e8b5e414e325f512aa4f 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdexcept>
 #include <string>
 #include <vector>
+#include <msp/core/attributes.h>
 #include "gl.h"
 #include <msp/gl/extensions/arb_pixel_buffer_object.h>
 #include <msp/gl/extensions/arb_vertex_buffer_object.h>
@@ -84,7 +85,7 @@ public:
 
        /** Sets the usage hint of the buffer.  It will take effect the next time
        the buffer's contents are defined. */
-       void set_usage(BufferUsage);
+       DEPRECATED void set_usage(BufferUsage);
 
        /** Uploads data into the buffer, completely replacing any previous
        contents. */
@@ -100,7 +101,8 @@ public:
 
        BufferRange *create_range(unsigned, unsigned);
 
-       void *map(BufferAccess);
+       void *map();
+       DEPRECATED void *map(BufferAccess) { return map(); }
        bool unmap();
 
        /** Binds the buffer in its default slot. */
index 6124f7616660bc62507928f1965c83947adb1ec6..fc0e3d21a203972b29e65165a5d09dd33241ba09 100644 (file)
@@ -138,7 +138,7 @@ Bufferable::AsyncUpdater::AsyncUpdater(const Bufferable &b):
        bufferable(b)
 {
        bufferable.buffer->require_size(bufferable.get_required_buffer_size());
-       mapped_address = reinterpret_cast<char *>(bufferable.buffer->map(WRITE_ONLY));
+       mapped_address = reinterpret_cast<char *>(bufferable.buffer->map());
 }
 
 Bufferable::AsyncUpdater::~AsyncUpdater()
index 68a6715d419c847c173ba56ab5cc0dac6c329878..1589d9b0d44e00258d2457fc1f8acb0def28b23e 100644 (file)
@@ -513,10 +513,7 @@ ProgramData::SharedBlock *ProgramData::get_shared_block(const Program::UniformBl
                if(info.bind_point>=0)
                {
                        if(!buffer)
-                       {
                                buffer = new Buffer(UNIFORM_BUFFER);
-                               buffer->set_usage(STREAM_DRAW);
-                       }
 
                        block = new UniformBlock(info.data_size);
                        block->use_buffer(buffer, last_block);
index daede1836332ca9c2b72a41edf5634a99a09abb1..dac671fdfa52fcae265d088b2cb9d14f918a9a56 100644 (file)
@@ -252,8 +252,8 @@ bool Texture2D::AsyncLoader::process()
        }
        else if(phase==1)
        {
-               pixel_buffer.data(n_bytes, 0);
-               mapped_address = reinterpret_cast<char *>(pixel_buffer.map(WRITE_ONLY));
+               pixel_buffer.storage(n_bytes);
+               mapped_address = reinterpret_cast<char *>(pixel_buffer.map());
        }
        else if(phase==2)
        {