GS: Convert ShaderConvert to enum class

This commit is contained in:
TellowKrinkle 2020-09-26 03:14:24 -05:00 committed by tellowkrinkle
parent 017c37f212
commit 6e38f40f96
11 changed files with 121 additions and 82 deletions

View File

@ -18,6 +18,36 @@
#include "GS/GSGL.h"
#include "GS/GS.h"
const char* shaderName(ShaderConvert value)
{
switch (value)
{
case ShaderConvert::COPY: return "ps_copy";
case ShaderConvert::RGBA8_TO_16_BITS: return "ps_convert_rgba8_16bits";
case ShaderConvert::DATM_1: return "ps_datm1";
case ShaderConvert::DATM_0: return "ps_datm0";
case ShaderConvert::MOD_256: return "ps_mod256";
case ShaderConvert::SCANLINE: return "ps_filter_scanlines";
case ShaderConvert::DIAGONAL_FILTER: return "ps_filter_diagonal";
case ShaderConvert::TRANSPARENCY_FILTER: return "ps_filter_transparency";
case ShaderConvert::TRIANGULAR_FILTER: return "ps_filter_triangular";
case ShaderConvert::COMPLEX_FILTER: return "ps_filter_complex";
case ShaderConvert::FLOAT32_TO_32_BITS: return "ps_convert_float32_32bits";
case ShaderConvert::FLOAT32_TO_RGBA8: return "ps_convert_float32_rgba8";
case ShaderConvert::FLOAT16_TO_RGB5A1: return "ps_convert_float16_rgb5a1";
case ShaderConvert::RGBA8_TO_FLOAT32: return "ps_convert_rgba8_float32";
case ShaderConvert::RGBA8_TO_FLOAT24: return "ps_convert_rgba8_float24";
case ShaderConvert::RGBA8_TO_FLOAT16: return "ps_convert_rgba8_float16";
case ShaderConvert::RGB5A1_TO_FLOAT16: return "ps_convert_rgb5a1_float16";
case ShaderConvert::RGBA_TO_8I: return "ps_convert_rgba_8i";
case ShaderConvert::YUV: return "ps_yuv";
case ShaderConvert::OSD: return "ps_osd";
default:
ASSERT(0);
return "ShaderConvertUnknownShader";
}
}
GSDevice::GSDevice()
: m_vsync(false)
, m_rbswapped(false)
@ -89,9 +119,9 @@ void GSDevice::Present(const GSVector4i& r, int shader)
if (m_current)
{
static int s_shader[5] = {ShaderConvert_COPY, ShaderConvert_SCANLINE,
ShaderConvert_DIAGONAL_FILTER, ShaderConvert_TRIANGULAR_FILTER,
ShaderConvert_COMPLEX_FILTER}; // FIXME
static constexpr ShaderConvert s_shader[5] = {ShaderConvert::COPY, ShaderConvert::SCANLINE,
ShaderConvert::DIAGONAL_FILTER, ShaderConvert::TRIANGULAR_FILTER,
ShaderConvert::COMPLEX_FILTER}; // FIXME
Present(m_current, m_backbuffer, GSVector4(r), s_shader[shader]);
RenderOsd(m_backbuffer);
@ -100,7 +130,7 @@ void GSDevice::Present(const GSVector4i& r, int shader)
Flip();
}
void GSDevice::Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader)
void GSDevice::Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader)
{
StretchRect(sTex, dTex, dRect, shader, m_linear_present);
}
@ -223,7 +253,7 @@ GSTexture* GSDevice::CreateOffscreen(int w, int h, int format)
return FetchSurface(GSTexture::Offscreen, w, h, format);
}
void GSDevice::StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader, bool linear)
void GSDevice::StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader, bool linear)
{
StretchRect(sTex, GSVector4(0, 0, 1, 1), dTex, dRect, shader, linear);
}
@ -315,7 +345,7 @@ void GSDevice::ExternalFX()
const GSVector4 sRect(0, 0, 1, 1);
const GSVector4 dRect(0, 0, s.x, s.y);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert_TRANSPARENCY_FILTER, false);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert::TRANSPARENCY_FILTER, false);
DoExternalFX(m_target_tmp, m_current);
}
}
@ -329,7 +359,7 @@ void GSDevice::FXAA()
const GSVector4 sRect(0, 0, 1, 1);
const GSVector4 dRect(0, 0, s.x, s.y);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert_TRANSPARENCY_FILTER, false);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert::TRANSPARENCY_FILTER, false);
DoFXAA(m_target_tmp, m_current);
}
}
@ -343,7 +373,7 @@ void GSDevice::ShadeBoost()
const GSVector4 sRect(0, 0, 1, 1);
const GSVector4 dRect(0, 0, s.x, s.y);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert_COPY, false);
StretchRect(m_current, sRect, m_target_tmp, dRect, ShaderConvert::COPY, false);
DoShadeBoost(m_target_tmp, m_current);
}
}

