gsdx mipmap: extend texture/cache to support a layer parameter

This commit is contained in:
Gregory Hainaut 2016-09-30 21:36:52 +02:00
parent b695e0065a
commit 76bd968c59
12 changed files with 36 additions and 36 deletions

View File

@ -43,8 +43,8 @@ public:
virtual operator bool() {ASSERT(0); return false;}
virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0;
virtual bool Map(GSMap& m, const GSVector4i* r = NULL) = 0;
virtual bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) = 0;
virtual bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) = 0;
virtual void Unmap() = 0;
virtual bool Save(const string& fn, bool dds = false) = 0;
virtual uint32 GetID() { return 0; }

View File

@ -46,7 +46,7 @@ GSTexture11::GSTexture11(ID3D11Texture2D* texture)
m_msaa = m_desc.SampleDesc.Count > 1;
}
bool GSTexture11::Update(const GSVector4i& r, const void* data, int pitch)
bool GSTexture11::Update(const GSVector4i& r, const void* data, int pitch, int layer)
{
if(m_dev && m_texture)
{
@ -60,7 +60,7 @@ bool GSTexture11::Update(const GSVector4i& r, const void* data, int pitch)
return false;
}
bool GSTexture11::Map(GSMap& m, const GSVector4i* r)
bool GSTexture11::Map(GSMap& m, const GSVector4i* r, int layer)
{
if(r != NULL)
{

View File

@ -37,8 +37,8 @@ class GSTexture11 : public GSTexture
public:
explicit GSTexture11(ID3D11Texture2D* texture);
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(GSMap& m, const GSVector4i* r);
bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0);
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0);
void Unmap();
bool Save(const string& fn, bool dds = false);

View File

@ -77,7 +77,7 @@ GSTexture9::~GSTexture9()
{
}
bool GSTexture9::Update(const GSVector4i& r, const void* data, int pitch)
bool GSTexture9::Update(const GSVector4i& r, const void* data, int pitch, int layer)
{
if(m_surface)
{
@ -114,7 +114,7 @@ bool GSTexture9::Update(const GSVector4i& r, const void* data, int pitch)
return false;
}
bool GSTexture9::Map(GSMap& m, const GSVector4i* r)
bool GSTexture9::Map(GSMap& m, const GSVector4i* r, int layer)
{
HRESULT hr;

View File

@ -35,8 +35,8 @@ public:
explicit GSTexture9(IDirect3DTexture9* texture);
virtual ~GSTexture9();
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(GSMap& m, const GSVector4i* r);
bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0);
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0);
void Unmap();
bool Save(const string& fn, bool dds = false);

View File

@ -1531,7 +1531,7 @@ GSTextureCache::Surface::~Surface()
m_renderer->m_dev->Recycle(m_texture);
}
void GSTextureCache::Surface::Update()
void GSTextureCache::Surface::UpdateAge()
{
m_age = 0;
}
@ -1589,9 +1589,9 @@ GSTextureCache::Source::~Source()
_aligned_free(m_write.rect);
}
void GSTextureCache::Source::Update(const GSVector4i& rect)
void GSTextureCache::Source::Update(const GSVector4i& rect, int layer)
{
Surface::Update();
Surface::UpdateAge();
if(m_complete || m_target)
{
@ -1635,7 +1635,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect)
{
m_valid[row] |= col;
Write(GSVector4i(x, y, x + bs.x, y + bs.y));
Write(GSVector4i(x, y, x + bs.x, y + bs.y), layer);
blocks++;
}
@ -1662,7 +1662,7 @@ void GSTextureCache::Source::Update(const GSVector4i& rect)
{
m_valid[row] |= col;
Write(GSVector4i(x, y, x + bs.x, y + bs.y));
Write(GSVector4i(x, y, x + bs.x, y + bs.y), layer);
blocks++;
}
@ -1675,11 +1675,11 @@ void GSTextureCache::Source::Update(const GSVector4i& rect)
{
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, bs.x * bs.y * blocks << (m_palette ? 2 : 0));
Flush(m_write.count);
Flush(m_write.count, layer);
}
}
void GSTextureCache::Source::Write(const GSVector4i& r)
void GSTextureCache::Source::Write(const GSVector4i& r, int layer)
{
m_write.rect[m_write.count++] = r;
@ -1708,11 +1708,11 @@ void GSTextureCache::Source::Write(const GSVector4i& r)
if(m_write.count > 2)
{
Flush(1);
Flush(1, layer);
}
}
void GSTextureCache::Source::Flush(uint32 count)
void GSTextureCache::Source::Flush(uint32 count, int layer)
{
// This function as written will not work for paletted formats copied from framebuffers
// because they are 8 or 4 bit formats on the GS and the GS local memory module reads
@ -1798,7 +1798,7 @@ GSTextureCache::Target::Target(GSRenderer* r, const GIFRegTEX0& TEX0, uint8* tem
void GSTextureCache::Target::Update()
{
Surface::Update();
Surface::UpdateAge();
// FIXME: the union of the rects may also update wrong parts of the render target (but a lot faster :)
// GH: it must be doable

View File

@ -47,15 +47,15 @@ public:
Surface(GSRenderer* r, uint8* temp);
virtual ~Surface();
virtual void Update();
void UpdateAge();
};
class Source : public Surface
{
struct {GSVector4i* rect; uint32 count;} m_write;
void Write(const GSVector4i& r);
void Flush(uint32 count);
void Write(const GSVector4i& r, int layer);
void Flush(uint32 count, int layer);
public:
GSTexture* m_palette;
@ -76,7 +76,7 @@ public:
Source(GSRenderer* r, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, uint8* temp, bool dummy_container = false);
virtual ~Source();
virtual void Update(const GSVector4i& rect);
void Update(const GSVector4i& rect, int layer = 0);
};
class Target : public Surface
@ -96,7 +96,7 @@ public:
void UpdateValidity(const GSVector4i& rect);
bool Inside(uint32 bp, uint32 bw, uint32 psm, const GSVector4i& rect);
virtual void Update();
void Update();
};
class SourceMap

View File

@ -34,8 +34,8 @@ public:
int GetType() const {return m_desc.type;}
int GetFormat() const {return m_desc.format;}
bool Update(const GSVector4i& r, const void* data, int pitch) {return true;}
bool Map(GSMap& m, const GSVector4i* r) {return false;}
bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) {return true;}
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0) {return false;}
void Unmap() {}
bool Save(const string& fn, bool dds = false) {return false;}
};

