mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
gl: Track image destruction and remove handles from state tracker
- Handles are reused for different resources which can cause problems
This commit is contained in:
parent
d577cebd89
commit
8185bfe893
4 changed files with 39 additions and 11 deletions
|
@ -336,6 +336,7 @@ namespace gl
|
||||||
temp_image_cache.clear();
|
temp_image_cache.clear();
|
||||||
resources.clear();
|
resources.clear();
|
||||||
font_cache.clear();
|
font_cache.clear();
|
||||||
|
view_cache.clear();
|
||||||
overlay_pass::destroy();
|
overlay_pass::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,6 +123,13 @@ namespace gl
|
||||||
m_format_class = format_class;
|
m_format_class = format_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
texture::~texture()
|
||||||
|
{
|
||||||
|
gl::get_command_context()->unbind_texture(static_cast<GLenum>(m_target), m_id);
|
||||||
|
glDeleteTextures(1, &m_id);
|
||||||
|
m_id = GL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void texture::copy_from(const void* src, texture::format format, texture::type type, int level, const coord3u region, const pixel_unpack_settings& pixel_settings)
|
void texture::copy_from(const void* src, texture::format format, texture::type type, int level, const coord3u region, const pixel_unpack_settings& pixel_settings)
|
||||||
{
|
{
|
||||||
pixel_settings.apply();
|
pixel_settings.apply();
|
||||||
|
@ -260,6 +267,13 @@ namespace gl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
texture_view::~texture_view()
|
||||||
|
{
|
||||||
|
gl::get_command_context()->unbind_texture(static_cast<GLenum>(m_target), m_id);
|
||||||
|
glDeleteTextures(1, &m_id);
|
||||||
|
m_id = GL_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
void texture_view::bind(gl::command_context& cmd, GLuint layer) const
|
void texture_view::bind(gl::command_context& cmd, GLuint layer) const
|
||||||
{
|
{
|
||||||
cmd->bind_texture(layer, m_target, m_id);
|
cmd->bind_texture(layer, m_target, m_id);
|
||||||
|
|
|
@ -159,12 +159,7 @@ namespace gl
|
||||||
texture(texture&& texture_) = delete;
|
texture(texture&& texture_) = delete;
|
||||||
|
|
||||||
texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLenum sized_format, rsx::format_class format_class = rsx::RSX_FORMAT_CLASS_UNDEFINED);
|
texture(GLenum target, GLuint width, GLuint height, GLuint depth, GLuint mipmaps, GLenum sized_format, rsx::format_class format_class = rsx::RSX_FORMAT_CLASS_UNDEFINED);
|
||||||
|
virtual ~texture();
|
||||||
virtual ~texture()
|
|
||||||
{
|
|
||||||
glDeleteTextures(1, &m_id);
|
|
||||||
m_id = GL_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Getters/setters
|
// Getters/setters
|
||||||
void set_native_component_layout(const std::array<GLenum, 4>& layout)
|
void set_native_component_layout(const std::array<GLenum, 4>& layout)
|
||||||
|
@ -324,11 +319,7 @@ namespace gl
|
||||||
create(data, target, sized_format, aspect_flags, argb_swizzle);
|
create(data, target, sized_format, aspect_flags, argb_swizzle);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~texture_view()
|
virtual ~texture_view();
|
||||||
{
|
|
||||||
glDeleteTextures(1, &m_id);
|
|
||||||
m_id = GL_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint id() const
|
GLuint id() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -300,6 +300,28 @@ namespace gl
|
||||||
bound = name;
|
bound = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void unbind_texture(GLenum target, GLuint name)
|
||||||
|
{
|
||||||
|
// To be called with glDeleteTextures.
|
||||||
|
// OpenGL internally unbinds the texture on delete, but then reuses the same ID when GenTextures is called again!
|
||||||
|
// This can also be avoided using unique internal names, such as 64-bit handles, but that involves changing a lot of code for little benefit
|
||||||
|
for (auto& layer : bound_textures)
|
||||||
|
{
|
||||||
|
if (layer.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto found = layer.find(target);
|
||||||
|
found != layer.end() && found->second == name)
|
||||||
|
{
|
||||||
|
// Actually still bound!
|
||||||
|
found->second = GL_NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class command_context
|
class command_context
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue