2011-11-16 22:17:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011-2011 Gregory hainaut
|
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
*
|
|
|
|
* This Program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This Program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2011-11-16 22:17:37 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-11-16 18:41:37 +00:00
|
|
|
#include "Renderers/Common/GSTexture.h"
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2013-08-17 09:05:41 +00:00
|
|
|
namespace PboPool {
|
2016-06-17 07:42:12 +00:00
|
|
|
inline void BindPbo();
|
|
|
|
inline void UnbindPbo();
|
|
|
|
inline void Sync();
|
2013-08-17 09:05:41 +00:00
|
|
|
|
2016-06-17 07:42:12 +00:00
|
|
|
inline char* Map(uint32 size);
|
|
|
|
inline void Unmap();
|
|
|
|
inline uptr Offset();
|
|
|
|
inline void EndTransfer();
|
2013-08-03 08:29:01 +00:00
|
|
|
|
|
|
|
void Init();
|
|
|
|
void Destroy();
|
|
|
|
}
|
|
|
|
|
2016-04-04 22:01:43 +00:00
|
|
|
class GSTextureOGL final : public GSTexture
|
2011-11-16 22:17:37 +00:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
GLuint m_texture_id; // the texture id
|
2012-01-08 21:59:42 +00:00
|
|
|
GLuint m_fbo_read;
|
2015-05-12 16:03:06 +00:00
|
|
|
bool m_clean;
|
2016-10-02 08:41:18 +00:00
|
|
|
bool m_generate_mipmap;
|
2011-11-16 22:17:37 +00:00
|
|
|
|
2015-05-18 09:29:04 +00:00
|
|
|
uint8* m_local_buffer;
|
2016-03-18 19:20:23 +00:00
|
|
|
// Avoid alignment constrain
|
|
|
|
//GSVector4i m_r;
|
|
|
|
int m_r_x;
|
|
|
|
int m_r_y;
|
|
|
|
int m_r_w;
|
|
|
|
int m_r_h;
|
2016-09-30 18:04:24 +00:00
|
|
|
int m_layer;
|
|
|
|
int m_max_layer;
|
2016-03-18 19:20:23 +00:00
|
|
|
|
2013-08-02 16:38:12 +00:00
|
|
|
// internal opengl format/type/alignment
|
|
|
|
GLenum m_int_format;
|
|
|
|
GLenum m_int_type;
|
|
|
|
uint32 m_int_shift;
|
|
|
|
|
2016-07-07 19:33:59 +00:00
|
|
|
// Allow to track size of allocated memory
|
|
|
|
uint32 m_mem_usage;
|
|
|
|
|
2011-11-16 22:17:37 +00:00
|
|
|
public:
|
2016-09-30 18:04:24 +00:00
|
|
|
explicit GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, bool mipmap);
|
2011-11-16 22:17:37 +00:00
|
|
|
virtual ~GSTextureOGL();
|
|
|
|
|
2016-09-30 19:36:52 +00:00
|
|
|
bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) final;
|
|
|
|
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) final;
|
2016-04-04 20:48:10 +00:00
|
|
|
void Unmap() final;
|
2016-10-02 08:41:18 +00:00
|
|
|
void GenerateMipmap() final;
|
2018-12-25 20:16:14 +00:00
|
|
|
bool Save(const std::string& fn) final;
|
2011-11-21 22:36:03 +00:00
|
|
|
|
2011-12-21 23:09:36 +00:00
|
|
|
bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); }
|
2019-02-17 06:02:32 +00:00
|
|
|
bool IsDss() { return (m_type == GSTexture::DepthStencil || m_type == GSTexture::SparseDepthStencil); }
|
2012-01-31 17:08:05 +00:00
|
|
|
|
2016-04-04 20:48:10 +00:00
|
|
|
uint32 GetID() final { return m_texture_id; }
|
2015-05-15 13:24:43 +00:00
|
|
|
bool HasBeenCleaned() { return m_clean; }
|
2016-04-21 19:07:17 +00:00
|
|
|
void WasAttached() { m_clean = false; }
|
2015-05-15 13:24:43 +00:00
|
|
|
void WasCleaned() { m_clean = true; }
|
2015-07-10 19:11:14 +00:00
|
|
|
|
2016-05-15 11:11:21 +00:00
|
|
|
void Clear(const void* data);
|
|
|
|
void Clear(const void* data, const GSVector4i& area);
|
|
|
|
|
2019-02-07 11:17:15 +00:00
|
|
|
void CommitPages(const GSVector2i& region, bool commit) final;
|
|
|
|
|
2015-07-10 19:11:14 +00:00
|
|
|
uint32 GetMemUsage();
|
2011-11-16 22:17:37 +00:00
|
|
|
};
|