mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
VideoCommon: Make API_TYPE an enum class
Allows for forward declarations in most places, which prevents dumping unrelated VideoCommon.h contents directly into headers.
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
#include "VideoCommon/GeometryShaderGen.h"
|
||||
#include "VideoCommon/LightingShaderGen.h"
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
static const char* primitives_ogl[] = {"points", "lines", "triangles"};
|
||||
@ -16,9 +17,9 @@ static const char* primitives_ogl[] = {"points", "lines", "triangles"};
|
||||
static const char* primitives_d3d[] = {"point", "line", "triangle"};
|
||||
|
||||
template <class T>
|
||||
static void EmitVertex(T& out, const char* vertex, API_TYPE ApiType, bool first_vertex = false);
|
||||
static void EmitVertex(T& out, const char* vertex, APIType ApiType, bool first_vertex = false);
|
||||
template <class T>
|
||||
static void EndPrimitive(T& out, API_TYPE ApiType);
|
||||
static void EndPrimitive(T& out, APIType ApiType);
|
||||
|
||||
GeometryShaderUid GetGeometryShaderUid(u32 primitive_type)
|
||||
{
|
||||
@ -38,11 +39,11 @@ GeometryShaderUid GetGeometryShaderUid(u32 primitive_type)
|
||||
}
|
||||
|
||||
static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data,
|
||||
const char* vertex, API_TYPE ApiType, bool first_vertex = false);
|
||||
const char* vertex, APIType ApiType, bool first_vertex = false);
|
||||
static void EndPrimitive(ShaderCode& out, const geometry_shader_uid_data* uid_data,
|
||||
API_TYPE ApiType);
|
||||
APIType ApiType);
|
||||
|
||||
ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_uid_data* uid_data)
|
||||
ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid_data* uid_data)
|
||||
{
|
||||
ShaderCode out;
|
||||
// Non-uid template parameters will write to the dummy data (=> gets optimized out)
|
||||
@ -53,7 +54,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
if (uid_data->wireframe)
|
||||
vertex_out++;
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
// Insert layout parameters
|
||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
@ -75,7 +76,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
out.Write("%s", s_lighting_struct);
|
||||
|
||||
// uniforms
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
out.Write("layout(std140%s) uniform GSBlock {\n",
|
||||
g_ActiveConfig.backend_info.bSupportsBindingLayout ? ", binding = 3" : "");
|
||||
else
|
||||
@ -90,7 +91,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
"");
|
||||
out.Write("};\n");
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
out.Write("#define InstanceID gl_InvocationID\n");
|
||||
@ -144,7 +145,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
|
||||
if (uid_data->primitive_type == PRIMITIVE_LINES)
|
||||
{
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT start, end;\n");
|
||||
AssignVSOutputMembers(out, "start", "vs[0]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -175,7 +176,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
}
|
||||
else if (uid_data->primitive_type == PRIMITIVE_POINTS)
|
||||
{
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT center;\n");
|
||||
AssignVSOutputMembers(out, "center", "vs[0]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -206,7 +207,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
|
||||
out.Write("\tfor (int i = 0; i < %d; ++i) {\n", vertex_in);
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT f;\n");
|
||||
AssignVSOutputMembers(out, "f", "vs[i]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -220,7 +221,7 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
{
|
||||
// Select the output layer
|
||||
out.Write("\tps.layer = eye;\n");
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
out.Write("\tgl_Layer = eye;\n");
|
||||
|
||||
// For stereoscopy add a small horizontal offset in Normalized Device Coordinates proportional
|
||||
@ -303,12 +304,12 @@ ShaderCode GenerateGeometryShaderCode(API_TYPE ApiType, const geometry_shader_ui
|
||||
}
|
||||
|
||||
static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data,
|
||||
const char* vertex, API_TYPE ApiType, bool first_vertex)
|
||||
const char* vertex, APIType ApiType, bool first_vertex)
|
||||
{
|
||||
if (uid_data->wireframe && first_vertex)
|
||||
out.Write("\tif (i == 0) first = %s;\n", vertex);
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
{
|
||||
out.Write("\tgl_Position = %s.pos;\n", vertex);
|
||||
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -318,19 +319,18 @@ static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data
|
||||
out.Write("\tps.o = %s;\n", vertex);
|
||||
}
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
out.Write("\tEmitVertex();\n");
|
||||
else
|
||||
out.Write("\toutput.Append(ps);\n");
|
||||
}
|
||||
|
||||
static void EndPrimitive(ShaderCode& out, const geometry_shader_uid_data* uid_data,
|
||||
API_TYPE ApiType)
|
||||
static void EndPrimitive(ShaderCode& out, const geometry_shader_uid_data* uid_data, APIType ApiType)
|
||||
{
|
||||
if (uid_data->wireframe)
|
||||
EmitVertex(out, uid_data, "first", ApiType);
|
||||
|
||||
if (ApiType == API_OPENGL)
|
||||
if (ApiType == APIType::OpenGL)
|
||||
out.Write("\tEndPrimitive();\n");
|
||||
else
|
||||
out.Write("\toutput.RestartStrip();\n");
|
||||
|
Reference in New Issue
Block a user