2014-10-16 18:52:32 +02:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2014-10-16 18:52:32 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
#include "VideoCommon/BPMemory.h"
|
2014-10-16 18:52:32 +02:00
|
|
|
#include "VideoCommon/GeometryShaderGen.h"
|
|
|
|
#include "VideoCommon/LightingShaderGen.h"
|
2014-10-30 23:40:03 +01:00
|
|
|
#include "VideoCommon/VertexShaderGen.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2014-10-16 18:52:32 +02:00
|
|
|
|
|
|
|
static char text[16384];
|
|
|
|
|
2014-12-14 22:27:09 +01:00
|
|
|
static const char* primitives_ogl[] =
|
|
|
|
{
|
|
|
|
"points",
|
|
|
|
"lines",
|
|
|
|
"triangles"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char* primitives_d3d[] =
|
|
|
|
{
|
|
|
|
"point",
|
|
|
|
"line",
|
|
|
|
"triangle"
|
|
|
|
};
|
|
|
|
|
2014-12-19 14:09:16 +01:00
|
|
|
template<class T> static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType, bool first_vertex = false);
|
|
|
|
template<class T> static inline void EndPrimitive(T& out, API_TYPE ApiType);
|
2014-12-15 22:39:03 +01:00
|
|
|
|
2014-10-16 18:52:32 +02:00
|
|
|
template<class T>
|
2014-12-14 19:41:16 +01:00
|
|
|
static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE ApiType)
|
2014-10-16 18:52:32 +02:00
|
|
|
{
|
|
|
|
// Non-uid template parameters will write to the dummy data (=> gets optimized out)
|
|
|
|
geometry_shader_uid_data dummy_data;
|
|
|
|
geometry_shader_uid_data* uid_data = out.template GetUidData<geometry_shader_uid_data>();
|
|
|
|
if (uid_data == nullptr)
|
|
|
|
uid_data = &dummy_data;
|
|
|
|
|
|
|
|
out.SetBuffer(text);
|
|
|
|
const bool is_writing_shadercode = (out.GetBuffer() != nullptr);
|
|
|
|
|
|
|
|
if (is_writing_shadercode)
|
|
|
|
text[sizeof(text) - 1] = 0x7C; // canary
|
|
|
|
|
2014-12-14 19:41:16 +01:00
|
|
|
uid_data->primitive_type = primitive_type;
|
2014-12-14 22:27:09 +01:00
|
|
|
const unsigned int vertex_in = primitive_type + 1;
|
2014-12-19 14:09:16 +01:00
|
|
|
unsigned int vertex_out = primitive_type == PRIMITIVE_TRIANGLES ? 3 : 4;
|
2014-12-14 22:27:09 +01:00
|
|
|
|
2014-12-19 12:03:11 +01:00
|
|
|
uid_data->wireframe = g_ActiveConfig.bWireFrame;
|
2014-12-19 14:09:16 +01:00
|
|
|
if (g_ActiveConfig.bWireFrame)
|
|
|
|
vertex_out++;
|
2014-12-14 22:27:09 +01:00
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
uid_data->stereo = g_ActiveConfig.iStereoMode > 0;
|
2014-10-16 18:52:32 +02:00
|
|
|
if (ApiType == API_OPENGL)
|
|
|
|
{
|
|
|
|
// Insert layout parameters
|
2014-10-29 14:51:12 +01:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
2014-12-15 22:12:17 +01:00
|
|
|
{
|
2014-12-14 22:27:09 +01:00
|
|
|
out.Write("layout(%s, invocations = %d) in;\n", primitives_ogl[primitive_type], g_ActiveConfig.iStereoMode > 0 ? 2 : 1);
|
2014-12-19 12:03:11 +01:00
|
|
|
out.Write("layout(%s_strip, max_vertices = %d) out;\n", g_ActiveConfig.bWireFrame ? "line" : "triangle", vertex_out);
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-10-29 14:51:12 +01:00
|
|
|
else
|
2014-12-15 22:12:17 +01:00
|
|
|
{
|
2014-12-14 22:27:09 +01:00
|
|
|
out.Write("layout(%s) in;\n", primitives_ogl[primitive_type]);
|
2014-12-19 12:03:11 +01:00
|
|
|
out.Write("layout(%s_strip, max_vertices = %d) out;\n", g_ActiveConfig.bWireFrame ? "line" : "triangle", g_ActiveConfig.iStereoMode > 0 ? vertex_out * 2 : vertex_out);
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-10-16 18:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
out.Write("%s", s_lighting_struct);
|
|
|
|
|
|
|
|
// uniforms
|
2014-10-26 19:17:00 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
2014-12-14 21:23:13 +01:00
|
|
|
out.Write("layout(std140%s) uniform GSBlock {\n", g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 3" : "");
|
2014-10-16 18:52:32 +02:00
|
|
|
else
|
2014-12-14 21:23:13 +01:00
|
|
|
out.Write("cbuffer GSBlock {\n");
|
|
|
|
out.Write(
|
|
|
|
"\tfloat4 " I_STEREOPARAMS";\n"
|
2014-12-16 00:21:07 +01:00
|
|
|
"\tfloat4 " I_LINEPTPARAMS";\n"
|
|
|
|
"\tint4 " I_TEXOFFSET";\n"
|
2014-12-14 21:23:13 +01:00
|
|
|
"};\n");
|
2014-10-16 18:52:32 +02:00
|
|
|
|
2014-12-14 21:44:33 +01:00
|
|
|
uid_data->numTexGens = bpmem.genMode.numtexgens;
|
2014-11-22 19:18:45 +01:00
|
|
|
uid_data->pixel_lighting = g_ActiveConfig.bEnablePixelLighting;
|
|
|
|
|
2014-12-21 12:52:14 +01:00
|
|
|
out.Write("struct VS_OUTPUT {\n");
|
|
|
|
GenerateVSOutputMembers<T>(out, ApiType);
|
|
|
|
out.Write("};\n");
|
2014-10-16 18:52:32 +02:00
|
|
|
|
2014-11-02 23:40:52 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
|
|
|
{
|
2014-12-14 21:50:46 +01:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
|
|
|
out.Write("#define InstanceID gl_InvocationID\n");
|
|
|
|
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("in VertexData {\n");
|
2014-12-21 12:52:14 +01:00
|
|
|
GenerateVSOutputMembers<T>(out, ApiType, g_ActiveConfig.backend_info.bSupportsBindingLayout ? "centroid" : "centroid in");
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("} vs[%d];\n", vertex_in);
|
|
|
|
|
|
|
|
out.Write("out VertexData {\n");
|
2014-12-21 12:52:14 +01:00
|
|
|
GenerateVSOutputMembers<T>(out, ApiType, g_ActiveConfig.backend_info.bSupportsBindingLayout ? "centroid" : "centroid out");
|
2014-12-14 22:27:09 +01:00
|
|
|
|
|
|
|
if (g_ActiveConfig.iStereoMode > 0)
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\tflat int layer;\n");
|
|
|
|
|
|
|
|
out.Write("} ps;\n");
|
2014-11-02 23:40:52 +01:00
|
|
|
|
|
|
|
out.Write("void main()\n{\n");
|
|
|
|
}
|
|
|
|
else // D3D
|
|
|
|
{
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("struct VertexData {\n");
|
|
|
|
out.Write("\tVS_OUTPUT o;\n");
|
2014-12-14 22:27:09 +01:00
|
|
|
|
|
|
|
if (g_ActiveConfig.iStereoMode > 0)
|
|
|
|
out.Write("\tuint layer : SV_RenderTargetArrayIndex;\n");
|
|
|
|
|
2014-12-03 22:35:34 +01:00
|
|
|
out.Write("};\n");
|
|
|
|
|
2014-11-14 12:39:25 +01:00
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
|
|
|
{
|
2014-12-15 22:12:17 +01:00
|
|
|
out.Write("[maxvertexcount(%d)]\n[instance(%d)]\n", vertex_out, g_ActiveConfig.iStereoMode > 0 ? 2 : 1);
|
2014-12-19 12:03:11 +01:00
|
|
|
out.Write("void main(%s VS_OUTPUT o[%d], inout %sStream<VertexData> output, in uint InstanceID : SV_GSInstanceID)\n{\n", primitives_d3d[primitive_type], vertex_in, g_ActiveConfig.bWireFrame ? "Line" : "Triangle");
|
2014-11-14 12:39:25 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-15 22:12:17 +01:00
|
|
|
out.Write("[maxvertexcount(%d)]\n", g_ActiveConfig.iStereoMode > 0 ? vertex_out * 2 : vertex_out);
|
2014-12-19 12:03:11 +01:00
|
|
|
out.Write("void main(%s VS_OUTPUT o[%d], inout %sStream<VertexData> output)\n{\n", primitives_d3d[primitive_type], vertex_in, g_ActiveConfig.bWireFrame ? "Line" : "Triangle");
|
2014-11-14 12:39:25 +01:00
|
|
|
}
|
2014-10-16 18:52:32 +02:00
|
|
|
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\tVertexData ps;\n");
|
2014-11-02 23:40:52 +01:00
|
|
|
}
|
2014-10-27 00:29:37 +01:00
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
if (primitive_type == PRIMITIVE_LINES)
|
|
|
|
{
|
2014-12-16 23:52:42 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
|
|
|
{
|
2014-12-21 12:52:14 +01:00
|
|
|
out.Write("\tVS_OUTPUT start, end;\n");
|
|
|
|
AssignVSOutputMembers(out, "start", "vs[0]");
|
|
|
|
AssignVSOutputMembers(out, "end", "vs[1]");
|
2014-12-16 23:52:42 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.Write("\tVS_OUTPUT start = o[0];\n");
|
|
|
|
out.Write("\tVS_OUTPUT end = o[1];\n");
|
|
|
|
}
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
// GameCube/Wii's line drawing algorithm is a little quirky. It does not
|
|
|
|
// use the correct line caps. Instead, the line caps are vertical or
|
|
|
|
// horizontal depending the slope of the line.
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write(
|
|
|
|
"\tfloat2 offset;\n"
|
2015-01-31 23:32:23 +01:00
|
|
|
"\tfloat2 to = abs(end.pos.xy / end.pos.w - start.pos.xy / start.pos.w);\n"
|
2014-12-16 16:53:49 +01:00
|
|
|
// FIXME: What does real hardware do when line is at a 45-degree angle?
|
|
|
|
// FIXME: Lines aren't drawn at the correct width. See Twilight Princess map.
|
|
|
|
"\tif (" I_LINEPTPARAMS".y * to.y > " I_LINEPTPARAMS".x * to.x) {\n"
|
|
|
|
// Line is more tall. Extend geometry left and right.
|
|
|
|
// Lerp LineWidth/2 from [0..VpWidth] to [-1..1]
|
|
|
|
"\t\toffset = float2(" I_LINEPTPARAMS".z / " I_LINEPTPARAMS".x, 0);\n"
|
|
|
|
"\t} else {\n"
|
|
|
|
// Line is more wide. Extend geometry up and down.
|
|
|
|
// Lerp LineWidth/2 from [0..VpHeight] to [1..-1]
|
|
|
|
"\t\toffset = float2(0, -" I_LINEPTPARAMS".z / " I_LINEPTPARAMS".y);\n"
|
|
|
|
"\t}\n");
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-12-15 22:29:56 +01:00
|
|
|
else if (primitive_type == PRIMITIVE_POINTS)
|
|
|
|
{
|
2014-12-16 23:52:42 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
2014-12-21 12:52:14 +01:00
|
|
|
{
|
|
|
|
out.Write("\tVS_OUTPUT center;\n");
|
|
|
|
AssignVSOutputMembers(out, "center", "vs[0]");
|
|
|
|
}
|
2014-12-16 23:52:42 +01:00
|
|
|
else
|
2014-12-21 12:52:14 +01:00
|
|
|
{
|
2014-12-18 19:53:53 +01:00
|
|
|
out.Write("\tVS_OUTPUT center = o[0];\n");
|
2014-12-21 12:52:14 +01:00
|
|
|
}
|
2014-12-16 23:52:42 +01:00
|
|
|
|
2014-12-15 22:29:56 +01:00
|
|
|
// Offset from center to upper right vertex
|
|
|
|
// Lerp PointSize/2 from [0,0..VpWidth,VpHeight] to [-1,1..1,-1]
|
2014-12-18 19:53:53 +01:00
|
|
|
out.Write("\tfloat2 offset = float2(" I_LINEPTPARAMS".w / " I_LINEPTPARAMS".x, -" I_LINEPTPARAMS".w / " I_LINEPTPARAMS".y) * center.pos.w;\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
}
|
2014-12-15 22:12:17 +01:00
|
|
|
|
2014-12-14 22:27:09 +01:00
|
|
|
if (g_ActiveConfig.iStereoMode > 0)
|
2014-12-03 22:35:34 +01:00
|
|
|
{
|
2014-12-14 22:27:09 +01:00
|
|
|
// If the GPU supports invocation we don't need a for loop and can simply use the
|
|
|
|
// invocation identifier to determine which layer we're rendering.
|
|
|
|
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
|
|
|
out.Write("\tint eye = InstanceID;\n");
|
|
|
|
else
|
2014-12-15 22:12:17 +01:00
|
|
|
out.Write("\tfor (int eye = 0; eye < 2; ++eye) {\n");
|
2014-12-03 22:35:34 +01:00
|
|
|
}
|
2014-12-14 22:27:09 +01:00
|
|
|
|
2014-12-19 14:09:16 +01:00
|
|
|
if (g_ActiveConfig.bWireFrame)
|
|
|
|
out.Write("\tVS_OUTPUT first;\n");
|
|
|
|
|
2014-12-14 22:27:09 +01:00
|
|
|
out.Write("\tfor (int i = 0; i < %d; ++i) {\n", vertex_in);
|
2014-12-16 23:52:42 +01:00
|
|
|
|
|
|
|
if (ApiType == API_OPENGL)
|
2014-12-21 12:52:14 +01:00
|
|
|
{
|
|
|
|
out.Write("\tVS_OUTPUT f;\n");
|
|
|
|
AssignVSOutputMembers(out, "f", "vs[i]");
|
|
|
|
}
|
2014-12-16 23:52:42 +01:00
|
|
|
else
|
2014-12-21 12:52:14 +01:00
|
|
|
{
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\tVS_OUTPUT f = o[i];\n");
|
2014-12-21 12:52:14 +01:00
|
|
|
}
|
2014-10-30 15:13:31 +01:00
|
|
|
|
2014-10-30 23:29:56 +01:00
|
|
|
if (g_ActiveConfig.iStereoMode > 0)
|
2014-11-01 23:55:04 +01:00
|
|
|
{
|
2014-12-14 22:27:09 +01:00
|
|
|
// Select the output layer
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\tps.layer = eye;\n");
|
2014-12-14 22:27:09 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
2014-12-15 22:12:17 +01:00
|
|
|
out.Write("\tgl_Layer = eye;\n");
|
2014-12-14 22:27:09 +01:00
|
|
|
|
2014-11-12 00:40:58 +01:00
|
|
|
// For stereoscopy add a small horizontal offset in Normalized Device Coordinates proportional
|
|
|
|
// to the depth of the vertex. We retrieve the depth value from the w-component of the projected
|
|
|
|
// vertex which contains the negated z-component of the original vertex.
|
|
|
|
// For negative parallax (out-of-screen effects) we subtract a convergence value from
|
|
|
|
// the depth value. This results in objects at a distance smaller than the convergence
|
|
|
|
// distance to seemingly appear in front of the screen.
|
|
|
|
// This formula is based on page 13 of the "Nvidia 3D Vision Automatic, Best Practices Guide"
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\tf.pos.x += " I_STEREOPARAMS"[eye] * (f.pos.w - " I_STEREOPARAMS"[2]);\n");
|
2014-11-01 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
if (primitive_type == PRIMITIVE_LINES)
|
|
|
|
{
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write("\tVS_OUTPUT l = f;\n"
|
|
|
|
"\tVS_OUTPUT r = f;\n");
|
2014-11-02 23:40:52 +01:00
|
|
|
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write("\tl.pos.xy -= offset * l.pos.w;\n"
|
|
|
|
"\tr.pos.xy += offset * r.pos.w;\n");
|
2014-11-02 23:40:52 +01:00
|
|
|
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\tif (" I_TEXOFFSET"[2] != 0) {\n");
|
|
|
|
out.Write("\tfloat texOffset = 1.0 / float(" I_TEXOFFSET"[2]);\n");
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
for (unsigned int i = 0; i < bpmem.genMode.numtexgens; ++i)
|
|
|
|
{
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\tif (((" I_TEXOFFSET"[0] >> %d) & 0x1) != 0)\n", i);
|
|
|
|
out.Write("\t\tr.tex%d.x += texOffset;\n", i);
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\t}\n");
|
2014-12-15 22:12:17 +01:00
|
|
|
|
2014-12-19 14:09:16 +01:00
|
|
|
EmitVertex<T>(out, "l", ApiType, true);
|
2014-12-15 22:12:17 +01:00
|
|
|
EmitVertex<T>(out, "r", ApiType);
|
|
|
|
}
|
2014-12-15 22:29:56 +01:00
|
|
|
else if (primitive_type == PRIMITIVE_POINTS)
|
|
|
|
{
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write("\tVS_OUTPUT ll = f;\n"
|
|
|
|
"\tVS_OUTPUT lr = f;\n"
|
|
|
|
"\tVS_OUTPUT ul = f;\n"
|
|
|
|
"\tVS_OUTPUT ur = f;\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write("\tll.pos.xy += float2(-1,-1) * offset;\n"
|
|
|
|
"\tlr.pos.xy += float2(1,-1) * offset;\n"
|
|
|
|
"\tul.pos.xy += float2(-1,1) * offset;\n"
|
|
|
|
"\tur.pos.xy += offset;\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\tif (" I_TEXOFFSET"[3] != 0) {\n");
|
|
|
|
out.Write("\tfloat2 texOffset = float2(1.0 / float(" I_TEXOFFSET"[3]), 1.0 / float(" I_TEXOFFSET"[3]));\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
|
|
|
|
for (unsigned int i = 0; i < bpmem.genMode.numtexgens; ++i)
|
|
|
|
{
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\tif (((" I_TEXOFFSET"[1] >> %d) & 0x1) != 0) {\n", i);
|
|
|
|
out.Write("\t\tll.tex%d.xy += float2(0,1) * texOffset;\n", i);
|
|
|
|
out.Write("\t\tlr.tex%d.xy += texOffset;\n", i);
|
|
|
|
out.Write("\t\tur.tex%d.xy += float2(1,0) * texOffset;\n", i);
|
|
|
|
out.Write("\t}\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
}
|
2014-12-16 00:21:07 +01:00
|
|
|
out.Write("\t}\n");
|
2014-12-15 22:29:56 +01:00
|
|
|
|
2014-12-19 14:09:16 +01:00
|
|
|
EmitVertex<T>(out, "ll", ApiType, true);
|
2014-12-15 22:29:56 +01:00
|
|
|
EmitVertex<T>(out, "lr", ApiType);
|
|
|
|
EmitVertex<T>(out, "ul", ApiType);
|
|
|
|
EmitVertex<T>(out, "ur", ApiType);
|
|
|
|
}
|
2014-11-02 23:40:52 +01:00
|
|
|
else
|
2014-12-15 22:12:17 +01:00
|
|
|
{
|
2014-12-19 14:09:16 +01:00
|
|
|
EmitVertex<T>(out, "f", ApiType, true);
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-11-02 23:40:52 +01:00
|
|
|
|
2014-10-16 18:52:32 +02:00
|
|
|
out.Write("\t}\n");
|
2014-11-02 23:40:52 +01:00
|
|
|
|
2014-12-19 14:09:16 +01:00
|
|
|
EndPrimitive<T>(out, ApiType);
|
2014-10-30 15:13:31 +01:00
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
if (g_ActiveConfig.iStereoMode > 0 && !g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
2014-12-16 16:53:49 +01:00
|
|
|
out.Write("\t}\n");
|
2014-10-30 15:13:31 +01:00
|
|
|
|
2014-10-16 18:52:32 +02:00
|
|
|
out.Write("}\n");
|
|
|
|
|
|
|
|
if (is_writing_shadercode)
|
|
|
|
{
|
|
|
|
if (text[sizeof(text) - 1] != 0x7C)
|
|
|
|
PanicAlert("GeometryShader generator - buffer too small, canary has been eaten!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
template<class T>
|
2014-12-19 14:09:16 +01:00
|
|
|
static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType, bool first_vertex)
|
2014-12-15 22:12:17 +01:00
|
|
|
{
|
2014-12-19 14:09:16 +01:00
|
|
|
if (g_ActiveConfig.bWireFrame && first_vertex)
|
|
|
|
out.Write("\tif (i == 0) first = %s;\n", vertex);
|
|
|
|
|
2014-12-15 22:12:17 +01:00
|
|
|
if (ApiType == API_OPENGL)
|
2014-12-21 12:52:14 +01:00
|
|
|
{
|
2014-12-15 22:12:17 +01:00
|
|
|
out.Write("\tgl_Position = %s.pos;\n", vertex);
|
2014-12-21 12:52:14 +01:00
|
|
|
AssignVSOutputMembers(out, "ps", vertex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out.Write("\tps.o = %s;\n", vertex);
|
|
|
|
}
|
2014-12-15 22:12:17 +01:00
|
|
|
|
|
|
|
if (ApiType == API_OPENGL)
|
|
|
|
out.Write("\tEmitVertex();\n");
|
|
|
|
else
|
2014-12-16 23:52:42 +01:00
|
|
|
out.Write("\toutput.Append(ps);\n");
|
2014-12-15 22:12:17 +01:00
|
|
|
}
|
2014-12-19 14:09:16 +01:00
|
|
|
template<class T>
|
|
|
|
static inline void EndPrimitive(T& out, API_TYPE ApiType)
|
|
|
|
{
|
|
|
|
if (g_ActiveConfig.bWireFrame)
|
|
|
|
EmitVertex<T>(out, "first", ApiType);
|
|
|
|
|
|
|
|
if (ApiType == API_OPENGL)
|
|
|
|
out.Write("\tEndPrimitive();\n");
|
|
|
|
else
|
|
|
|
out.Write("\toutput.RestartStrip();\n");
|
|
|
|
}
|
2014-12-15 22:12:17 +01:00
|
|
|
|
2014-12-14 19:41:16 +01:00
|
|
|
void GetGeometryShaderUid(GeometryShaderUid& object, u32 primitive_type, API_TYPE ApiType)
|
2014-10-16 18:52:32 +02:00
|
|
|
{
|
2014-12-14 19:41:16 +01:00
|
|
|
GenerateGeometryShader<GeometryShaderUid>(object, primitive_type, ApiType);
|
2014-10-16 18:52:32 +02:00
|
|
|
}
|
|
|
|
|
2014-12-14 19:41:16 +01:00
|
|
|
void GenerateGeometryShaderCode(ShaderCode& object, u32 primitive_type, API_TYPE ApiType)
|
2014-10-16 18:52:32 +02:00
|
|
|
{
|
2014-12-14 19:41:16 +01:00
|
|
|
GenerateGeometryShader<ShaderCode>(object, primitive_type, ApiType);
|
2014-10-16 18:52:32 +02:00
|
|
|
}
|