mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Fix build errors related to formatting non-scoped enums
This commit is contained in:
@ -107,7 +107,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
|
||||
WARN_LOG_FMT(VIDEO,
|
||||
"CP MATINDEX_A: an exact value of {:02x} was expected "
|
||||
"but instead a value of {:02x} was seen",
|
||||
MATINDEX_A, sub_cmd);
|
||||
static_cast<u16>(MATINDEX_A), sub_cmd);
|
||||
}
|
||||
|
||||
matrix_index_a.Hex = value;
|
||||
@ -120,7 +120,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
|
||||
WARN_LOG_FMT(VIDEO,
|
||||
"CP MATINDEX_B: an exact value of {:02x} was expected "
|
||||
"but instead a value of {:02x} was seen",
|
||||
MATINDEX_B, sub_cmd);
|
||||
static_cast<u16>(MATINDEX_B), sub_cmd);
|
||||
}
|
||||
|
||||
matrix_index_b.Hex = value;
|
||||
@ -133,7 +133,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
|
||||
WARN_LOG_FMT(VIDEO,
|
||||
"CP VCD_LO: an exact value of {:02x} was expected "
|
||||
"but instead a value of {:02x} was seen",
|
||||
VCD_LO, sub_cmd);
|
||||
static_cast<u16>(VCD_LO), sub_cmd);
|
||||
}
|
||||
|
||||
vtx_desc.low.Hex = value;
|
||||
@ -146,7 +146,7 @@ void CPState::LoadCPReg(u8 sub_cmd, u32 value)
|
||||
WARN_LOG_FMT(VIDEO,
|
||||
"CP VCD_HI: an exact value of {:02x} was expected "
|
||||
"but instead a value of {:02x} was seen",
|
||||
VCD_HI, sub_cmd);
|
||||
static_cast<u16>(VCD_HI), sub_cmd);
|
||||
}
|
||||
|
||||
vtx_desc.high.Hex = value;
|
||||
|
@ -98,16 +98,16 @@ void EmitVertexMainDeclaration(ShaderCode& code, u32 num_tex_inputs, u32 num_col
|
||||
{
|
||||
for (u32 i = 0; i < num_tex_inputs; i++)
|
||||
{
|
||||
const auto attribute = SHADER_TEXTURE0_ATTRIB + i;
|
||||
code.Write("ATTRIBUTE_LOCATION({}) in float3 rawtex{};\n", attribute, i);
|
||||
const auto attribute = ShaderAttrib::TexCoord0 + i;
|
||||
code.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawtex{};\n", attribute, i);
|
||||
}
|
||||
for (u32 i = 0; i < num_color_inputs; i++)
|
||||
{
|
||||
const auto attribute = SHADER_COLOR0_ATTRIB + i;
|
||||
code.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor{};\n", attribute, i);
|
||||
const auto attribute = ShaderAttrib::Color0 + i;
|
||||
code.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawcolor{};\n", attribute, i);
|
||||
}
|
||||
if (position_input)
|
||||
code.Write("ATTRIBUTE_LOCATION({}) in float4 rawpos;\n", SHADER_POSITION_ATTRIB);
|
||||
code.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawpos;\n", ShaderAttrib::Position);
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders)
|
||||
{
|
||||
|
@ -118,10 +118,12 @@ void WriteVertexLighting(ShaderCode& out, APIType api_type, std::string_view wor
|
||||
|
||||
out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::enablelighting>("alphareg"));
|
||||
out.Write(" if ({} != 0u) {{\n", BitfieldExtract<&LitChannel::ambsource>("alphareg"));
|
||||
out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n", VB_HAS_COL0);
|
||||
out.Write(" if ((components & ({}u << chan)) != 0u) // VB_HAS_COL0\n",
|
||||
static_cast<u32>(VB_HAS_COL0));
|
||||
out.Write(" lacc.w = int(round(((chan == 0u) ? {}.w : {}.w) * 255.0));\n", in_color_0_var,
|
||||
in_color_1_var);
|
||||
out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n", VB_HAS_COL0);
|
||||
out.Write(" else if ((components & {}u) != 0u) // VB_HAS_COLO0\n",
|
||||
static_cast<u32>(VB_HAS_COL0));
|
||||
out.Write(" lacc.w = int(round({}.w * 255.0));\n", in_color_0_var);
|
||||
out.Write(" else\n"
|
||||
" lacc.w = 255;\n"
|
||||
|
@ -147,15 +147,15 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
}
|
||||
else
|
||||
{
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawpos;\n", SHADER_POSITION_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in uint4 posmtx;\n", SHADER_POSMTX_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnormal;\n", SHADER_NORMAL_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawtangent;\n", SHADER_TANGENT_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawbinormal;\n", SHADER_BINORMAL_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor0;\n", SHADER_COLOR0_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor1;\n", SHADER_COLOR1_ATTRIB);
|
||||
for (int i = 0; i < 8; ++i)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawtex{};\n", SHADER_TEXTURE0_ATTRIB + i, i);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawpos;\n", ShaderAttrib::Position);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in uint4 posmtx;\n", ShaderAttrib::PositionMatrix);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawnormal;\n", ShaderAttrib::Normal);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawtangent;\n", ShaderAttrib::Tangent);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawbinormal;\n", ShaderAttrib::Binormal);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawcolor0;\n", ShaderAttrib::Color0);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawcolor1;\n", ShaderAttrib::Color1);
|
||||
for (u32 i = 0; i < 8; ++i)
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawtex{};\n", ShaderAttrib::TexCoord0 + i, i);
|
||||
}
|
||||
|
||||
if (host_config.backend_geometry_shaders)
|
||||
@ -223,7 +223,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
"float3 N2;\n"
|
||||
"\n"
|
||||
"if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n",
|
||||
VB_HAS_POSMTXIDX);
|
||||
static_cast<u32>(VB_HAS_POSMTXIDX));
|
||||
LoadVertexAttribute(out, host_config, 2, "posmtx", "uint4", "ubyte4");
|
||||
out.Write(" // Vertex format has a per-vertex matrix\n"
|
||||
" int posidx = int(posmtx.r);\n"
|
||||
@ -258,7 +258,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
"float3 _normal = float3(0.0, 0.0, 0.0);\n"
|
||||
"if ((components & {}u) != 0u) // VB_HAS_NORMAL\n"
|
||||
"{{\n",
|
||||
VB_HAS_NORMAL);
|
||||
static_cast<u32>(VB_HAS_NORMAL));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawnormal", "float3", "float3");
|
||||
out.Write(" _normal = normalize(float3(dot(N0, rawnormal), dot(N1, rawnormal), dot(N2, "
|
||||
"rawnormal)));\n"
|
||||
@ -267,7 +267,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
"float3 _tangent = float3(0.0, 0.0, 0.0);\n"
|
||||
"if ((components & {}u) != 0u) // VB_HAS_TANGENT\n"
|
||||
"{{\n",
|
||||
VB_HAS_TANGENT);
|
||||
static_cast<u32>(VB_HAS_TANGENT));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawtangent", "float3", "float3");
|
||||
out.Write(" _tangent = float3(dot(N0, rawtangent), dot(N1, rawtangent), dot(N2, rawtangent));\n"
|
||||
"}}\n"
|
||||
@ -280,7 +280,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
"float3 _binormal = float3(0.0, 0.0, 0.0);\n"
|
||||
"if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n"
|
||||
"{{\n",
|
||||
VB_HAS_BINORMAL);
|
||||
static_cast<u32>(VB_HAS_BINORMAL));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawbinormal", "float3", "float3");
|
||||
out.Write(" _binormal = float3(dot(N0, rawbinormal), dot(N1, rawbinormal), dot(N2, "
|
||||
"rawbinormal));\n"
|
||||
@ -301,11 +301,11 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
out.Write("// To use color 1, the vertex descriptor must have color 0 and 1.\n"
|
||||
"// If color 1 is present but not color 0, it is used for lighting channel 0.\n"
|
||||
"bool use_color_1 = ((components & {0}u) == {0}u); // VB_HAS_COL0 | VB_HAS_COL1\n",
|
||||
VB_HAS_COL0 | VB_HAS_COL1);
|
||||
static_cast<u32>(VB_HAS_COL0 | VB_HAS_COL1));
|
||||
|
||||
out.Write("if ((components & {0}u) == {0}u) // VB_HAS_COL0 | VB_HAS_COL1\n"
|
||||
"{{\n",
|
||||
VB_HAS_COL0 | VB_HAS_COL1);
|
||||
static_cast<u32>(VB_HAS_COL0 | VB_HAS_COL1));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawcolor0", "float4", "ubyte4");
|
||||
LoadVertexAttribute(out, host_config, 2, "rawcolor1", "float4", "ubyte4");
|
||||
out.Write(" vertex_color_0 = rawcolor0;\n"
|
||||
@ -313,14 +313,14 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
"}}\n"
|
||||
"else if ((components & {}u) != 0u) // VB_HAS_COL0\n"
|
||||
"{{\n",
|
||||
VB_HAS_COL0);
|
||||
static_cast<u32>(VB_HAS_COL0));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawcolor0", "float4", "ubyte4");
|
||||
out.Write(" vertex_color_0 = rawcolor0;\n"
|
||||
" vertex_color_1 = rawcolor0;\n"
|
||||
"}}\n"
|
||||
"else if ((components & {}u) != 0u) // VB_HAS_COL1\n"
|
||||
"{{\n",
|
||||
VB_HAS_COL1);
|
||||
static_cast<u32>(VB_HAS_COL1));
|
||||
LoadVertexAttribute(out, host_config, 2, "rawcolor1", "float4", "ubyte4");
|
||||
out.Write(" vertex_color_0 = rawcolor1;\n"
|
||||
" vertex_color_1 = rawcolor1;\n"
|
||||
@ -355,7 +355,7 @@ float3 load_input_float3_rawtex(uint vtx_offset, uint attr_offset) {{
|
||||
" float4 other_p1 = P1;\n"
|
||||
" float4 other_p2 = P2;\n"
|
||||
" if ((components & {}u) != 0u) {{ // VB_HAS_POSMTXIDX\n",
|
||||
VB_HAS_POSMTXIDX);
|
||||
static_cast<u32>(VB_HAS_POSMTXIDX));
|
||||
out.Write(" uint other_posidx = load_input_uint4_ubyte4(other_base_offset, "
|
||||
"vertex_offset_posmtx).r;\n"
|
||||
" other_p0 = " I_TRANSFORMMATRICES "[other_posidx];\n"
|
||||
@ -545,7 +545,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
|
||||
out.Write(" case {:s}:\n", SourceRow::Normal);
|
||||
out.Write(" if ((components & {}u) != 0u) // VB_HAS_NORMAL\n"
|
||||
" {{\n",
|
||||
VB_HAS_NORMAL);
|
||||
static_cast<u32>(VB_HAS_NORMAL));
|
||||
LoadVertexAttribute(out, host_config, 6, "rawnormal", "float3", "float3");
|
||||
out.Write(" coord.xyz = rawnormal.xyz;\n"
|
||||
" }}\n"
|
||||
@ -553,7 +553,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
|
||||
out.Write(" case {:s}:\n", SourceRow::BinormalT);
|
||||
out.Write(" if ((components & {}u) != 0u) // VB_HAS_TANGENT\n"
|
||||
" {{\n",
|
||||
VB_HAS_TANGENT);
|
||||
static_cast<u32>(VB_HAS_TANGENT));
|
||||
LoadVertexAttribute(out, host_config, 6, "rawtangent", "float3", "float3");
|
||||
out.Write(" coord.xyz = rawtangent.xyz;\n"
|
||||
" }}\n"
|
||||
@ -561,7 +561,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
|
||||
out.Write(" case {:s}:\n", SourceRow::BinormalB);
|
||||
out.Write(" if ((components & {}u) != 0u) // VB_HAS_BINORMAL\n"
|
||||
" {{\n",
|
||||
VB_HAS_BINORMAL);
|
||||
static_cast<u32>(VB_HAS_BINORMAL));
|
||||
LoadVertexAttribute(out, host_config, 6, "rawbinormal", "float3", "float3");
|
||||
out.Write(" coord.xyz = rawbinormal.xyz;\n"
|
||||
" }}\n"
|
||||
@ -625,7 +625,7 @@ static void GenVertexShaderTexGens(APIType api_type, const ShaderHostConfig& hos
|
||||
out.Write(" default:\n"
|
||||
" {{\n");
|
||||
out.Write(" if ((components & ({}u /* VB_HAS_TEXMTXIDX0 */ << texgen)) != 0u) {{\n",
|
||||
VB_HAS_TEXMTXIDX0);
|
||||
static_cast<u32>(VB_HAS_TEXMTXIDX0));
|
||||
if (host_config.backend_dynamic_vertex_loader || host_config.backend_vs_point_line_expand)
|
||||
{
|
||||
out.Write(" int tmp = int(load_input_float3_rawtex(vertex_base_offset, "
|
||||
|
@ -118,20 +118,20 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
|
||||
|
||||
if (uid_data->vs_expand == VSExpand::None)
|
||||
{
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawpos;\n", SHADER_POSITION_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawpos;\n", ShaderAttrib::Position);
|
||||
if ((uid_data->components & VB_HAS_POSMTXIDX) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in uint4 posmtx;\n", SHADER_POSMTX_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in uint4 posmtx;\n", ShaderAttrib::PositionMatrix);
|
||||
if ((uid_data->components & VB_HAS_NORMAL) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawnormal;\n", SHADER_NORMAL_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawnormal;\n", ShaderAttrib::Normal);
|
||||
if ((uid_data->components & VB_HAS_TANGENT) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawtangent;\n", SHADER_TANGENT_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawtangent;\n", ShaderAttrib::Tangent);
|
||||
if ((uid_data->components & VB_HAS_BINORMAL) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float3 rawbinormal;\n", SHADER_BINORMAL_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float3 rawbinormal;\n", ShaderAttrib::Binormal);
|
||||
|
||||
if ((uid_data->components & VB_HAS_COL0) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor0;\n", SHADER_COLOR0_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawcolor0;\n", ShaderAttrib::Color0);
|
||||
if ((uid_data->components & VB_HAS_COL1) != 0)
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float4 rawcolor1;\n", SHADER_COLOR1_ATTRIB);
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float4 rawcolor1;\n", ShaderAttrib::Color1);
|
||||
|
||||
for (u32 i = 0; i < 8; ++i)
|
||||
{
|
||||
@ -139,7 +139,7 @@ ShaderCode GenerateVertexShaderCode(APIType api_type, const ShaderHostConfig& ho
|
||||
|
||||
if ((uid_data->components & (VB_HAS_UV0 << i)) != 0 || has_texmtx != 0)
|
||||
{
|
||||
out.Write("ATTRIBUTE_LOCATION({}) in float{} rawtex{};\n", SHADER_TEXTURE0_ATTRIB + i,
|
||||
out.Write("ATTRIBUTE_LOCATION({:s}) in float{} rawtex{};\n", ShaderAttrib::TexCoord0 + i,
|
||||
has_texmtx != 0 ? 3 : 2, i);
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/EnumFormatter.h"
|
||||
|
||||
#include "VideoCommon/LightingShaderGen.h"
|
||||
#include "VideoCommon/ShaderGenCommon.h"
|
||||
|
||||
@ -14,25 +16,39 @@ enum class SourceRow : u32;
|
||||
enum class VSExpand : u32;
|
||||
|
||||
// TODO should be reordered
|
||||
enum : int
|
||||
enum class ShaderAttrib : u32
|
||||
{
|
||||
SHADER_POSITION_ATTRIB = 0,
|
||||
SHADER_POSMTX_ATTRIB = 1,
|
||||
SHADER_NORMAL_ATTRIB = 2,
|
||||
SHADER_TANGENT_ATTRIB = 3,
|
||||
SHADER_BINORMAL_ATTRIB = 4,
|
||||
SHADER_COLOR0_ATTRIB = 5,
|
||||
SHADER_COLOR1_ATTRIB = 6,
|
||||
Position = 0,
|
||||
PositionMatrix = 1,
|
||||
Normal = 2,
|
||||
Tangent = 3,
|
||||
Binormal = 4,
|
||||
Color0 = 5,
|
||||
Color1 = 6,
|
||||
|
||||
SHADER_TEXTURE0_ATTRIB = 8,
|
||||
SHADER_TEXTURE1_ATTRIB = 9,
|
||||
SHADER_TEXTURE2_ATTRIB = 10,
|
||||
SHADER_TEXTURE3_ATTRIB = 11,
|
||||
SHADER_TEXTURE4_ATTRIB = 12,
|
||||
SHADER_TEXTURE5_ATTRIB = 13,
|
||||
SHADER_TEXTURE6_ATTRIB = 14,
|
||||
SHADER_TEXTURE7_ATTRIB = 15
|
||||
TexCoord0 = 8,
|
||||
TexCoord1 = 9,
|
||||
TexCoord2 = 10,
|
||||
TexCoord3 = 11,
|
||||
TexCoord4 = 12,
|
||||
TexCoord5 = 13,
|
||||
TexCoord6 = 14,
|
||||
TexCoord7 = 15
|
||||
};
|
||||
template <>
|
||||
struct fmt::formatter<ShaderAttrib> : EnumFormatter<ShaderAttrib::TexCoord7>
|
||||
{
|
||||
static constexpr array_type names = {
|
||||
"Position", "Position Matrix", "Normal", "Tangent", "Binormal", "Color 0",
|
||||
"Color 1", nullptr, "Tex Coord 0", "Tex Coord 1", "Tex Coord 2", "Tex Coord 3",
|
||||
"Tex Coord 4", "Tex Coord 5", "Tex Coord 6", "Tex Coord 7"};
|
||||
constexpr formatter() : EnumFormatter(names) {}
|
||||
};
|
||||
// Intended for offsetting from Color0/TexCoord0
|
||||
constexpr ShaderAttrib operator+(ShaderAttrib attrib, int offset)
|
||||
{
|
||||
return static_cast<ShaderAttrib>(static_cast<u8>(attrib) + offset);
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
|
Reference in New Issue
Block a user