mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
VideoCommon: Add APIType entry for Vulkan
This commit is contained in:
@ -55,7 +55,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
if (uid_data->wireframe)
|
||||
vertex_out++;
|
||||
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
// Insert layout parameters
|
||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
@ -77,10 +77,11 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
out.Write("%s", s_lighting_struct);
|
||||
|
||||
// uniforms
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
out.Write("UBO_BINDING(std140, 3) uniform GSBlock {\n");
|
||||
else
|
||||
out.Write("cbuffer GSBlock {\n");
|
||||
|
||||
out.Write("\tfloat4 " I_STEREOPARAMS ";\n"
|
||||
"\tfloat4 " I_LINEPTPARAMS ";\n"
|
||||
"\tint4 " I_TEXOFFSET ";\n"
|
||||
@ -91,7 +92,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
"");
|
||||
out.Write("};\n");
|
||||
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
if (g_ActiveConfig.backend_info.bSupportsGSInstancing)
|
||||
out.Write("#define InstanceID gl_InvocationID\n");
|
||||
@ -145,7 +146,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
|
||||
if (uid_data->primitive_type == PRIMITIVE_LINES)
|
||||
{
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT start, end;\n");
|
||||
AssignVSOutputMembers(out, "start", "vs[0]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -176,7 +177,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
}
|
||||
else if (uid_data->primitive_type == PRIMITIVE_POINTS)
|
||||
{
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT center;\n");
|
||||
AssignVSOutputMembers(out, "center", "vs[0]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -207,7 +208,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
|
||||
out.Write("\tfor (int i = 0; i < %d; ++i) {\n", vertex_in);
|
||||
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
{
|
||||
out.Write("\tVS_OUTPUT f;\n");
|
||||
AssignVSOutputMembers(out, "f", "vs[i]", uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
@ -230,7 +231,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const geometry_shader_uid
|
||||
{
|
||||
// Select the output layer
|
||||
out.Write("\tps.layer = eye;\n");
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
out.Write("\tgl_Layer = eye;\n");
|
||||
|
||||
// For stereoscopy add a small horizontal offset in Normalized Device Coordinates proportional
|
||||
@ -329,12 +330,19 @@ static void EmitVertex(ShaderCode& out, const geometry_shader_uid_data* uid_data
|
||||
}
|
||||
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
}
|
||||
else if (ApiType == APIType::Vulkan)
|
||||
{
|
||||
// Vulkan NDC space has Y pointing down (right-handed NDC space).
|
||||
out.Write("\tgl_Position = %s.pos;\n", vertex);
|
||||
out.Write("\tgl_Position.y = -gl_Position.y;\n");
|
||||
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, uid_data->pixel_lighting);
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("\tps.o = %s;\n", vertex);
|
||||
}
|
||||
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
out.Write("\tEmitVertex();\n");
|
||||
else
|
||||
out.Write("\toutput.Append(ps);\n");
|
||||
@ -345,7 +353,7 @@ static void EndPrimitive(ShaderCode& out, const geometry_shader_uid_data* uid_da
|
||||
if (uid_data->wireframe)
|
||||
EmitVertex(out, uid_data, "first", ApiType);
|
||||
|
||||
if (ApiType == APIType::OpenGL)
|
||||
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
|
||||
out.Write("\tEndPrimitive();\n");
|
||||
else
|
||||
out.Write("\toutput.RestartStrip();\n");
|
||||
|
Reference in New Issue
Block a user