View File

@ -26,31 +26,35 @@
#include <dxgi.h>
#endif
enum ShaderConvert
enum class ShaderConvert
{
ShaderConvert_COPY = 0,
ShaderConvert_RGBA8_TO_16_BITS,
ShaderConvert_DATM_1,
ShaderConvert_DATM_0,
ShaderConvert_MOD_256,
ShaderConvert_SCANLINE = 5,
ShaderConvert_DIAGONAL_FILTER,
ShaderConvert_TRANSPARENCY_FILTER,
ShaderConvert_TRIANGULAR_FILTER,
ShaderConvert_COMPLEX_FILTER,
ShaderConvert_FLOAT32_TO_32_BITS = 10,
ShaderConvert_FLOAT32_TO_RGBA8,
ShaderConvert_FLOAT16_TO_RGB5A1,
ShaderConvert_RGBA8_TO_FLOAT32 = 13,
ShaderConvert_RGBA8_TO_FLOAT24,
ShaderConvert_RGBA8_TO_FLOAT16,
ShaderConvert_RGB5A1_TO_FLOAT16,
ShaderConvert_RGBA_TO_8I = 17,
ShaderConvert_YUV,
ShaderConvert_OSD,
ShaderConvert_Count
COPY = 0,
RGBA8_TO_16_BITS,
DATM_1,
DATM_0,
MOD_256,
SCANLINE = 5,
DIAGONAL_FILTER,
TRANSPARENCY_FILTER,
TRIANGULAR_FILTER,
COMPLEX_FILTER,
FLOAT32_TO_32_BITS = 10,
FLOAT32_TO_RGBA8,
FLOAT16_TO_RGB5A1,
RGBA8_TO_FLOAT32 = 13,
RGBA8_TO_FLOAT24,
RGBA8_TO_FLOAT16,
RGB5A1_TO_FLOAT16,
RGBA_TO_8I = 17,
YUV,
OSD,
Count
};
/// Get the name of a shader
/// (Can't put methods on an enum class)
const char* shaderName(ShaderConvert value);
enum ChannelFetch
{
ChannelFetch_NONE = 0,
@ -200,7 +204,7 @@ public:
virtual bool Reset(int w, int h);
virtual bool IsLost(bool update = false) { return false; }
virtual void Present(const GSVector4i& r, int shader);
virtual void Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0);
virtual void Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader = ShaderConvert::COPY);
virtual void Flip() {}
virtual void SetVSync(int vsync) { m_vsync = vsync; }
@ -226,13 +230,13 @@ public:
GSTexture* CreateTexture(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, ShaderConvert ps_shader = ShaderConvert::COPY) { return NULL; }
virtual void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) {}
virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) {}
virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader = ShaderConvert::COPY, bool linear = true) {}
virtual void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, bool red, bool green, bool blue, bool alpha) {}
void StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true);
void StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader = ShaderConvert::COPY, bool linear = true);
virtual void PSSetShaderResources(GSTexture* sr0, GSTexture* sr1) {}
virtual void PSSetShaderResource(int i, GSTexture* sRect) {}

View File

