diff options
| author | Jules Blok <jules.blok@gmail.com> | 2014-12-19 14:09:16 +0100 |
|---|---|---|
| committer | Jules Blok <jules.blok@gmail.com> | 2014-12-19 14:24:08 +0100 |
| commit | 531b3941ff612f9cc8dcb4b1d7de6cbec3ff1c08 (patch) | |
| tree | fbd8dabe983f13f235796e350450f0c1e166a17c /Source/Core/VideoCommon/GeometryShaderGen.cpp | |
| parent | 1b9fe70d7c0b567c7930297af296e765e91bc02b (diff) | |
GeometryShaderGen: Re-emit the first vertex when wireframe mode is enabled.
Diffstat (limited to 'Source/Core/VideoCommon/GeometryShaderGen.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/GeometryShaderGen.cpp | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/Source/Core/VideoCommon/GeometryShaderGen.cpp b/Source/Core/VideoCommon/GeometryShaderGen.cpp index eaba7652d6..a85e36b9bc 100644 --- a/Source/Core/VideoCommon/GeometryShaderGen.cpp +++ b/Source/Core/VideoCommon/GeometryShaderGen.cpp @@ -26,7 +26,8 @@ static const char* primitives_d3d[] = "triangle" }; -template<class T> static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType); +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); template<class T> static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE ApiType) @@ -45,10 +46,13 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A uid_data->primitive_type = primitive_type; const unsigned int vertex_in = primitive_type + 1; - const unsigned int vertex_out = primitive_type == PRIMITIVE_TRIANGLES ? 3 : 4; + unsigned int vertex_out = primitive_type == PRIMITIVE_TRIANGLES ? 3 : 4; - uid_data->stereo = g_ActiveConfig.iStereoMode > 0; uid_data->wireframe = g_ActiveConfig.bWireFrame; + if (g_ActiveConfig.bWireFrame) + vertex_out++; + + uid_data->stereo = g_ActiveConfig.iStereoMode > 0; if (ApiType == API_OPENGL) { // Insert layout parameters @@ -178,6 +182,9 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A out.Write("\tfor (int eye = 0; eye < 2; ++eye) {\n"); } + if (g_ActiveConfig.bWireFrame) + out.Write("\tVS_OUTPUT first;\n"); + out.Write("\tfor (int i = 0; i < %d; ++i) {\n", vertex_in); if (ApiType == API_OPENGL) @@ -221,7 +228,7 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A } out.Write("\t}\n"); - EmitVertex<T>(out, "l", ApiType); + EmitVertex<T>(out, "l", ApiType, true); EmitVertex<T>(out, "r", ApiType); } else if (primitive_type == PRIMITIVE_POINTS) @@ -249,22 +256,19 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A } out.Write("\t}\n"); - EmitVertex<T>(out, "ll", ApiType); + EmitVertex<T>(out, "ll", ApiType, true); EmitVertex<T>(out, "lr", ApiType); EmitVertex<T>(out, "ul", ApiType); EmitVertex<T>(out, "ur", ApiType); } else { - EmitVertex<T>(out, "f", ApiType); + EmitVertex<T>(out, "f", ApiType, true); } out.Write("\t}\n"); - if (ApiType == API_OPENGL) - out.Write("\tEndPrimitive();\n"); - else - out.Write("\toutput.RestartStrip();\n"); + EndPrimitive<T>(out, ApiType); if (g_ActiveConfig.iStereoMode > 0 && !g_ActiveConfig.backend_info.bSupportsGSInstancing) out.Write("\t}\n"); @@ -279,8 +283,11 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A } template<class T> -static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType) +static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType, bool first_vertex) { + if (g_ActiveConfig.bWireFrame && first_vertex) + out.Write("\tif (i == 0) first = %s;\n", vertex); + if (ApiType == API_OPENGL) out.Write("\tgl_Position = %s.pos;\n", vertex); @@ -291,6 +298,17 @@ static inline void EmitVertex(T& out, const char* vertex, API_TYPE ApiType) else out.Write("\toutput.Append(ps);\n"); } +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"); +} void GetGeometryShaderUid(GeometryShaderUid& object, u32 primitive_type, API_TYPE ApiType) { |
