GS/OGL: Use VS/GS selectors from base class

This commit is contained in:
Stenzek 2023-04-07 16:40:37 +10:00 committed by refractionpcsx2
parent a06f890ab9
commit 2a06bb6e2c
3 changed files with 16 additions and 87 deletions

View File

@ -46,12 +46,12 @@ void texture_coord()
// Integer coordinate => normalized
VSout.t_int.xy = uv * TextureScale;
#if VS_INT_FST == 1
// Some games uses float coordinate for post-processing effect
VSout.t_int.zw = st / TextureScale;
#else
#if VS_FST
// Integer coordinate => integral
VSout.t_int.zw = uv;
#else
// Some games uses float coordinate for post-processing effect
VSout.t_int.zw = st / TextureScale;
#endif
}
@ -129,7 +129,7 @@ void out_vertex(in vec4 position, in vertex v)
GSout.t_float = v.t_float;
GSout.t_int = v.t_int;
// Flat output
#if GS_POINT == 1
#if GS_PRIM == 0
GSout.c = GSin[0].c;
#else
GSout.c = GSin[1].c;
@ -139,14 +139,14 @@ void out_vertex(in vec4 position, in vertex v)
EmitVertex();
}
#if GS_POINT == 1
#if GS_PRIM == 0
layout(points) in;
#else
layout(lines) in;
#endif
layout(triangle_strip, max_vertices = 4) out;
#if GS_POINT == 1
#if GS_PRIM == 0
void gs_main()
{
@ -172,7 +172,7 @@ void gs_main()
EndPrimitive();
}
#elif GS_LINE == 1
#elif GS_PRIM == 1
void gs_main()
{
@ -203,7 +203,7 @@ void gs_main()
EndPrimitive();
}
#else
#else // GS_PRIM == 3
void gs_main()
{

View File

@ -1176,7 +1176,7 @@ std::string GSDeviceOGL::GetVSSource(VSSelector sel)
{
DevCon.WriteLn("Compiling new vertex shader with selector 0x%" PRIX64, sel.key);
std::string macro = fmt::format("#define VS_INT_FST {}\n", static_cast<u32>(sel.int_fst))
std::string macro = fmt::format("#define VS_FST {}\n", static_cast<u32>(sel.fst))
+ fmt::format("#define VS_IIP {}\n", static_cast<u32>(sel.iip))
+ fmt::format("#define VS_POINT_SIZE {}\n", static_cast<u32>(sel.point_size));
@ -1189,8 +1189,8 @@ std::string GSDeviceOGL::GetGSSource(GSSelector sel)
{
DevCon.WriteLn("Compiling new geometry shader with selector 0x%" PRIX64, sel.key);
std::string macro = fmt::format("#define GS_POINT {}\n", static_cast<u32>(sel.point))
+ fmt::format("#define GS_LINE {}\n", static_cast<u32>(sel.line))
std::string macro = fmt::format("#define GS_PRIM {}\n", static_cast<u32>(sel.topology))
+ fmt::format("#define GS_EXPAND {}\n", static_cast<u32>(sel.expand))
+ fmt::format("#define GS_IIP {}\n", static_cast<u32>(sel.iip));
std::string src = GenGlslHeader("gs_main", GL_GEOMETRY_SHADER, macro);
@ -2243,16 +2243,6 @@ void GSDeviceOGL::SetupOM(OMDepthStencilSelector dssel)
OMSetDepthStencilState(m_om_dss[dssel.key]);
}
static GSDeviceOGL::VSSelector convertSel(const GSHWDrawConfig::VSSelector sel, const GSHWDrawConfig::Topology topology)
{
// Mali requires gl_PointSize written when rasterizing points. The spec seems to suggest this is okay.
GSDeviceOGL::VSSelector out;
out.int_fst = !sel.fst;
out.iip = sel.iip;
out.point_size = sel.point_size || (GLLoader::is_gles && topology == GSHWDrawConfig::Topology::Point);
return out;
}
// clang-format off
static constexpr std::array<GLenum, 16> s_gl_blend_factors = { {
GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR, GL_DST_COLOR, GL_ONE_MINUS_DST_COLOR,
@ -2366,22 +2356,13 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
}
ProgramSelector psel;
psel.vs = convertSel(config.vs, config.topology);
psel.vs = config.vs;
psel.ps.key_hi = config.ps.key_hi;
psel.ps.key_lo = config.ps.key_lo;
psel.gs.key = 0;
psel.pad = 0;
if (config.gs.expand)
{
psel.gs.iip = config.gs.iip;
switch (config.gs.topology)
{
case GSHWDrawConfig::GSTopology::Point: psel.gs.point = 1; break;
case GSHWDrawConfig::GSTopology::Line: psel.gs.line = 1; break;
case GSHWDrawConfig::GSTopology::Sprite: psel.gs.sprite = 1; break;
case GSHWDrawConfig::GSTopology::Triangle: ASSERT(0); break;
}
}
psel.gs.key = config.gs.key;
SetupPipeline(psel);

View File

@ -120,60 +120,8 @@ public:
class GSDeviceOGL final : public GSDevice
{
public:
struct VSSelector
{
union
{
struct
{
u8 int_fst : 1;
u8 iip : 1;
u8 point_size : 1;
u8 _free : 5;
};
u8 key;
};
VSSelector()
: key(0)
{
}
VSSelector(u8 k)
: key(k)
{
}
};
struct GSSelector
{
union
{
struct
{
u8 sprite : 1;
u8 point : 1;
u8 line : 1;
u8 iip : 1;
u8 _free : 4;
};
u8 key;
};
operator u32() const { return key; }
GSSelector()
: key(0)
{
}
GSSelector(u8 k)
: key(k)
{
}
};
using VSSelector = GSHWDrawConfig::VSSelector;
using GSSelector = GSHWDrawConfig::GSSelector;
using PSSelector = GSHWDrawConfig::PSSelector;
using PSSamplerSelector = GSHWDrawConfig::SamplerSelector;
using OMDepthStencilSelector = GSHWDrawConfig::DepthStencilSelector;