@ -635,7 +635,7 @@ GSTexture* GSDevice11::FetchSurface(int type, int w, int h, int format)
return __super::FetchSurface(type, w, h, format);
}
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, ShaderConvert ps_shader)
{
GSTexture* dst = NULL;
@ -650,7 +650,7 @@ GSTexture* GSDevice11::CopyOffscreen(GSTexture* src, const GSVector4& sRect, int
{
GSVector4 dRect(0, 0, w, h);
StretchRect(src, sRect, rt, dRect, m_convert.ps[ps_shader].get(), NULL);
StretchRect(src, sRect, rt, dRect, m_convert.ps[static_cast<int>(ps_shader)].get(), NULL);
dst = CreateOffscreen(w, h, format);
@ -703,9 +703,9 @@ void GSDevice11::CloneTexture(GSTexture* src, GSTexture** dest)
CopyRect(src, *dest, GSVector4i(0, 0, w, h));
}
void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader, bool linear)
void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader, bool linear)
{
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[shader].get(), nullptr, linear);
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[static_cast<int>(shader)].get(), nullptr, linear);
}
void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, bool linear)
@ -729,7 +729,7 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture*
wil::com_ptr_nothrow<ID3D11BlendState> bs;
m_dev->CreateBlendState(&bd, bs.put());
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[ShaderConvert_COPY].get(), nullptr, bs.get(), false);
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[static_cast<int>(ShaderConvert::COPY)].get(), nullptr, bs.get(), false);
}
void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, ID3D11BlendState* bs, bool linear)
@ -740,8 +740,10 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture*
return;
}
const bool draw_in_depth = (ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT32] || ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT24]
|| ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT16] || ps == m_convert.ps[ShaderConvert_RGB5A1_TO_FLOAT16]);
const bool draw_in_depth = ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT32)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT24)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT16)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGB5A1_TO_FLOAT16)];
BeginScene();
@ -827,7 +829,7 @@ void GSDevice11::RenderOsd(GSTexture* dt)
// ps
PSSetShaderResource(0, m_font.get());
PSSetSamplerState(m_convert.pt.get(), nullptr);
PSSetShader(m_convert.ps[ShaderConvert_OSD].get(), nullptr);
PSSetShader(m_convert.ps[static_cast<int>(ShaderConvert::OSD)].get(), nullptr);
// ia
IASetInputLayout(m_convert.il.get());
@ -1022,7 +1024,7 @@ void GSDevice11::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* vert
// ps
PSSetShaderResources(rt, nullptr);
PSSetSamplerState(m_convert.pt.get(), nullptr);
PSSetShader(m_convert.ps[datm ? ShaderConvert_DATM_1 : ShaderConvert_DATM_0].get(), nullptr);
PSSetShader(m_convert.ps[static_cast<int>(datm ? ShaderConvert::DATM_1 : ShaderConvert::DATM_0)].get(), nullptr);
//

View File

@ -450,7 +450,7 @@ private:
{
wil::com_ptr_nothrow<ID3D11InputLayout> il;
wil::com_ptr_nothrow<ID3D11VertexShader> vs;
wil::com_ptr_nothrow<ID3D11PixelShader> ps[ShaderConvert_Count];
wil::com_ptr_nothrow<ID3D11PixelShader> ps[static_cast<int>(ShaderConvert::Count)];
wil::com_ptr_nothrow<ID3D11SamplerState> ln;
wil::com_ptr_nothrow<ID3D11SamplerState> pt;
wil::com_ptr_nothrow<ID3D11DepthStencilState> dss;
@ -542,13 +542,13 @@ public:
void ClearDepth(GSTexture* t) final;
void ClearStencil(GSTexture* t, u8 c) 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, ShaderConvert ps_shader = ShaderConvert::COPY) final;
void CloneTexture(GSTexture* src, GSTexture** dest);
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r);
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) final;
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader = ShaderConvert::COPY, bool linear = true) final;
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, bool linear = true);
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, bool red, bool green, bool blue, bool alpha);
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ID3D11PixelShader* ps, ID3D11Buffer* ps_cb, ID3D11BlendState* bs, bool linear = true);

View File

@ -893,7 +893,7 @@ void GSRendererDX11::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sou
hdr_rt = dev->CreateRenderTarget(rtsize.x, rtsize.y, DXGI_FORMAT_R32G32B32A32_FLOAT);
// Warning: StretchRect must be called before BeginScene otherwise
// vertices will be overwritten. Trust me you don't want to do that.
dev->StretchRect(rt, sRect, hdr_rt, dRect, ShaderConvert_COPY, false);
dev->StretchRect(rt, sRect, hdr_rt, dRect, ShaderConvert::COPY, false);
}
if (m_ps_sel.dfmt == 1)
@ -1180,7 +1180,7 @@ void GSRendererDX11::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sou
{
const GSVector4 dRect(ComputeBoundingBox(rtscale, rtsize));
const GSVector4 sRect = dRect / GSVector4(rtsize.x, rtsize.y).xyxy();
dev->StretchRect(hdr_rt, sRect, rt, dRect, ShaderConvert_MOD_256, false);
dev->StretchRect(hdr_rt, sRect, rt, dRect, ShaderConvert::MOD_256, false);
dev->Recycle(hdr_rt);
}

