mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-03-10 07:24:54 +01:00
gl: Add support for subviews
This commit is contained in:
parent
07abde4e8d
commit
0f1735d0df
|
|
@ -318,6 +318,34 @@ namespace gl
|
|||
}
|
||||
}
|
||||
|
||||
texture_view* texture_view::as(GLenum format)
|
||||
{
|
||||
if (format == this->m_view_format)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
auto self = m_root_view ? m_root_view : this;
|
||||
if (auto found = self->m_subviews.find(format);
|
||||
found != self->m_subviews.end())
|
||||
{
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
GLenum swizzle_argb[4] =
|
||||
{
|
||||
component_swizzle[3],
|
||||
component_swizzle[0],
|
||||
component_swizzle[1],
|
||||
component_swizzle[2],
|
||||
};
|
||||
|
||||
auto view = std::make_unique<texture_view>(m_image_data, m_target, format, swizzle_argb, m_aspect_flags);
|
||||
auto ret = view.get();
|
||||
self->m_subviews.emplace(format, std::move(view));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void texture_view::bind(gl::command_context& cmd, GLuint layer) const
|
||||
{
|
||||
cmd->bind_texture(layer, m_target, m_id);
|
||||
|
|
|
|||
|
|
@ -353,7 +353,10 @@ namespace gl
|
|||
GLenum m_aspect_flags = 0;
|
||||
texture* m_image_data = nullptr;
|
||||
|
||||
GLenum component_swizzle[4] {};
|
||||
GLenum component_swizzle[4]{};
|
||||
|
||||
std::unordered_map<GLenum, std::unique_ptr<texture_view>> m_subviews;
|
||||
texture_view* m_root_view = nullptr;
|
||||
|
||||
texture_view() = default;
|
||||
|
||||
|
|
@ -395,6 +398,8 @@ namespace gl
|
|||
|
||||
virtual ~texture_view();
|
||||
|
||||
texture_view* as(GLenum format);
|
||||
|
||||
GLuint id() const
|
||||
{
|
||||
return m_id;
|
||||
|
|
|
|||
Loading…
Reference in a new issue