Merge pull request #9984 from Pokechu22/ApiType-to-api_type

VideoCommon: Rename ApiType to api_type
This commit is contained in:
Tilka 2021-08-01 23:26:12 +01:00 committed by GitHub
commit 8a078ea43a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 49 deletions

View File

@ -45,11 +45,12 @@ GeometryShaderUid GetGeometryShaderUid(PrimitiveType primitive_type)
static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data, const char* vertex,
APIType ApiType, bool wireframe, bool first_vertex = false);
APIType api_type, bool wireframe, bool first_vertex = false);
static void EndPrimitive(ShaderCode& out, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data, APIType ApiType, bool wireframe);
const geometry_shader_uid_data* uid_data, APIType api_type,
bool wireframe);
ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& host_config,
ShaderCode GenerateGeometryShaderCode(APIType api_type, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data)
{
ShaderCode out;
@ -67,7 +68,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
if (wireframe)
vertex_out++;
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
// Insert layout parameters
if (host_config.backend_gs_instancing)
@ -88,7 +89,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
out.Write("{}", s_lighting_struct);
// uniforms
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write("UBO_BINDING(std140, 3) uniform GSBlock {{\n");
else
out.Write("cbuffer GSBlock {{\n");
@ -99,21 +100,21 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
"}};\n");
out.Write("struct VS_OUTPUT {{\n");
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config, "");
GenerateVSOutputMembers(out, api_type, uid_data->numTexGens, host_config, "");
out.Write("}};\n");
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
if (host_config.backend_gs_instancing)
out.Write("#define InstanceID gl_InvocationID\n");
out.Write("VARYING_LOCATION(0) in VertexData {{\n");
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config,
GenerateVSOutputMembers(out, api_type, uid_data->numTexGens, host_config,
GetInterpolationQualifier(msaa, ssaa, true, true));
out.Write("}} vs[{}];\n", vertex_in);
out.Write("VARYING_LOCATION(0) out VertexData {{\n");
GenerateVSOutputMembers(out, ApiType, uid_data->numTexGens, host_config,
GenerateVSOutputMembers(out, api_type, uid_data->numTexGens, host_config,
GetInterpolationQualifier(msaa, ssaa, true, false));
if (stereo)
@ -152,7 +153,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
if (primitive_type == PrimitiveType::Lines)
{
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
out.Write("\tVS_OUTPUT start, end;\n");
AssignVSOutputMembers(out, "start", "vs[0]", uid_data->numTexGens, host_config);
@ -183,7 +184,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
}
else if (primitive_type == PrimitiveType::Points)
{
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
out.Write("\tVS_OUTPUT center;\n");
AssignVSOutputMembers(out, "center", "vs[0]", uid_data->numTexGens, host_config);
@ -214,7 +215,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
out.Write("\tfor (int i = 0; i < {}; ++i) {{\n", vertex_in);
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
out.Write("\tVS_OUTPUT f;\n");
AssignVSOutputMembers(out, "f", "vs[i]", uid_data->numTexGens, host_config);
@ -237,7 +238,7 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
{
// Select the output layer
out.Write("\tps.layer = eye;\n");
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write("\tgl_Layer = eye;\n");
// For stereoscopy add a small horizontal offset in Normalized Device Coordinates proportional
@ -269,8 +270,8 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
}
out.Write("\t}}\n");
EmitVertex(out, host_config, uid_data, "l", ApiType, wireframe, true);
EmitVertex(out, host_config, uid_data, "r", ApiType, wireframe);
EmitVertex(out, host_config, uid_data, "l", api_type, wireframe, true);
EmitVertex(out, host_config, uid_data, "r", api_type, wireframe);
}
else if (primitive_type == PrimitiveType::Points)
{
@ -298,19 +299,19 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
}
out.Write("\t}}\n");
EmitVertex(out, host_config, uid_data, "ll", ApiType, wireframe, true);
EmitVertex(out, host_config, uid_data, "lr", ApiType, wireframe);
EmitVertex(out, host_config, uid_data, "ul", ApiType, wireframe);
EmitVertex(out, host_config, uid_data, "ur", ApiType, wireframe);
EmitVertex(out, host_config, uid_data, "ll", api_type, wireframe, true);
EmitVertex(out, host_config, uid_data, "lr", api_type, wireframe);
EmitVertex(out, host_config, uid_data, "ul", api_type, wireframe);
EmitVertex(out, host_config, uid_data, "ur", api_type, wireframe);
}
else
{
EmitVertex(out, host_config, uid_data, "f", ApiType, wireframe, true);
EmitVertex(out, host_config, uid_data, "f", api_type, wireframe, true);
}
out.Write("\t}}\n");
EndPrimitive(out, host_config, uid_data, ApiType, wireframe);
EndPrimitive(out, host_config, uid_data, api_type, wireframe);
if (stereo && !host_config.backend_gs_instancing)
out.Write("\t}}\n");
@ -322,12 +323,12 @@ ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& h
static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data, const char* vertex,
APIType ApiType, bool wireframe, bool first_vertex)
APIType api_type, bool wireframe, bool first_vertex)
{
if (wireframe && first_vertex)
out.Write("\tif (i == 0) first = {};\n", vertex);
if (ApiType == APIType::OpenGL)
if (api_type == APIType::OpenGL)
{
out.Write("\tgl_Position = {}.pos;\n", vertex);
if (host_config.backend_depth_clamp)
@ -337,7 +338,7 @@ static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
}
AssignVSOutputMembers(out, "ps", vertex, uid_data->numTexGens, host_config);
}
else if (ApiType == APIType::Vulkan)
else if (api_type == APIType::Vulkan)
{
// Vulkan NDC space has Y pointing down (right-handed NDC space).
out.Write("\tgl_Position = {}.pos;\n", vertex);
@ -349,19 +350,19 @@ static void EmitVertex(ShaderCode& out, const ShaderHostConfig& host_config,
out.Write("\tps.o = {};\n", vertex);
}
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write("\tEmitVertex();\n");
else
out.Write("\toutput.Append(ps);\n");
}
static void EndPrimitive(ShaderCode& out, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data, APIType ApiType, bool wireframe)
const geometry_shader_uid_data* uid_data, APIType api_type, bool wireframe)
{
if (wireframe)
EmitVertex(out, host_config, uid_data, "first", ApiType, wireframe);
EmitVertex(out, host_config, uid_data, "first", api_type, wireframe);
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write("\tEndPrimitive();\n");
else
out.Write("\toutput.RestartStrip();\n");

View File

@ -23,7 +23,7 @@ struct geometry_shader_uid_data
using GeometryShaderUid = ShaderUid<geometry_shader_uid_data>;
ShaderCode GenerateGeometryShaderCode(APIType ApiType, const ShaderHostConfig& host_config,
ShaderCode GenerateGeometryShaderCode(APIType api_type, const ShaderHostConfig& host_config,
const geometry_shader_uid_data* uid_data);
GeometryShaderUid GetGeometryShaderUid(PrimitiveType primitive_type);
void EnumerateGeometryShaderUids(const std::function<void(const GeometryShaderUid&)>& callback);

View File

@ -34,7 +34,7 @@ PixelShaderUid GetPixelShaderUid()
return out;
}
void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host_config,
void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config,
PixelShaderUid* uid)
{
pixel_ubershader_uid_data* const uid_data = uid->GetUidData();
@ -42,11 +42,11 @@ void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host
// OpenGL and Vulkan convert implicitly normalized color outputs to their uint representation.
// Therefore, it is not necessary to use a uint output on these backends. We also disable the
// uint output when logic op is not supported (i.e. driver/device does not support D3D11.1).
if (ApiType != APIType::D3D || !host_config.backend_logic_op)
if (api_type != APIType::D3D || !host_config.backend_logic_op)
uid_data->uint_output = 0;
}
ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
const pixel_ubershader_uid_data* uid_data)
{
const bool per_pixel_lighting = host_config.per_pixel_lighting;
@ -63,13 +63,13 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
out.Write("// Pixel UberShader for {} texgens{}{}\n", numTexgen,
early_depth ? ", early-depth" : "", per_pixel_depth ? ", per-pixel depth" : "");
WritePixelShaderCommonHeader(out, ApiType, host_config, bounding_box);
WriteUberShaderCommonHeader(out, ApiType, host_config);
WritePixelShaderCommonHeader(out, api_type, host_config, bounding_box);
WriteUberShaderCommonHeader(out, api_type, host_config);
if (per_pixel_lighting)
WriteLightingFunction(out);
// Shader inputs/outputs in GLSL (HLSL is in main).
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
if (use_dual_source)
{
@ -110,7 +110,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
if (host_config.backend_geometry_shaders)
{
out.Write("VARYING_LOCATION(0) in VertexData {{\n");
GenerateVSOutputMembers(out, ApiType, numTexgen, host_config,
GenerateVSOutputMembers(out, api_type, numTexgen, host_config,
GetInterpolationQualifier(msaa, ssaa, true, true));
if (stereo)
@ -158,7 +158,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
out.Write(", int2 fixpoint_uv{}", i);
out.Write(") {{\n");
if (ApiType == APIType::D3D)
if (api_type == APIType::D3D)
{
out.Write(" switch (index) {{\n");
for (u32 i = 0; i < numTexgen; i++)
@ -227,9 +227,9 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
// Doesn't look like DirectX supports this. Oh well the code path is here just in case it
// supports this in the future.
out.Write("int4 sampleTexture(uint sampler_num, float3 uv) {{\n");
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write(" return iround(texture(samp[sampler_num], uv) * 255.0);\n");
else if (ApiType == APIType::D3D)
else if (api_type == APIType::D3D)
out.Write(" return iround(Tex[sampler_num].Sample(samp[sampler_num], uv) * 255.0);\n");
out.Write("}}\n\n");
}
@ -243,9 +243,9 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
" switch(sampler_num) {{\n");
for (int i = 0; i < 8; i++)
{
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
out.Write(" case {}u: return iround(texture(samp[{}], uv) * 255.0);\n", i, i);
else if (ApiType == APIType::D3D)
else if (api_type == APIType::D3D)
out.Write(" case {}u: return iround(Tex[{}].Sample(samp[{}], uv) * 255.0);\n", i, i, i);
}
out.Write(" }}\n"
@ -404,7 +404,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
// The switch statements in these functions appear to get transformed into an if..else chain
// on NVIDIA's OpenGL/Vulkan drivers, resulting in lower performance than the D3D counterparts.
// Transforming the switch into a binary tree of ifs can increase performance by up to 20%.
if (ApiType == APIType::D3D)
if (api_type == APIType::D3D)
{
out.Write("// Helper function for Alpha Test\n"
"bool alphaCompare(int a, int b, uint compare) {{\n"
@ -669,7 +669,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
out.Write(")\n\n");
}
if (ApiType == APIType::OpenGL || ApiType == APIType::Vulkan)
if (api_type == APIType::OpenGL || api_type == APIType::Vulkan)
{
if (early_depth && host_config.backend_early_z)
out.Write("FORCE_EARLY_Z;\n");
@ -745,7 +745,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
" float4 lit_colors_1 = colors_1;\n"
" float3 lit_normal = normalize(Normal.xyz);\n"
" float3 lit_pos = WorldPos.xyz;\n");
WriteVertexLighting(out, ApiType, "lit_pos", "lit_normal", "colors_0", "colors_1",
WriteVertexLighting(out, api_type, "lit_pos", "lit_normal", "colors_0", "colors_1",
"lit_colors_0", "lit_colors_1");
color_input_prefix = "lit_";
}
@ -754,7 +754,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
BitfieldExtract<&GenMode::numtevstages>("bpmem_genmode"));
out.Write(" // Main tev loop\n");
if (ApiType == APIType::D3D)
if (api_type == APIType::D3D)
{
// Tell DirectX we don't want this loop unrolled (it crashes if it tries to)
out.Write(" [loop]\n");
@ -1092,7 +1092,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
" if ((bpmem_genmode & {}u) != 0u) {{\n",
1 << GenMode().zfreeze.StartBit());
out.Write(" float2 screenpos = rawpos.xy * " I_EFBSCALE ".xy;\n");
if (ApiType == APIType::OpenGL)
if (api_type == APIType::OpenGL)
{
out.Write(" // OpenGL has reversed vertical screenspace coordinates\n"
" screenpos.y = 528.0 - screenpos.y;\n");
@ -1233,7 +1233,7 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
"\n");
// D3D requires that the shader outputs be uint when writing to a uint render target for logic op.
if (ApiType == APIType::D3D && uid_data->uint_output)
if (api_type == APIType::D3D && uid_data->uint_output)
{
out.Write(" if (bpmem_rgba6_format)\n"
" ocol0 = uint4(TevResult & 0xFC);\n"

View File

@ -27,10 +27,10 @@ using PixelShaderUid = ShaderUid<pixel_ubershader_uid_data>;
PixelShaderUid GetPixelShaderUid();
ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
const pixel_ubershader_uid_data* uid_data);
void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>& callback);
void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host_config,
void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config,
PixelShaderUid* uid);
} // namespace UberShader