View File

@ -33,31 +33,31 @@ void GSTextureCache11::Read(Target* t, const GSVector4i& r)
const GIFRegTEX0& TEX0 = t->m_TEX0;
DXGI_FORMAT format;
int ps_shader;
ShaderConvert ps_shader;
switch (TEX0.PSM)
{
case PSM_PSMCT32:
case PSM_PSMCT24:
format = DXGI_FORMAT_R8G8B8A8_UNORM;
ps_shader = ShaderConvert_COPY;
ps_shader = ShaderConvert::COPY;
break;
case PSM_PSMCT16:
case PSM_PSMCT16S:
format = DXGI_FORMAT_R16_UINT;
ps_shader = ShaderConvert_RGBA8_TO_16_BITS;
ps_shader = ShaderConvert::RGBA8_TO_16_BITS;
break;
case PSM_PSMZ32:
case PSM_PSMZ24:
format = DXGI_FORMAT_R32_UINT;
ps_shader = ShaderConvert_FLOAT32_TO_32_BITS;
ps_shader = ShaderConvert::FLOAT32_TO_32_BITS;
break;
case PSM_PSMZ16:
case PSM_PSMZ16S:
format = DXGI_FORMAT_R16_UINT;
ps_shader = ShaderConvert_FLOAT32_TO_32_BITS;
ps_shader = ShaderConvert::FLOAT32_TO_32_BITS;
break;
default:

View File

@ -588,17 +588,17 @@ GSTextureCache::Target* GSTextureCache::LookupTarget(const GIFRegTEX0& TEX0, int
dst = CreateTarget(TEX0, w, h, type);
dst->m_32_bits_fmt = dst_match->m_32_bits_fmt;
int shader;
ShaderConvert shader;
bool fmt_16_bits = (psm_s.bpp == 16 && GSLocalMemory::m_psm[dst_match->m_TEX0.PSM].bpp == 16);
if (type == DepthStencil)
{
GL_CACHE("TC: Lookup Target(Depth) %dx%d, hit Color (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(dst_match->m_TEX0.PSM));
shader = (fmt_16_bits) ? ShaderConvert_RGB5A1_TO_FLOAT16 : ShaderConvert_RGBA8_TO_FLOAT32 + psm_s.fmt;
shader = (fmt_16_bits) ? ShaderConvert::RGB5A1_TO_FLOAT16 : (ShaderConvert)((int)ShaderConvert::RGBA8_TO_FLOAT32 + psm_s.fmt);
}
else
{
GL_CACHE("TC: Lookup Target(Color) %dx%d, hit Depth (0x%x, %s was %s)", w, h, bp, psm_str(TEX0.PSM), psm_str(dst_match->m_TEX0.PSM));
shader = (fmt_16_bits) ? ShaderConvert_FLOAT16_TO_RGB5A1 : ShaderConvert_FLOAT32_TO_RGBA8;
shader = (fmt_16_bits) ? ShaderConvert::FLOAT16_TO_RGB5A1 : ShaderConvert::FLOAT32_TO_RGBA8;
}
m_renderer->m_dev->StretchRect(dst_match->m_texture, sRect, dst->m_texture, dRect, shader, false);
}
@ -1351,13 +1351,13 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
{
// TODO: clean up this mess
int shader = dst->m_type != RenderTarget ? ShaderConvert_FLOAT32_TO_RGBA8 : ShaderConvert_COPY;
ShaderConvert shader = dst->m_type != RenderTarget ? ShaderConvert::FLOAT32_TO_RGBA8 : ShaderConvert::COPY;
bool is_8bits = TEX0.PSM == PSM_PSMT8;
if (is_8bits)
{
GL_INS("Reading RT as a packed-indexed 8 bits format");
shader = ShaderConvert_RGBA_TO_8I;
shader = ShaderConvert::RGBA_TO_8I;
}
#ifdef ENABLE_OGL_DEBUG
@ -1540,7 +1540,7 @@ GSTextureCache::Source* GSTextureCache::CreateSource(const GIFRegTEX0& TEX0, con
// copy. Likely a speed boost and memory usage reduction.
bool linear = (TEX0.PSM == PSM_PSMCT32 || TEX0.PSM == PSM_PSMCT24);
if ((sRect == dRect).alltrue() && !shader)
if ((sRect == dRect).alltrue() && shader == ShaderConvert::COPY)
{
if (half_right)
{
@ -2102,7 +2102,7 @@ void GSTextureCache::Target::Update()
GL_INS("ERROR: Update DepthStencil 0x%x", m_TEX0.TBP0);
// FIXME linear or not?
m_renderer->m_dev->StretchRect(t, m_texture, GSVector4(r) * GSVector4(m_texture->GetScale()).xyxy(), ShaderConvert_RGBA8_TO_FLOAT32);
m_renderer->m_dev->StretchRect(t, m_texture, GSVector4(r) * GSVector4(m_texture->GetScale()).xyxy(), ShaderConvert::RGBA8_TO_FLOAT32);
}
m_renderer->m_dev->Recycle(t);

View File

@ -1270,7 +1270,7 @@ void GSDeviceOGL::SelfShaderTest()
}
// 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, ShaderConvert ps_shader)
{
if (format == 0)
format = GL_RGBA8;
@ -1286,7 +1286,7 @@ GSTexture* GSDeviceOGL::CopyOffscreen(GSTexture* src, const GSVector4& sRect, in
// invalid data (for example due to SW blending).
glTextureBarrier();
StretchRect(src, sRect, dst, dRect, m_convert.ps[ps_shader]);
StretchRect(src, sRect, dst, dRect, m_convert.ps[(int)ps_shader]);
return dst;
}
@ -1304,7 +1304,7 @@ void GSDeviceOGL::BlitRect(GSTexture* sTex, const GSVector4i& r, const GSVector2
const GSVector4 float_r(r);
BeginScene();
m_shader->BindPipeline(m_convert.ps[ShaderConvert_COPY]);
m_shader->BindPipeline(m_convert.ps[static_cast<int>(ShaderConvert::COPY)]);
OMSetDepthStencilState(m_convert.dss);
OMSetBlendState();
OMSetColorMaskState();
@ -1342,9 +1342,9 @@ void GSDeviceOGL::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r
r.width(), r.height(), 1);
}
void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader, bool linear)
void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader, bool linear)
{
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[shader], linear);
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[(int)shader], linear);
}
void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, bool linear)
@ -1361,7 +1361,7 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
cms.wb = blue;
cms.wa = alpha;
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[ShaderConvert_COPY], m_NO_BLEND, cms, false);
StretchRect(sTex, sRect, dTex, dRect, m_convert.ps[(int)ShaderConvert::COPY], m_NO_BLEND, cms, false);
}
void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, int bs, OMColorMaskSelector cms, bool linear)
@ -1372,8 +1372,10 @@ void GSDeviceOGL::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture
return;
}
const bool draw_in_depth = (ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT32] || ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT24] ||
ps == m_convert.ps[ShaderConvert_RGBA8_TO_FLOAT16] || ps == m_convert.ps[ShaderConvert_RGB5A1_TO_FLOAT16]);
const bool draw_in_depth = ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT32)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT24)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGBA8_TO_FLOAT16)]
|| ps == m_convert.ps[static_cast<int>(ShaderConvert::RGB5A1_TO_FLOAT16)];
// Performance optimization. It might be faster to use a framebuffer blit for standard case
// instead to emulate it with shader
@ -1477,7 +1479,8 @@ void GSDeviceOGL::RenderOsd(GSTexture* dt)
{
BeginScene();
m_shader->BindPipeline(m_convert.ps[ShaderConvert_OSD]);
m_shader->BindPipeline(m_convert.ps[static_cast<int>(ShaderConvert::OSD)]);
OMSetDepthStencilState(m_convert.dss);
OMSetBlendState((u8)GSDeviceOGL::m_MERGE_BLEND);
@ -1534,12 +1537,12 @@ void GSDeviceOGL::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
{
// 2nd output is enabled and selected. Copy it to destination so we can blend it with 1st output
// Note: value outside of dRect must contains the background color (c)
StretchRect(sTex[1], sRect[1], dTex, dRect[1], ShaderConvert_COPY);
StretchRect(sTex[1], sRect[1], dTex, dRect[1], ShaderConvert::COPY);
}
// Save 2nd output
if (feedback_write_2) // FIXME I'm not sure dRect[1] is always correct
StretchRect(dTex, full_r, sTex[2], dRect[1], ShaderConvert_YUV);
StretchRect(dTex, full_r, sTex[2], dRect[1], ShaderConvert::YUV);
// Restore background color to process the normal merge
if (feedback_write_2_but_blend_bg)
@ -1565,7 +1568,7 @@ void GSDeviceOGL::DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex,
}
if (feedback_write_1) // FIXME I'm not sure dRect[0] is always correct
StretchRect(dTex, full_r, sTex[2], dRect[0], ShaderConvert_YUV);
StretchRect(dTex, full_r, sTex[2], dRect[0], ShaderConvert::YUV);
}
void GSDeviceOGL::DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset)
@ -1700,7 +1703,7 @@ void GSDeviceOGL::SetupDATE(GSTexture* rt, GSTexture* ds, const GSVertexPT1* ver
ClearStencil(ds, 0);
m_shader->BindPipeline(m_convert.ps[datm ? ShaderConvert_DATM_1 : ShaderConvert_DATM_0]);
m_shader->BindPipeline(m_convert.ps[static_cast<int>(datm ? ShaderConvert::DATM_1 : ShaderConvert::DATM_0)]);
// om

View File

@ -505,7 +505,7 @@ private:
struct
{
GLuint vs; // program object
GLuint ps[ShaderConvert_Count]; // program object
GLuint ps[(int)ShaderConvert::Count]; // program object
GLuint ln; // sampler object
GLuint pt; // sampler object
GSDepthStencilOGL* dss;
@ -605,14 +605,14 @@ public:
void InitPrimDateTexture(GSTexture* rt, const GSVector4i& area);
void RecycleDateTexture();
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, ShaderConvert ps_shader = ShaderConvert::COPY) final;
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) final;
// BlitRect *does* mess with GL state, be sure to re-bind.
void BlitRect(GSTexture* sTex, const GSVector4i& r, const GSVector2i& dsize, bool at_origin, bool linear);
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, int shader = 0, bool linear = true) final;
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader = ShaderConvert::COPY, bool linear = true) final;
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, bool linear = true);
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, bool red, bool green, bool blue, bool alpha) final;
void StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture* dTex, const GSVector4& dRect, GLuint ps, int bs, OMColorMaskSelector cms, bool linear = true);

