From ffe1debbd757d20f7250fd8572c2c46cd901f559 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 25 Jan 2021 02:48:21 +0200 Subject: [PATCH] Deprecate some Buffer features which don't translate to Vulkan --- source/buffer.cpp | 17 +++++------------ source/buffer.h | 6 ++++-- source/bufferable.cpp | 2 +- source/programdata.cpp | 3 --- source/texture2d.cpp | 4 ++-- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/source/buffer.cpp b/source/buffer.cpp index 91aa4028..35975f17 100644 --- a/source/buffer.cpp +++ b/source/buffer.cpp @@ -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"); diff --git a/source/buffer.h b/source/buffer.h index fc9ace78..2961cdb3 100644 --- a/source/buffer.h +++ b/source/buffer.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "gl.h" #include #include @@ -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. */ diff --git a/source/bufferable.cpp b/source/bufferable.cpp index 6124f761..fc0e3d21 100644 --- a/source/bufferable.cpp +++ b/source/bufferable.cpp @@ -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(bufferable.buffer->map(WRITE_ONLY)); + mapped_address = reinterpret_cast(bufferable.buffer->map()); } Bufferable::AsyncUpdater::~AsyncUpdater() diff --git a/source/programdata.cpp b/source/programdata.cpp index 68a6715d..1589d9b0 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -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); diff --git a/source/texture2d.cpp b/source/texture2d.cpp index daede183..dac671fd 100644 --- a/source/texture2d.cpp +++ b/source/texture2d.cpp @@ -252,8 +252,8 @@ bool Texture2D::AsyncLoader::process() } else if(phase==1) { - pixel_buffer.data(n_bytes, 0); - mapped_address = reinterpret_cast(pixel_buffer.map(WRITE_ONLY)); + pixel_buffer.storage(n_bytes); + mapped_address = reinterpret_cast(pixel_buffer.map()); } else if(phase==2) { -- 2.45.2