GSdx: just fixing slow texture uploads with dx9... (odin sphere back to 40-50 fps)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1279 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2009-05-28 02:57:01 +00:00
parent 50332c1cd1
commit 4bc698d698
10 changed files with 56 additions and 19 deletions

View File

@ -40,7 +40,7 @@ public:
virtual int GetHeight() const = 0; virtual int GetHeight() const = 0;
virtual int GetFormat() const = 0; virtual int GetFormat() const = 0;
virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0; virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0;
virtual bool Map(uint8** bits, int& pitch) = 0; virtual bool Map(uint8** bits, int& pitch, const GSVector4i* r = NULL) = 0;
virtual void Unmap() = 0; virtual void Unmap() = 0;
virtual bool Save(const string& fn, bool dds = false) = 0; virtual bool Save(const string& fn, bool dds = false) = 0;

View File

@ -83,8 +83,15 @@ bool GSTexture10::Update(const GSVector4i& r, const void* data, int pitch)
return false; return false;
} }
bool GSTexture10::Map(uint8** bits, int& pitch) bool GSTexture10::Map(uint8** bits, int& pitch, const GSVector4i* r)
{ {
if(r != NULL)
{
// ASSERT(0); // not implemented
return false;
}
if(m_texture) if(m_texture)
{ {
D3D10_MAPPED_TEXTURE2D map; D3D10_MAPPED_TEXTURE2D map;

View File

@ -44,7 +44,7 @@ public:
int GetHeight() const; int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch); bool Map(uint8** bits, int& pitch, const GSVector4i* r);
void Unmap(); void Unmap();
bool Save(const string& fn, bool dds = false); bool Save(const string& fn, bool dds = false);

View File

@ -133,10 +133,17 @@ bool GSTexture7::Update(const GSVector4i& r, const void* data, int pitch)
return false; return false;
} }
bool GSTexture7::Map(uint8** bits, int& pitch) bool GSTexture7::Map(uint8** bits, int& pitch, const GSVector4i* r)
{ {
HRESULT hr; HRESULT hr;
if(r != NULL)
{
// ASSERT(0); // not implemented
return false;
}
DDSURFACEDESC2 desc; DDSURFACEDESC2 desc;
if(SUCCEEDED(hr = m_system->Lock(NULL, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL))) if(SUCCEEDED(hr = m_system->Lock(NULL, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL)))

View File

@ -44,7 +44,7 @@ public:
int GetHeight() const; int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch); bool Map(uint8** bits, int& pitch, const GSVector4i* r);
void Unmap(); void Unmap();
bool Save(const string& fn, bool dds = false); bool Save(const string& fn, bool dds = false);

View File

@ -113,7 +113,7 @@ bool GSTexture9::Update(const GSVector4i& r, const void* data, int pitch)
return false; return false;
} }
bool GSTexture9::Map(uint8** bits, int& pitch) bool GSTexture9::Map(uint8** bits, int& pitch, const GSVector4i* r)
{ {
HRESULT hr; HRESULT hr;
@ -121,7 +121,7 @@ bool GSTexture9::Map(uint8** bits, int& pitch)
{ {
D3DLOCKED_RECT lr; D3DLOCKED_RECT lr;
if(SUCCEEDED(hr = surface->LockRect(&lr, NULL, 0))) if(SUCCEEDED(hr = surface->LockRect(&lr, (LPRECT)r, 0)))
{ {
*bits = (uint8*)lr.pBits; *bits = (uint8*)lr.pBits;
pitch = (int)lr.Pitch; pitch = (int)lr.Pitch;

View File

@ -43,7 +43,7 @@ public:
int GetHeight() const; int GetHeight() const;
int GetFormat() const; int GetFormat() const;
bool Update(const GSVector4i& r, const void* data, int pitch); bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch); bool Map(uint8** bits, int& pitch, const GSVector4i* r);
void Unmap(); void Unmap();
bool Save(const string& fn, bool dds = false); bool Save(const string& fn, bool dds = false);

View File

@ -698,20 +698,41 @@ void GSTextureCache::GSCachedTexture::Update()
m_valid = m_valid.runion(r); m_valid = m_valid.runion(r);
static uint8* bits = (uint8*)::_aligned_malloc(1024 * 1024 * 4, 16); uint8* bits = NULL;
int pitch = 0;
int pitch = ((r.width() + 3) & ~3) * 4; if(m_texture->Map(&bits, pitch, &r))
if(m_renderer->m_psrr)
{ {
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP); // in dx9 managed textures can be written directly, less copying is faster, but still not as fast as dx10's UpdateResource
if(m_renderer->m_psrr)
{
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
else
{
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
m_texture->Unmap();
} }
else else
{ {
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP); static uint8* buff = (uint8*)::_aligned_malloc(1024 * 1024 * 4, 16);
}
m_texture->Update(r, bits, pitch); pitch = ((r.width() + 3) & ~3) * 4;
if(m_renderer->m_psrr)
{
m_renderer->m_mem.ReadTextureNPNC(r, buff, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
else
{
m_renderer->m_mem.ReadTextureNP(r, buff, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
m_texture->Update(r, buff, pitch);
}
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, r.width() * r.height() * m_bpp >> 3); m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, r.width() * r.height() * m_bpp >> 3);
} }

View File

@ -38,7 +38,7 @@ public:
int GetHeight() const {return m_desc.h;} int GetHeight() const {return m_desc.h;}
int GetFormat() const {return m_desc.format;} int GetFormat() const {return m_desc.format;}
bool Update(const GSVector4i& r, const void* data, int pitch) {return true;} bool Update(const GSVector4i& r, const void* data, int pitch) {return true;}
bool Map(uint8** bits, int& pitch) {return true;} bool Map(uint8** bits, int& pitch, const GSVector4i* r) {return false;}
void Unmap() {} void Unmap() {}
bool Save(const string& fn, bool dds = false) {return false;} bool Save(const string& fn, bool dds = false) {return false;}
}; };

View File

@ -174,7 +174,9 @@ bool GSUtil::IsDirect3D10Available()
char* GSUtil::GetLibName() char* GSUtil::GetLibName()
{ {
static string str = format("GSdx %d", SVN_REV); static string str;
str = format("GSdx %d", SVN_REV);
if(SVN_MODS) str += "m"; if(SVN_MODS) str += "m";