View File

@ -1614,7 +1614,7 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
if (hdr_rt)
{
const GSVector4 sRect = GSVector4(commitRect) / GSVector4(rtsize.x, rtsize.y).xyxy();
dev->StretchRect(hdr_rt, sRect, rt, GSVector4(commitRect), ShaderConvert_MOD_256, false);
dev->StretchRect(hdr_rt, sRect, rt, GSVector4(commitRect), ShaderConvert::MOD_256, false);
dev->Recycle(hdr_rt);
}

View File

@ -29,31 +29,31 @@ void GSTextureCacheOGL::Read(Target* t, const GSVector4i& r)
const GIFRegTEX0& TEX0 = t->m_TEX0;
GLuint fmt;
int ps_shader;
ShaderConvert ps_shader;
switch (TEX0.PSM)
{
case PSM_PSMCT32:
case PSM_PSMCT24:
fmt = GL_RGBA8;
ps_shader = ShaderConvert_COPY;
ps_shader = ShaderConvert::COPY;
break;
case PSM_PSMCT16:
case PSM_PSMCT16S:
fmt = GL_R16UI;
ps_shader = ShaderConvert_RGBA8_TO_16_BITS;
ps_shader = ShaderConvert::RGBA8_TO_16_BITS;
break;
case PSM_PSMZ32:
case PSM_PSMZ24:
fmt = GL_R32UI;
ps_shader = ShaderConvert_FLOAT32_TO_32_BITS;
ps_shader = ShaderConvert::FLOAT32_TO_32_BITS;
break;
case PSM_PSMZ16:
case PSM_PSMZ16S:
fmt = GL_R16UI;
ps_shader = ShaderConvert_FLOAT32_TO_32_BITS;
ps_shader = ShaderConvert::FLOAT32_TO_32_BITS;
break;
default: