Commit a409dfd7 authored by Johannes Braun's avatar Johannes Braun
Browse files

Added self-deleting OpenGL handle types.

parent 35445028
......@@ -144,9 +144,9 @@ namespace glare
class Query {
public:
Query() { gl::genQueries(1, &m_id); };
explicit Query(GLuint id) : m_id(id) { };
~Query() { gl::deleteQueries(1, &m_id); };
Query() { m_handle.generate(); };
explicit Query(GLuint id) { m_handle.reset(id); };
~Query() {};
Query(Query&&) = delete;
Query& operator=(Query&& other) = delete;
......@@ -155,7 +155,7 @@ namespace glare
/**
* \brief Begins the Query GL_TIME_ELAPSED.
*/
void issue() const { gl::beginQuery(gl::QueryTarget::eTimeElapsed, m_id); };
void issue() const { gl::beginQuery(gl::QueryTarget::eTimeElapsed, m_handle); };
/**
* \brief Ends the Query GL_TIME_ELAPSED, waits for the result and returns it.
......@@ -164,12 +164,12 @@ namespace glare
GLuint64 get() const {
gl::endQuery(gl::QueryTarget::eTimeElapsed);
GLuint64 result;
gl::getQueryObjectui64v(m_id, gl::QueryObject::eResult, &result);
gl::getQueryObjectui64v(m_handle, gl::QueryObject::eResult, &result);
return result;
};
private:
GLuint m_id;
gl::handle::query m_handle;
};
ClockGL();
......
......@@ -111,7 +111,7 @@ namespace glare
gl::TextureFilterMin m_filter_min;
gl::TextureFilterMag m_filter_mag;
unsigned m_texture_id;
gl::handle::texture m_handle;
uint64_t m_texture_id_bindless;
uint64_t m_image_id_bindless;
};
......@@ -281,21 +281,20 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
Texture<Format, InternalFormat, T>::Texture(uint32_t width, uint32_t height, tex_type* data, gl::TextureFilterMin min, gl::TextureFilterMag mag)
{
gl::genTextures(1, &m_texture_id);
m_handle.generate();
m_filter_min = min;
m_filter_mag = mag;
resize(width, height, data);
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
m_texture_id_bindless = gl::getTextureHandle(m_texture_id);
m_image_id_bindless = gl::getImageHandle(m_texture_id, 0, false, 0, gl::ImageUnitFormat(InternalFormat));
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
m_texture_id_bindless = gl::getTextureHandle(m_handle);
m_image_id_bindless = gl::getImageHandle(m_handle, 0, false, 0, gl::ImageUnitFormat(InternalFormat));
gl::bindTexture(gl::TextureTarget::e2D, 0);
}
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
Texture<Format, InternalFormat, T>::~Texture()
{
glDeleteTextures(1, &m_texture_id);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
gl::makeImageHandleNonResident(m_image_id_bindless);
}
......@@ -305,7 +304,7 @@ namespace glare
{
m_width = width;
m_height = height;
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
gl::textureParameter(gl::TextureTarget::e2D, gl::TextureParameter::eWrapS, gl::TextureWrapMode::eRepeat);
gl::textureParameter(gl::TextureTarget::e2D, gl::TextureParameter::eWrapT, gl::TextureWrapMode::eRepeat);
gl::textureParameter(gl::TextureTarget::e2D, gl::TextureParameter::eMagFilter, m_filter_mag);
......@@ -321,7 +320,7 @@ namespace glare
{
m_filter_min = min;
m_filter_mag = mag;
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
gl::textureParameter(gl::TextureTarget::e2D, gl::TextureParameter::eMagFilter, m_filter_mag);
gl::textureParameter(gl::TextureTarget::e2D, gl::TextureParameter::eMinFilter, m_filter_min);
gl::bindTexture(gl::TextureTarget::e2D, 0);
......@@ -330,7 +329,7 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
void Texture<Format, InternalFormat, T>::bindToShader(std::shared_ptr<ShaderProgram> shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader->updateUniformPointer(uniform_name, m_texture_id_bindless);
......@@ -340,7 +339,7 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
void Texture<Format, InternalFormat, T>::bindToShader(const ShaderProgram &shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader.updateUniformPointer(uniform_name, m_texture_id_bindless);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
......@@ -359,13 +358,13 @@ namespace glare
template <gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint Texture<Format, InternalFormat, T>::getID() const
{
return m_texture_id;
return m_handle;
}
template <gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint64 Texture<Format, InternalFormat, T>::getResidentTextureID() const
{
gl::bindTexture(gl::TextureTarget::e2D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2D, m_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
return m_texture_id_bindless;
}
......
......@@ -45,7 +45,7 @@ namespace glare
unsigned m_width;
unsigned m_height;
unsigned m_samples;
unsigned m_texture_id;
gl::handle::texture m_texture_handle;
uint64_t m_texture_id_bindless;
};
......@@ -68,18 +68,17 @@ namespace glare
template<gl::TextureInternalFormat InternalFormat, gl::Type T>
TextureMultisampled<InternalFormat, T>::TextureMultisampled(unsigned width, unsigned height, unsigned samples)
{
gl::genTextures(1, &m_texture_id);
m_texture_handle.generate();
resize(width, height, samples);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_id);
m_texture_id_bindless = gl::getTextureHandle(m_texture_id);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_handle);
m_texture_id_bindless = gl::getTextureHandle(m_texture_handle);
gl::bindTexture(gl::TextureTarget::e2DMultisample, 0);
}
template<gl::TextureInternalFormat InternalFormat, gl::Type T>
TextureMultisampled<InternalFormat, T>::~TextureMultisampled()
{
glDeleteTextures(1, &m_texture_id);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
}
......@@ -89,7 +88,7 @@ namespace glare
m_width = width;
m_height = height;
m_samples = samples;
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_handle);
gl::pixelStorei(gl::PixelStoreAlignment::eUnpack, 1);
gl::textureImage2DMultisample(gl::TextureImageTargetMultisample2D::e2DMultisample, samples, InternalFormat, width, height, false);
gl::bindTexture(gl::TextureTarget::e2DMultisample, 0);
......@@ -98,7 +97,7 @@ namespace glare
template<gl::TextureInternalFormat InternalFormat, gl::Type T>
void TextureMultisampled<InternalFormat, T>::bindToShader(std::shared_ptr<ShaderProgram> shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader->updateUniformUInt64(uniform_name, m_texture_id_bindless);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
......@@ -107,7 +106,7 @@ namespace glare
template<gl::TextureInternalFormat InternalFormat, gl::Type T>
void TextureMultisampled<InternalFormat, T>::bindToShader(const ShaderProgram &shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader.updateUniformUInt64(uniform_name, m_texture_id_bindless);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
......@@ -116,13 +115,13 @@ namespace glare
template <gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint TextureMultisampled<InternalFormat, T>::getID() const
{
return m_texture_id;
return m_texture_handle;
}
template <gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint64 TextureMultisampled<InternalFormat, T>::getResidentTextureID() const
{
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_id);
gl::bindTexture(gl::TextureTarget::e2DMultisample, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
return m_texture_id_bindless;
}
......
......@@ -53,7 +53,7 @@ namespace glare
gl::TextureFilterMin m_filter_min;
gl::TextureFilterMag m_filter_mag;
unsigned m_texture_id;
gl::handle::texture m_texture_handle;
uint64_t m_texture_id_bindless;
uint64_t m_image_id_bindless;
};
......@@ -83,21 +83,20 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
Texture3D<Format, InternalFormat, T>::Texture3D(unsigned width, unsigned height, unsigned depth, tex_type* data, gl::TextureFilterMin min, gl::TextureFilterMag mag)
{
gl::genTextures(1, &m_texture_id);
m_texture_handle.generate();
m_filter_min = min;
m_filter_mag = mag;
resize(width, height, depth, data);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
m_texture_id_bindless = gl::getTextureHandle(m_texture_id);
m_image_id_bindless = gl::getImageHandle(m_texture_id, 0, true, 0, gl::ImageUnitFormat(InternalFormat));
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
m_texture_id_bindless = gl::getTextureHandle(m_texture_handle);
m_image_id_bindless = gl::getImageHandle(m_texture_handle, 0, true, 0, gl::ImageUnitFormat(InternalFormat));
gl::bindTexture(gl::TextureTarget::e3D, 0);
}
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
Texture3D<Format, InternalFormat, T>::~Texture3D()
{
glDeleteTextures(1, &m_texture_id);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
gl::makeImageHandleNonResident(m_image_id_bindless);
}
......@@ -108,7 +107,7 @@ namespace glare
m_width = width;
m_height = height;
m_depth = depth;
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
gl::textureParameter(gl::TextureTarget::e3D, gl::TextureParameter::eWrapS, gl::TextureWrapMode::eRepeat);
gl::textureParameter(gl::TextureTarget::e3D, gl::TextureParameter::eWrapT, gl::TextureWrapMode::eRepeat);
gl::textureParameter(gl::TextureTarget::e3D, gl::TextureParameter::eMagFilter, m_filter_mag);
......@@ -124,7 +123,7 @@ namespace glare
{
m_filter_min = min;
m_filter_mag = mag;
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
gl::textureParameter(gl::TextureTarget::e3D, gl::TextureParameter::eMagFilter, m_filter_mag);
gl::textureParameter(gl::TextureTarget::e3D, gl::TextureParameter::eMinFilter, m_filter_min);
gl::bindTexture(gl::TextureTarget::e3D, 0);
......@@ -133,7 +132,7 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
void Texture3D<Format, InternalFormat, T>::bindToShader(std::shared_ptr<ShaderProgram> shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader->updateUniformUInt64(uniform_name, m_texture_id_bindless);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
......@@ -142,7 +141,7 @@ namespace glare
template<gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
void Texture3D<Format, InternalFormat, T>::bindToShader(const ShaderProgram &shader, std::string uniform_name) const
{
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
shader.updateUniformUInt64(uniform_name, m_texture_id_bindless);
gl::makeTextureHandleNonResident(m_texture_id_bindless);
......@@ -160,13 +159,13 @@ namespace glare
template <gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint Texture3D<Format, InternalFormat, T>::getID() const
{
return m_texture_id;
return m_texture_handle;
}
template <gl::TextureFormat Format, gl::TextureInternalFormat InternalFormat, gl::Type T>
GLuint64 Texture3D<Format, InternalFormat, T>::getResidentTextureID() const
{
gl::bindTexture(gl::TextureTarget::e3D, m_texture_id);
gl::bindTexture(gl::TextureTarget::e3D, m_texture_handle);
gl::makeTextureHandleResident(m_texture_id_bindless);
return m_texture_id_bindless;
}
......
......@@ -9,7 +9,7 @@ namespace glare
Framebuffer::Framebuffer(unsigned int width, unsigned int height)
: m_width(width), m_height(height)
{
gl::genFramebuffers(1, &m_framebuffer_id);
m_handle.generate();
}
void Framebuffer::resize(unsigned int width, unsigned int height)
......@@ -30,7 +30,7 @@ namespace glare
void Framebuffer::activateDepthAttachment()
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
m_depth_attachment = std::make_unique<Texture_Float<gl::TextureFormat::eDepthComponent, gl::TextureInternalFormat::eDepthComponent32Float>>(m_width, m_height, nullptr);
......@@ -50,7 +50,7 @@ namespace glare
void Framebuffer::addColorAttachment(gl::Attachment attachment_type)
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault , m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault , m_handle);
auto attachment = new TextureRGBA_32F(m_width, m_height, nullptr);
m_color_attachments.emplace_back(attachment);
......@@ -73,7 +73,6 @@ namespace glare
Framebuffer::~Framebuffer()
{
gl::deleteFramebuffers(1, &m_framebuffer_id);
}
void Framebuffer::record(std::function<void()> render_function) const
......@@ -119,7 +118,7 @@ namespace glare
void Framebuffer::activate() const
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
}
void Framebuffer::deactivate()
......@@ -130,7 +129,7 @@ namespace glare
FramebufferMultisample::FramebufferMultisample(unsigned int width, unsigned int height, unsigned samples)
: m_width(width), m_height(height), m_samples(samples)
{
gl::genFramebuffers(1, &m_framebuffer_id);
m_handle.generate();
}
void FramebufferMultisample::resize(unsigned int width, unsigned int height, unsigned samples)
......@@ -152,7 +151,7 @@ namespace glare
void FramebufferMultisample::activateDepthAttachment()
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
m_depth_attachment = std::make_unique<TextureMultisampled_Float<gl::TextureInternalFormat::eDepthComponent32Float>>(m_width, m_height, m_samples);
......@@ -172,7 +171,7 @@ namespace glare
void FramebufferMultisample::addColorAttachment(gl::Attachment attachment_type)
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
auto attachment = new TextureMultisampledRGBA_32F(m_width, m_height, m_samples);
m_color_attachments.emplace_back(attachment);
......@@ -195,7 +194,6 @@ namespace glare
FramebufferMultisample::~FramebufferMultisample()
{
gl::deleteFramebuffers(1, &m_framebuffer_id);
}
void FramebufferMultisample::record(std::function<void()> render_function) const
......@@ -241,7 +239,7 @@ namespace glare
void FramebufferMultisample::activate() const
{
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_framebuffer_id);
gl::bindFramebuffer(gl::FramebufferTarget::eDefault, m_handle);
}
void FramebufferMultisample::deactivate()
......
......@@ -40,7 +40,7 @@ namespace glare
void addColorAttachment(gl::Attachment attachment_type);
void activateDepthAttachment();
unsigned m_framebuffer_id;
gl::handle::framebuffer m_handle;
unsigned int m_width;
unsigned int m_height;
......@@ -82,7 +82,7 @@ namespace glare
void addColorAttachment(gl::Attachment attachment_type);
void activateDepthAttachment();
unsigned m_framebuffer_id;
gl::handle::framebuffer m_handle;
unsigned m_samples;
unsigned int m_width;
......
......@@ -419,51 +419,51 @@ namespace glare
Shader::Shader(gl::ShaderType type)
{
m_shader_id = gl::createShader(type);
m_shader_handle.generate(type);
}
Shader::Shader(gl::ShaderType shader_type, fs::path path)
: Shader(shader_type)
{
m_shader_id = gl::createShader(shader_type);
std::string source = loadText((asset("/shaders/")) / path);
compileSource(source);
}
void Shader::compileSource(const std::string &source) const
void Shader::compileSource(const std::string &source)
{
auto extensions = ShaderLoader::loadExtensions(source);
ShaderLoader::checkExtensions(extensions);
const char *source_chars = source.c_str();
gl::shaderSource(m_shader_id, 1, &source_chars, nullptr);
gl::shaderSource(m_shader_handle, 1, &source_chars, nullptr);
const char* root = "/.";
int count = 1;
if (glfwExtensionSupported("GL_ARB_shading_language_include")) {
gl::compileShaderInclude(m_shader_id, 1, &root, nullptr);
gl::compileShaderInclude(m_shader_handle, 1, &root, nullptr);
} else
{
gl::compileShader(m_shader_id);
gl::compileShader(m_shader_handle);
}
int success = 0;
gl::getShaderiv(m_shader_id, gl::GetShaderParameter::eCompileStatus, &success);
gl::getShaderiv(m_shader_handle, gl::GetShaderParameter::eCompileStatus, &success);
if (!success)
{
int logSize = 200;
gl::getShaderiv(m_shader_id, gl::GetShaderParameter::eLogInfoLength, &logSize);
gl::getShaderiv(m_shader_handle, gl::GetShaderParameter::eLogInfoLength, &logSize);
char *log = new char[logSize];
gl::getShaderInfoLog(m_shader_id, logSize, &logSize, log);
gl::getShaderInfoLog(m_shader_handle, logSize, &logSize, log);
Log_Error << log;
gl::deleteShader(m_shader_id);
m_shader_handle.reset();
delete[] log;
}
else
......@@ -474,17 +474,15 @@ namespace glare
Shader::~Shader()
{
gl::deleteShader(m_shader_id);
}
VertexArray::VertexArray()
{
gl::genVertexArrays(1, &m_array_id);
m_handle.generate();
}
VertexArray::~VertexArray()
{
gl::deleteVertexArrays(1, &m_array_id);
}
void VertexArray::draw(gl::PrimitiveType primitive, size_t count, int first) const
......@@ -511,7 +509,7 @@ namespace glare
void VertexArray::bind() const
{
gl::bindVertexArray(m_array_id);
gl::bindVertexArray(m_handle);
}
void VertexArray::unbind()
......
......@@ -100,17 +100,17 @@ namespace glare
~Shader();
void compileSource(const std::string &source) const;
void compileSource(const std::string &source);
//Getters
unsigned getID() const
{
return m_shader_id;
return m_shader_handle;
}
private:
unsigned m_shader_id;
gl::handle::shader m_shader_handle;
};
/**
......@@ -171,7 +171,7 @@ namespace glare
uint64_t makeResident(gl::Access access);
private:
unsigned m_buffer_id = 0;
gl::handle::buffer m_handle;
uint64_t m_bindless_address = 0;
};
......@@ -187,16 +187,16 @@ namespace glare
void drawElements(gl::PrimitiveType primitive, size_t count, gl::Type indices_type, const Buffer<gl::BufferType::eElementArray> &element_array_buffer) const;
void bind() const;
static void unbind();
unsigned id() const { return m_array_id; }
unsigned id() const { return m_handle; }
private:
unsigned m_array_id;
gl::handle::vertex_array m_handle;
};
template<gl::BufferType Type>
Buffer<Type>::Buffer()
{
gl::genBuffers(1, &m_buffer_id);
m_handle.generate();
}
template <gl::BufferType Type>
......@@ -217,24 +217,23 @@ namespace glare
template<gl::BufferType Type>
Buffer<Type>::~Buffer()
{
if (gl::isNamedBufferResident(m_buffer_id))
if (gl::isNamedBufferResident(m_handle))
{
gl::makeNamedBufferNonResident(m_buffer_id);
gl::makeNamedBufferNonResident(m_handle);
}
gl::deleteBuffers(1, &m_buffer_id);
}
template<gl::BufferType Type>
void Buffer<Type>::bind() const
{
gl::bindBuffer(Type, m_buffer_id);
gl::bindBuffer(Type, m_handle);
}
template<gl::BufferType Type>
void Buffer<Type>::setData(size_t size, gl::BufferUsage mode, const void* data) const
{
bind();
gl::namedBufferData(m_buffer_id, size, data, mode);
gl::namedBufferData(m_handle, size, data, mode);
}
template <gl::BufferType Type>
......@@ -249,13 +248,13 @@ namespace glare
ReturnType* Buffer<Type>::map(size_t offset, size_t size, gl::BufferMapBit map_access) const
{
bind();
return reinterpret_cast<ReturnType*>(gl::mapNamedBufferRange(m_buffer_id, offset, size, map_access));
return reinterpret_cast<ReturnType*>(gl::mapNamedBufferRange(m_handle, offset, size, map_access));
}
template <gl::BufferType Type>
void Buffer<Type>::unmap() const
{
gl::unmapNamedBuffer(m_buffer_id);
gl::unmapNamedBuffer(m_handle);
}
template<gl::BufferType Type>
......@@ -264,7 +263,7 @@ namespace glare
bind();
void* output = map(offset, size, gl::BufferMapBit::eRead);
memcpy(out_data, output, size);
gl::unmapNamedBuffer(m_buffer_id);
gl::unmapNamedBuffer(m_handle);
}
template <gl::BufferType Type>
......@@ -280,7 +279,7 @@ namespace glare
void Buffer<Type>::bindToCurrentShader(int binding_point) const
{
bind();
gl::bindBufferBase(Type, binding_point, m_buffer_id);
gl::bindBufferBase(Type, binding_point, m_handle);
}
template<gl::BufferType Type>
......@@ -306,12 +305,12 @@ namespace glare
uint64_t Buffer<Type>::makeResident(gl::Access access)
{
bind();
if (!gl::isNamedBufferResident(m_buffer_id))
if (!gl::isNamedBufferResident(m_handle))
{
gl::makeNamedBufferResident(m_buffer_id, access);
gl::getNamedBufferParameterui64v(m_buffer_id, gl::GetNamedBufferParameters::eGPUAddress, &m_bindless_address);
gl::makeNamedBufferResident(m_handle, access);
gl::getNamedBufferParameterui64v(m_handle, gl::GetNamedBufferParameters::eGPUAddress, &m_bindless_address);
}
assert(gl::isNamedBufferResident(m_buffer_id));