mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 05:15:45 -04:00
GPU/HW: Expand lines into triangles before rendering
Fewer batches, consistent upscaling behavior.
This commit is contained in:
@ -885,111 +885,6 @@ float4 SampleFromVRAM(uint4 texpage, float2 coords)
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string GPU_HW_ShaderGen::GenerateBatchLineExpandGeometryShader()
|
||||
{
|
||||
std::stringstream ss;
|
||||
WriteHeader(ss);
|
||||
WriteCommonFunctions(ss);
|
||||
|
||||
ss << R"(
|
||||
CONSTANT float2 WIDTH = (float(RESOLUTION_SCALE * 2u) / float2(VRAM_SIZE));
|
||||
)";
|
||||
|
||||
// GS is a pain, too different between HLSL and GLSL...
|
||||
if (m_glsl)
|
||||
{
|
||||
if (IsVulkan())
|
||||
ss << "layout(location = 0) ";
|
||||
|
||||
ss << R"(in VertexDataVS {
|
||||
float4 v_col0;
|
||||
} in_data[];)";
|
||||
|
||||
if (IsVulkan())
|
||||
ss << "layout(location = 0) ";
|
||||
|
||||
ss << R"(out VertexData {
|
||||
float4 v_col0;
|
||||
} out_data;
|
||||
|
||||
layout(lines) in;
|
||||
layout(triangle_strip, max_vertices = 4) out;
|
||||
|
||||
void main() {
|
||||
float2 dir = normalize(gl_in[1].gl_Position.xy - gl_in[0].gl_Position.xy);
|
||||
float2 normal = cross(float3(dir, 0.0), float3(0.0, 0.0, 1.0)).xy * WIDTH;
|
||||
float4 offset = float4(normal, 0.0, 0.0);
|
||||
|
||||
// top-left
|
||||
out_data.v_col0 = in_data[0].v_col0;
|
||||
gl_Position = gl_in[0].gl_Position;
|
||||
EmitVertex();
|
||||
|
||||
// top-right
|
||||
out_data.v_col0 = in_data[0].v_col0;
|
||||
gl_Position = gl_in[0].gl_Position + offset;
|
||||
EmitVertex();
|
||||
|
||||
// bottom-left
|
||||
out_data.v_col0 = in_data[1].v_col0;
|
||||
gl_Position = gl_in[1].gl_Position;
|
||||
EmitVertex();
|
||||
|
||||
// bottom-right
|
||||
out_data.v_col0 = in_data[1].v_col0;
|
||||
gl_Position = gl_in[1].gl_Position + offset;
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
)";
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << R"(
|
||||
struct Vertex
|
||||
{
|
||||
float4 col0 : COLOR0;
|
||||
float4 pos : SV_Position;
|
||||
};
|
||||
|
||||
[maxvertexcount(4)]
|
||||
void main(line Vertex input[2], inout TriangleStream<Vertex> output)
|
||||
{
|
||||
Vertex v;
|
||||
|
||||
float2 dir = normalize(input[1].pos.xy - input[0].pos.xy);
|
||||
float2 normal = cross(float3(dir, 0.0), float3(0.0, 0.0, 1.0)).xy * WIDTH;
|
||||
float4 offset = float4(normal, 0.0, 0.0);
|
||||
|
||||
// top-left
|
||||
v.col0 = input[0].col0;
|
||||
v.pos = input[0].pos;
|
||||
output.Append(v);
|
||||
|
||||
// top-right
|
||||
v.col0 = input[0].col0;
|
||||
v.pos = input[0].pos + offset;
|
||||
output.Append(v);
|
||||
|
||||
// bottom-left
|
||||
v.col0 = input[1].col0;
|
||||
v.pos = input[1].pos;
|
||||
output.Append(v);
|
||||
|
||||
// bottom-right
|
||||
v.col0 = input[1].col0;
|
||||
v.pos = input[1].pos + offset;
|
||||
output.Append(v);
|
||||
|
||||
output.RestartStrip();
|
||||
}
|
||||
)";
|
||||
}
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string GPU_HW_ShaderGen::GenerateScreenQuadVertexShader()
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
Reference in New Issue
Block a user