gsdx hw: use non virtual Create Texture function.

Just do the format check in FetchSurface. It removes a level of virtual function
and avoid useless code duplication.
This commit is contained in:
Gregory Hainaut 2019-01-30 13:10:34 +01:00 committed by lightningterror
parent f25fe48c9b
commit dbffad2aef
5 changed files with 10 additions and 53 deletions

View File

@ -175,10 +175,10 @@ public:
virtual void ClearDepth(GSTexture* t) {} virtual void ClearDepth(GSTexture* t) {}
virtual void ClearStencil(GSTexture* t, uint8 c) {} virtual void ClearStencil(GSTexture* t, uint8 c) {}
virtual GSTexture* CreateRenderTarget(int w, int h, int format = 0); GSTexture* CreateRenderTarget(int w, int h, int format = 0);
virtual GSTexture* CreateDepthStencil(int w, int h, int format = 0); GSTexture* CreateDepthStencil(int w, int h, int format = 0);
virtual GSTexture* CreateTexture(int w, int h, int format = 0); GSTexture* CreateTexture(int w, int h, int format = 0);
virtual GSTexture* CreateOffscreen(int w, int h, int format = 0); GSTexture* CreateOffscreen(int w, int h, int format = 0);
virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) {return NULL;} virtual GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) {return NULL;}

View File

@ -712,29 +712,12 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, int format)
GSTexture* GSDevice11::FetchSurface(int type, int w, int h, int format) GSTexture* GSDevice11::FetchSurface(int type, int w, int h, int format)
{ {
if (format == 0)
format = (type == GSTexture::DepthStencil) ? DXGI_FORMAT_R32G8X24_TYPELESS : DXGI_FORMAT_R8G8B8A8_UNORM;
return __super::FetchSurface(type, w, h, format); return __super::FetchSurface(type, w, h, format);
} }
GSTexture* GSDevice11::CreateRenderTarget(int w, int h, int format)
{
return __super::CreateRenderTarget(w, h, format ? format : DXGI_FORMAT_R8G8B8A8_UNORM);
}
GSTexture* GSDevice11::CreateDepthStencil(int w, int h, int format)
{
return __super::CreateDepthStencil(w, h, format ? format : DXGI_FORMAT_R32G8X24_TYPELESS);
}
GSTexture* GSDevice11::CreateTexture(int w, int h, int format)
{
return __super::CreateTexture(w, h, format ? format : DXGI_FORMAT_R8G8B8A8_UNORM);
}
GSTexture* GSDevice11::CreateOffscreen(int w, int h, int format)
{
return __super::CreateOffscreen(w, h, format ? format : DXGI_FORMAT_R8G8B8A8_UNORM);
}
GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader)
{ {
GSTexture* dst = NULL; GSTexture* dst = NULL;

View File

@ -483,11 +483,6 @@ public:
void ClearDepth(GSTexture* t) final; void ClearDepth(GSTexture* t) final;
void ClearStencil(GSTexture* t, uint8 c) final; void ClearStencil(GSTexture* t, uint8 c) final;
GSTexture* CreateRenderTarget(int w, int h, int format = 0) final;
GSTexture* CreateDepthStencil(int w, int h, int format = 0) final;
GSTexture* CreateTexture(int w, int h, int format = 0) final;
GSTexture* CreateOffscreen(int w, int h, int format = 0) final;
GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) final; GSTexture* CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format = 0, int ps_shader = 0) final;
void CloneTexture(GSTexture* src, GSTexture** dest); void CloneTexture(GSTexture* src, GSTexture** dest);

View File

@ -260,6 +260,9 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, int fmt)
GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, int format) GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, int format)
{ {
if (format == 0)
format = (type == GSTexture::DepthStencil) ? GL_DEPTH32F_STENCIL8 : GL_RGBA8;
GSTexture* t = GSDevice::FetchSurface(type, w, h, format); GSTexture* t = GSDevice::FetchSurface(type, w, h, format);
@ -1178,26 +1181,6 @@ void GSDeviceOGL::SelfShaderTest()
SelfShaderTestPrint(test, nb_shader); SelfShaderTestPrint(test, nb_shader);
} }
GSTexture* GSDeviceOGL::CreateRenderTarget(int w, int h, int format)
{
return GSDevice::CreateRenderTarget(w, h, format ? format : GL_RGBA8);
}
GSTexture* GSDeviceOGL::CreateDepthStencil(int w, int h, int format)
{
return GSDevice::CreateDepthStencil(w, h, format ? format : GL_DEPTH32F_STENCIL8);
}
GSTexture* GSDeviceOGL::CreateTexture(int w, int h, int format)
{
return GSDevice::CreateTexture(w, h, format ? format : GL_RGBA8);
}
GSTexture* GSDeviceOGL::CreateOffscreen(int w, int h, int format)
{
return GSDevice::CreateOffscreen(w, h, format ? format : GL_RGBA8);
}
// blit a texture into an offscreen buffer // blit a texture into an offscreen buffer
GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader) GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int w, int h, int format, int ps_shader)
{ {

View File

@ -534,10 +534,6 @@ public:
void ClearDepth(GSTexture* t) final; void ClearDepth(GSTexture* t) final;
void ClearStencil(GSTexture* t, uint8 c) final; void ClearStencil(GSTexture* t, uint8 c) final;
GSTexture* CreateRenderTarget(int w, int h, int format = 0) final;
GSTexture* CreateDepthStencil(int w, int h, int format = 0) final;
GSTexture* CreateTexture(int w, int h, int format = 0) final;
GSTexture* CreateOffscreen(int w, int h, int format = 0) final;
void InitPrimDateTexture(GSTexture* rt, const GSVector4i& area); void InitPrimDateTexture(GSTexture* rt, const GSVector4i& area);
void RecycleDateTexture(); void RecycleDateTexture();