mirror of https://github.com/PCSX2/pcsx2.git
GS: Add Swap() to GSTexture
This commit is contained in:
parent
ed9f34de5f
commit
69a500d657
|
@ -71,6 +71,23 @@ bool GSTexture::Save(const std::string& fn)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTexture::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
std::swap(m_scale, tex->m_scale);
|
||||||
|
std::swap(m_size, tex->m_size);
|
||||||
|
std::swap(m_committed_size, tex->m_committed_size);
|
||||||
|
std::swap(m_mipmap_levels, tex->m_mipmap_levels);
|
||||||
|
std::swap(m_type, tex->m_type);
|
||||||
|
std::swap(m_format, tex->m_format);
|
||||||
|
std::swap(m_state, tex->m_state);
|
||||||
|
std::swap(m_sparse, tex->m_sparse);
|
||||||
|
std::swap(m_needs_mipmaps_generated, tex->m_needs_mipmaps_generated);
|
||||||
|
std::swap(last_frame_used, tex->last_frame_used);
|
||||||
|
std::swap(LikelyOffset, tex->LikelyOffset);
|
||||||
|
std::swap(OffsetHack_modx, tex->OffsetHack_modx);
|
||||||
|
std::swap(OffsetHack_mody, tex->OffsetHack_mody);
|
||||||
|
}
|
||||||
|
|
||||||
void GSTexture::GenerateMipmapsIfNeeded()
|
void GSTexture::GenerateMipmapsIfNeeded()
|
||||||
{
|
{
|
||||||
if (!m_needs_mipmaps_generated || m_mipmap_levels <= 1)
|
if (!m_needs_mipmaps_generated || m_mipmap_levels <= 1)
|
||||||
|
|
|
@ -86,6 +86,7 @@ public:
|
||||||
virtual void Unmap() = 0;
|
virtual void Unmap() = 0;
|
||||||
virtual void GenerateMipmap() {}
|
virtual void GenerateMipmap() {}
|
||||||
virtual bool Save(const std::string& fn);
|
virtual bool Save(const std::string& fn);
|
||||||
|
virtual void Swap(GSTexture* tex);
|
||||||
virtual u32 GetID() { return 0; }
|
virtual u32 GetID() { return 0; }
|
||||||
|
|
||||||
GSVector2 GetScale() const { return m_scale; }
|
GSVector2 GetScale() const { return m_scale; }
|
||||||
|
|
|
@ -188,6 +188,16 @@ void GSTexture11::GenerateMipmap()
|
||||||
GSDevice11::GetInstance()->GetD3DContext()->GenerateMips(operator ID3D11ShaderResourceView*());
|
GSDevice11::GetInstance()->GetD3DContext()->GenerateMips(operator ID3D11ShaderResourceView*());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTexture11::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
GSTexture::Swap(tex);
|
||||||
|
std::swap(m_texture, static_cast<GSTexture11*>(tex)->m_texture);
|
||||||
|
std::swap(m_srv, static_cast<GSTexture11*>(tex)->m_srv);
|
||||||
|
std::swap(m_rtv, static_cast<GSTexture11*>(tex)->m_rtv);
|
||||||
|
std::swap(m_desc, static_cast<GSTexture11*>(tex)->m_desc);
|
||||||
|
std::swap(m_mapped_subresource, static_cast<GSTexture11*>(tex)->m_mapped_subresource);
|
||||||
|
}
|
||||||
|
|
||||||
GSTexture11::operator ID3D11Texture2D*()
|
GSTexture11::operator ID3D11Texture2D*()
|
||||||
{
|
{
|
||||||
return m_texture.get();
|
return m_texture.get();
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
bool Save(const std::string& fn) override;
|
bool Save(const std::string& fn) override;
|
||||||
void GenerateMipmap() override;
|
void GenerateMipmap() override;
|
||||||
|
void Swap(GSTexture* tex) override;
|
||||||
bool Equal(GSTexture11* tex);
|
bool Equal(GSTexture11* tex);
|
||||||
|
|
||||||
operator ID3D11Texture2D*();
|
operator ID3D11Texture2D*();
|
||||||
|
|
|
@ -29,6 +29,12 @@ GSTextureNull::GSTextureNull(Type type, int w, int h, GSTexture::Format format)
|
||||||
m_desc.format = format;
|
m_desc.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTextureNull::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
GSTexture::Swap(tex);
|
||||||
|
std::swap(m_desc, static_cast<GSTextureNull*>(tex)->m_desc);
|
||||||
|
}
|
||||||
|
|
||||||
void* GSTextureNull::GetNativeHandle() const
|
void* GSTextureNull::GetNativeHandle() const
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -37,5 +37,6 @@ public:
|
||||||
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override { return false; }
|
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override { return false; }
|
||||||
void Unmap() override {}
|
void Unmap() override {}
|
||||||
bool Save(const std::string& fn) override { return false; }
|
bool Save(const std::string& fn) override { return false; }
|
||||||
|
void Swap(GSTexture* tex) override;
|
||||||
void* GetNativeHandle() const override;
|
void* GetNativeHandle() const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -625,6 +625,24 @@ bool GSTextureOGL::Save(const std::string& fn)
|
||||||
return GSPng::Save(fmt, fn, image.get(), m_committed_size.x, m_committed_size.y, pitch, compression);
|
return GSPng::Save(fmt, fn, image.get(), m_committed_size.x, m_committed_size.y, pitch, compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTextureOGL::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
GSTexture::Swap(tex);
|
||||||
|
|
||||||
|
std::swap(m_texture_id, static_cast<GSTextureOGL*>(tex)->m_texture_id);
|
||||||
|
std::swap(m_fbo_read, static_cast<GSTextureOGL*>(tex)->m_fbo_read);
|
||||||
|
std::swap(m_clean, static_cast<GSTextureOGL*>(tex)->m_clean);
|
||||||
|
std::swap(m_r_x, static_cast<GSTextureOGL*>(tex)->m_r_x);
|
||||||
|
std::swap(m_r_x, static_cast<GSTextureOGL*>(tex)->m_r_y);
|
||||||
|
std::swap(m_r_w, static_cast<GSTextureOGL*>(tex)->m_r_w);
|
||||||
|
std::swap(m_r_h, static_cast<GSTextureOGL*>(tex)->m_r_h);
|
||||||
|
std::swap(m_layer, static_cast<GSTextureOGL*>(tex)->m_layer);
|
||||||
|
std::swap(m_int_format, static_cast<GSTextureOGL*>(tex)->m_int_format);
|
||||||
|
std::swap(m_int_type, static_cast<GSTextureOGL*>(tex)->m_int_type);
|
||||||
|
std::swap(m_int_shift, static_cast<GSTextureOGL*>(tex)->m_int_shift);
|
||||||
|
std::swap(m_mem_usage, static_cast<GSTextureOGL*>(tex)->m_mem_usage);
|
||||||
|
}
|
||||||
|
|
||||||
u32 GSTextureOGL::GetMemUsage()
|
u32 GSTextureOGL::GetMemUsage()
|
||||||
{
|
{
|
||||||
return m_mem_usage;
|
return m_mem_usage;
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
void Unmap() final;
|
void Unmap() final;
|
||||||
void GenerateMipmap() final;
|
void GenerateMipmap() final;
|
||||||
bool Save(const std::string& fn) final;
|
bool Save(const std::string& fn) final;
|
||||||
|
void Swap(GSTexture* tex) final;
|
||||||
|
|
||||||
GSMap Read(const GSVector4i& r, AlignedBuffer<u8, 32>& buffer);
|
GSMap Read(const GSVector4i& r, AlignedBuffer<u8, 32>& buffer);
|
||||||
bool IsDss() { return (m_type == Type::DepthStencil || m_type == Type::SparseDepthStencil); }
|
bool IsDss() { return (m_type == Type::DepthStencil || m_type == Type::SparseDepthStencil); }
|
||||||
|
|
|
@ -94,3 +94,11 @@ bool GSTextureSW::Save(const std::string& fn)
|
||||||
int compression = theApp.GetConfigI("png_compression_level");
|
int compression = theApp.GetConfigI("png_compression_level");
|
||||||
return GSPng::Save(fmt, fn, static_cast<u8*>(m_data), m_size.x, m_size.y, m_pitch, compression);
|
return GSPng::Save(fmt, fn, static_cast<u8*>(m_data), m_size.x, m_size.y, m_pitch, compression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTextureSW::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
GSTexture::Swap(tex);
|
||||||
|
std::swap(m_pitch, static_cast<GSTextureSW*>(tex)->m_pitch);
|
||||||
|
std::swap(m_data, static_cast<GSTextureSW*>(tex)->m_data);
|
||||||
|
// std::swap(m_mapped, static_cast<GSTextureSW*>(tex)->m_mapped);
|
||||||
|
}
|
||||||
|
|
|
@ -33,5 +33,6 @@ public:
|
||||||
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override;
|
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override;
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
bool Save(const std::string& fn) override;
|
bool Save(const std::string& fn) override;
|
||||||
|
void Swap(GSTexture* tex) override;
|
||||||
void* GetNativeHandle() const override;
|
void* GetNativeHandle() const override;
|
||||||
};
|
};
|
||||||
|
|
|
@ -361,6 +361,17 @@ void GSTextureVK::GenerateMipmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GSTextureVK::Swap(GSTexture* tex)
|
||||||
|
{
|
||||||
|
GSTexture::Swap(tex);
|
||||||
|
std::swap(m_texture, static_cast<GSTextureVK*>(tex)->m_texture);
|
||||||
|
std::swap(m_use_fence_counter, static_cast<GSTextureVK*>(tex)->m_use_fence_counter);
|
||||||
|
std::swap(m_clear_value, static_cast<GSTextureVK*>(tex)->m_clear_value);
|
||||||
|
std::swap(m_map_area, static_cast<GSTextureVK*>(tex)->m_map_area);
|
||||||
|
std::swap(m_map_level, static_cast<GSTextureVK*>(tex)->m_map_level);
|
||||||
|
std::swap(m_framebuffers, static_cast<GSTextureVK*>(tex)->m_framebuffers);
|
||||||
|
}
|
||||||
|
|
||||||
void GSTextureVK::TransitionToLayout(VkImageLayout layout)
|
void GSTextureVK::TransitionToLayout(VkImageLayout layout)
|
||||||
{
|
{
|
||||||
m_texture.TransitionToLayout(g_vulkan_context->GetCurrentCommandBuffer(), layout);
|
m_texture.TransitionToLayout(g_vulkan_context->GetCurrentCommandBuffer(), layout);
|
||||||
|
|
|
@ -50,6 +50,7 @@ public:
|
||||||
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override;
|
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) override;
|
||||||
void Unmap() override;
|
void Unmap() override;
|
||||||
void GenerateMipmap() override;
|
void GenerateMipmap() override;
|
||||||
|
void Swap(GSTexture* tex) override;
|
||||||
|
|
||||||
void TransitionToLayout(VkImageLayout layout);
|
void TransitionToLayout(VkImageLayout layout);
|
||||||
void CommitClear();
|
void CommitClear();
|
||||||
|
|
Loading…
Reference in New Issue