1
1

GL: Remove lingering image binds

This updates image bind tracking to be the same as texture binds.
Adding a new bind flag to avoid conflict when the texture is used in
both slots.
Fixes a gl error in glBindImageTextures about invalid image binds.
This commit is contained in:
2022-08-01 17:57:33 +02:00
parent d629402054
commit 04d43e8dbb
3 changed files with 6 additions and 3 deletions

View File

@@ -563,14 +563,14 @@ void GLStateManager::image_bind(Texture *tex_, int unit)
}
images_[unit] = tex->tex_id_;
formats_[unit] = to_gl_internal_format(tex->format_);
tex->is_bound_ = true;
tex->is_bound_image_ = true;
dirty_image_binds_ |= 1ULL << unit;
}
void GLStateManager::image_unbind(Texture *tex_)
{
GLTexture *tex = static_cast<GLTexture *>(tex_);
if (!tex->is_bound_) {
if (!tex->is_bound_image_) {
return;
}
@@ -581,7 +581,7 @@ void GLStateManager::image_unbind(Texture *tex_)
dirty_image_binds_ |= 1ULL << i;
}
}
tex->is_bound_ = false;
tex->is_bound_image_ = false;
}
void GLStateManager::image_unbind_all()

View File

@@ -40,6 +40,7 @@ GLTexture::~GLTexture()
if (ctx != nullptr && is_bound_) {
/* This avoid errors when the texture is still inside the bound texture array. */
ctx->state_manager->texture_unbind(this);
ctx->state_manager->image_unbind(this);
}
GLContext::tex_free(tex_id_);
}

View File

@@ -37,6 +37,8 @@ class GLTexture : public Texture {
/** True if this texture is bound to at least one texture unit. */
/* TODO(fclem): How do we ensure thread safety here? */
bool is_bound_ = false;
/** Same as is_bound_ but for image slots. */
bool is_bound_image_ = false;
/** True if pixels in the texture have been initialized. */
bool has_pixels_ = false;