View File

@ -302,7 +302,7 @@ void GSTextureOGL::Clear(const void* data, const GSVector4i& area)
glClearTexSubImage(m_texture_id, GL_TEX_LEVEL_0, area.x, area.y, 0, area.width(), area.height(), 1, m_int_format, m_int_type, data);
}
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int layer)
{
ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen);
@ -367,7 +367,7 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
return true;
}
bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r)
bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer)
{
GSVector4i r = _r ? *_r : GSVector4i(0, 0, m_size.x, m_size.y);
// Will need some investigation

View File

@ -65,8 +65,8 @@ class GSTextureOGL final : public GSTexture
explicit GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read);
virtual ~GSTextureOGL();
bool Update(const GSVector4i& r, const void* data, int pitch) final;
bool Map(GSMap& m, const GSVector4i* r = NULL) final;
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;
void Unmap() final;
bool Save(const string& fn, bool dds = false) final;

View File

@ -38,7 +38,7 @@ GSTextureSW::~GSTextureSW()
_aligned_free(m_data);
}
bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch)
bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch, int layer)
{
GSMap m;
@ -62,7 +62,7 @@ bool GSTextureSW::Update(const GSVector4i& r, const void* data, int pitch)
return false;
}
bool GSTextureSW::Map(GSMap& m, const GSVector4i* r)
bool GSTextureSW::Map(GSMap& m, const GSVector4i* r, int layer)
{
GSVector4i r2 = r != NULL ? *r : GSVector4i(0, 0, m_size.x, m_size.y);

View File

@ -23,7 +23,7 @@
#include "GSTexture.h"
class GSTextureSW : public GSTexture
class GSTextureSW final : public GSTexture
{
// mem texture, always 32-bit rgba (might add 8-bit for palette if needed)
@ -35,8 +35,8 @@ public:
GSTextureSW(int type, int width, int height);
virtual ~GSTextureSW();
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(GSMap& m, const GSVector4i* r);
bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0);
bool Map(GSMap& m, const GSVector4i* r = NULL, int layer = 0);
void Unmap();
bool Save(const string& fn, bool dds = false);
};