diff --git a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp index 80a59b57b3..8f7d9cad12 100644 --- a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp @@ -3,6 +3,8 @@ #include +#include "Common/EnumMap.h" + #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DRender.h" #include "VideoBackends/D3D/D3DState.h" @@ -20,55 +22,75 @@ Renderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) return std::make_unique(vtx_decl); } -static const DXGI_FORMAT d3d_format_lookup[5 * 4 * 2] = { - // float formats - DXGI_FORMAT_R8_UNORM, - DXGI_FORMAT_R8_SNORM, - DXGI_FORMAT_R16_UNORM, - DXGI_FORMAT_R16_SNORM, - DXGI_FORMAT_R32_FLOAT, - DXGI_FORMAT_R8G8_UNORM, - DXGI_FORMAT_R8G8_SNORM, - DXGI_FORMAT_R16G16_UNORM, - DXGI_FORMAT_R16G16_SNORM, - DXGI_FORMAT_R32G32_FLOAT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_R32G32B32A32_FLOAT, - - // integer formats - DXGI_FORMAT_R8_UINT, - DXGI_FORMAT_R8_SINT, - DXGI_FORMAT_R16_UINT, - DXGI_FORMAT_R16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8_UINT, - DXGI_FORMAT_R8G8_SINT, - DXGI_FORMAT_R16G16_UINT, - DXGI_FORMAT_R16G16_SINT, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_UNKNOWN, - DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_UNKNOWN, -}; - -DXGI_FORMAT VarToD3D(VarType t, int size, bool integer) +DXGI_FORMAT VarToD3D(ComponentFormat t, int size, bool integer) { - DXGI_FORMAT retval = d3d_format_lookup[(int)t + 5 * (size - 1) + 5 * 4 * (int)integer]; + using FormatMap = Common::EnumMap; + static constexpr auto f = [](FormatMap a) { return a; }; // Deduction helper + + static constexpr std::array d3d_float_format_lookup = { + f({ + DXGI_FORMAT_R8_UNORM, + DXGI_FORMAT_R8_SNORM, + DXGI_FORMAT_R16_UNORM, + DXGI_FORMAT_R16_SNORM, + DXGI_FORMAT_R32_FLOAT, + }), + f({ + DXGI_FORMAT_R8G8_UNORM, + DXGI_FORMAT_R8G8_SNORM, + DXGI_FORMAT_R16G16_UNORM, + DXGI_FORMAT_R16G16_SNORM, + DXGI_FORMAT_R32G32_FLOAT, + }), + f({ + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_R32G32B32_FLOAT, + }), + f({ + DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_R32G32B32A32_FLOAT, + }), + }; + + static constexpr std::array d3d_integer_format_lookup = { + f({ + DXGI_FORMAT_R8_UINT, + DXGI_FORMAT_R8_SINT, + DXGI_FORMAT_R16_UINT, + DXGI_FORMAT_R16_SINT, + DXGI_FORMAT_UNKNOWN, + }), + f({ + DXGI_FORMAT_R8G8_UINT, + DXGI_FORMAT_R8G8_SINT, + DXGI_FORMAT_R16G16_UINT, + DXGI_FORMAT_R16G16_SINT, + DXGI_FORMAT_UNKNOWN, + }), + f({ + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + DXGI_FORMAT_UNKNOWN, + }), + f({ + DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_UNKNOWN, + }), + }; + + DXGI_FORMAT retval = + integer ? d3d_integer_format_lookup[size - 1][t] : d3d_float_format_lookup[size - 1][t]; if (retval == DXGI_FORMAT_UNKNOWN) { PanicAlertFmt("VarToD3D: Invalid type/size combo {}, {}, {}", t, size, integer); diff --git a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp index d95c8b9f7f..bd818d1a66 100644 --- a/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp +++ b/Source/Core/VideoBackends/D3D12/DX12VertexFormat.cpp @@ -4,39 +4,43 @@ #include "VideoBackends/D3D12/DX12VertexFormat.h" #include "Common/Assert.h" +#include "Common/EnumMap.h" #include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexShaderGen.h" namespace DX12 { -static DXGI_FORMAT VarToDXGIFormat(VarType t, u32 components, bool integer) +static DXGI_FORMAT VarToDXGIFormat(ComponentFormat t, u32 components, bool integer) { + using ComponentArray = std::array; + static constexpr auto f = [](ComponentArray a) { return a; }; // Deduction helper + // NOTE: 3-component formats are not valid. - static const DXGI_FORMAT float_type_lookup[][4] = { - {DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, - DXGI_FORMAT_R8G8B8A8_UNORM}, // VAR_UNSIGNED_BYTE - {DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, - DXGI_FORMAT_R8G8B8A8_SNORM}, // VAR_BYTE - {DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM, - DXGI_FORMAT_R16G16B16A16_UNORM}, // VAR_UNSIGNED_SHORT - {DXGI_FORMAT_R16_SNORM, DXGI_FORMAT_R16G16_SNORM, DXGI_FORMAT_R16G16B16A16_SNORM, - DXGI_FORMAT_R16G16B16A16_SNORM}, // VAR_SHORT - {DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT} // VAR_FLOAT + static constexpr Common::EnumMap float_type_lookup = { + f({DXGI_FORMAT_R8_UNORM, DXGI_FORMAT_R8G8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, + DXGI_FORMAT_R8G8B8A8_UNORM}), // UByte + f({DXGI_FORMAT_R8_SNORM, DXGI_FORMAT_R8G8_SNORM, DXGI_FORMAT_R8G8B8A8_SNORM, + DXGI_FORMAT_R8G8B8A8_SNORM}), // Byte + f({DXGI_FORMAT_R16_UNORM, DXGI_FORMAT_R16G16_UNORM, DXGI_FORMAT_R16G16B16A16_UNORM, + DXGI_FORMAT_R16G16B16A16_UNORM}), // UShort + f({DXGI_FORMAT_R16_SNORM, DXGI_FORMAT_R16G16_SNORM, DXGI_FORMAT_R16G16B16A16_SNORM, + DXGI_FORMAT_R16G16B16A16_SNORM}), // Short + f({DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT}), // Float }; - static const DXGI_FORMAT integer_type_lookup[][4] = { - {DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, - DXGI_FORMAT_R8G8B8A8_UINT}, // VAR_UNSIGNED_BYTE - {DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, - DXGI_FORMAT_R8G8B8A8_SINT}, // VAR_BYTE - {DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, - DXGI_FORMAT_R16G16B16A16_UINT}, // VAR_UNSIGNED_SHORT - {DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, - DXGI_FORMAT_R16G16B16A16_SINT}, // VAR_SHORT - {DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, - DXGI_FORMAT_R32G32B32A32_FLOAT} // VAR_FLOAT + static constexpr Common::EnumMap integer_type_lookup = { + f({DXGI_FORMAT_R8_UINT, DXGI_FORMAT_R8G8_UINT, DXGI_FORMAT_R8G8B8A8_UINT, + DXGI_FORMAT_R8G8B8A8_UINT}), // UByte + f({DXGI_FORMAT_R8_SINT, DXGI_FORMAT_R8G8_SINT, DXGI_FORMAT_R8G8B8A8_SINT, + DXGI_FORMAT_R8G8B8A8_SINT}), // Byte + f({DXGI_FORMAT_R16_UINT, DXGI_FORMAT_R16G16_UINT, DXGI_FORMAT_R16G16B16A16_UINT, + DXGI_FORMAT_R16G16B16A16_UINT}), // UShort + f({DXGI_FORMAT_R16_SINT, DXGI_FORMAT_R16G16_SINT, DXGI_FORMAT_R16G16B16A16_SINT, + DXGI_FORMAT_R16G16B16A16_SINT}), // Short + f({DXGI_FORMAT_R32_FLOAT, DXGI_FORMAT_R32G32_FLOAT, DXGI_FORMAT_R32G32B32_FLOAT, + DXGI_FORMAT_R32G32B32A32_FLOAT}), // Float }; ASSERT(components > 0 && components <= 4); diff --git a/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp b/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp index 9a6e568c8d..d21a40ebc1 100644 --- a/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/OGL/OGLNativeVertexFormat.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "Common/CommonTypes.h" +#include "Common/EnumMap.h" #include "Common/GL/GLUtil.h" #include "Common/MsgHandler.h" @@ -23,10 +24,11 @@ Renderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) return std::make_unique(vtx_decl); } -static inline GLuint VarToGL(VarType t) +static inline GLuint VarToGL(ComponentFormat t) { - static const GLuint lookup[5] = {GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, - GL_FLOAT}; + static constexpr Common::EnumMap lookup = { + GL_UNSIGNED_BYTE, GL_BYTE, GL_UNSIGNED_SHORT, GL_SHORT, GL_FLOAT, + }; return lookup[t]; } diff --git a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp index a7d0506a1f..af99e5ba85 100644 --- a/Source/Core/VideoBackends/Software/SWVertexLoader.cpp +++ b/Source/Core/VideoBackends/Software/SWVertexLoader.cpp @@ -145,7 +145,7 @@ static void ReadVertexAttribute(T* dst, DataReader src, const AttributeFormat& f if (format.enable) { src.Skip(format.offset); - src.Skip(base_component * (1 << (format.type >> 1))); + src.Skip(base_component * GetElementSize(format.type)); int i; for (i = 0; i < std::min(format.components - base_component, components); i++) @@ -153,24 +153,24 @@ static void ReadVertexAttribute(T* dst, DataReader src, const AttributeFormat& f int i_dst = reverse ? components - i - 1 : i; switch (format.type) { - case VAR_UNSIGNED_BYTE: + case ComponentFormat::UByte: dst[i_dst] = ReadNormalized(src.Read()); break; - case VAR_BYTE: + case ComponentFormat::Byte: dst[i_dst] = ReadNormalized(src.Read()); break; - case VAR_UNSIGNED_SHORT: + case ComponentFormat::UShort: dst[i_dst] = ReadNormalized(src.Read()); break; - case VAR_SHORT: + case ComponentFormat::Short: dst[i_dst] = ReadNormalized(src.Read()); break; - case VAR_FLOAT: + case ComponentFormat::Float: dst[i_dst] = ReadNormalized(src.Read()); break; } - ASSERT_MSG(VIDEO, !format.integer || format.type != VAR_FLOAT, + ASSERT_MSG(VIDEO, !format.integer || format.type != ComponentFormat::Float, "only non-float values are allowed to be streamed as integer"); } for (; i < components; i++) diff --git a/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp b/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp index e06beafbb8..5f53547066 100644 --- a/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKVertexFormat.cpp @@ -4,6 +4,7 @@ #include "VideoBackends/Vulkan/VKVertexFormat.h" #include "Common/Assert.h" +#include "Common/EnumMap.h" #include "VideoBackends/Vulkan/CommandBufferManager.h" #include "VideoBackends/Vulkan/ObjectCache.h" @@ -13,32 +14,35 @@ namespace Vulkan { -static VkFormat VarToVkFormat(VarType t, uint32_t components, bool integer) +static VkFormat VarToVkFormat(ComponentFormat t, uint32_t components, bool integer) { - static const VkFormat float_type_lookup[][4] = { - {VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8B8_UNORM, - VK_FORMAT_R8G8B8A8_UNORM}, // VAR_UNSIGNED_BYTE - {VK_FORMAT_R8_SNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8B8_SNORM, - VK_FORMAT_R8G8B8A8_SNORM}, // VAR_BYTE - {VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM, VK_FORMAT_R16G16B16_UNORM, - VK_FORMAT_R16G16B16A16_UNORM}, // VAR_UNSIGNED_SHORT - {VK_FORMAT_R16_SNORM, VK_FORMAT_R16G16_SNORM, VK_FORMAT_R16G16B16_SNORM, - VK_FORMAT_R16G16B16A16_SNORM}, // VAR_SHORT - {VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32_SFLOAT, - VK_FORMAT_R32G32B32A32_SFLOAT} // VAR_FLOAT + using ComponentArray = std::array; + static constexpr auto f = [](ComponentArray a) { return a; }; // Deduction helper + + static constexpr Common::EnumMap float_type_lookup = { + f({VK_FORMAT_R8_UNORM, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8G8B8_UNORM, + VK_FORMAT_R8G8B8A8_UNORM}), // UByte + f({VK_FORMAT_R8_SNORM, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8B8_SNORM, + VK_FORMAT_R8G8B8A8_SNORM}), // Byte + f({VK_FORMAT_R16_UNORM, VK_FORMAT_R16G16_UNORM, VK_FORMAT_R16G16B16_UNORM, + VK_FORMAT_R16G16B16A16_UNORM}), // UShort + f({VK_FORMAT_R16_SNORM, VK_FORMAT_R16G16_SNORM, VK_FORMAT_R16G16B16_SNORM, + VK_FORMAT_R16G16B16A16_SNORM}), // Short + f({VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32_SFLOAT, + VK_FORMAT_R32G32B32A32_SFLOAT}), // Float }; - static const VkFormat integer_type_lookup[][4] = { - {VK_FORMAT_R8_UINT, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8B8_UINT, - VK_FORMAT_R8G8B8A8_UINT}, // VAR_UNSIGNED_BYTE - {VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8_SINT, - VK_FORMAT_R8G8B8A8_SINT}, // VAR_BYTE - {VK_FORMAT_R16_UINT, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16B16_UINT, - VK_FORMAT_R16G16B16A16_UINT}, // VAR_UNSIGNED_SHORT - {VK_FORMAT_R16_SINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16B16_SINT, - VK_FORMAT_R16G16B16A16_SINT}, // VAR_SHORT - {VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32_SFLOAT, - VK_FORMAT_R32G32B32A32_SFLOAT} // VAR_FLOAT + static constexpr Common::EnumMap integer_type_lookup = { + f({VK_FORMAT_R8_UINT, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8B8_UINT, + VK_FORMAT_R8G8B8A8_UINT}), // UByte + f({VK_FORMAT_R8_SINT, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8B8_SINT, + VK_FORMAT_R8G8B8A8_SINT}), // Byte + f({VK_FORMAT_R16_UINT, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16B16_UINT, + VK_FORMAT_R16G16B16A16_UINT}), // UShort + f({VK_FORMAT_R16_SINT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16B16_SINT, + VK_FORMAT_R16G16B16A16_SINT}), // Short + f({VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32B32_SFLOAT, + VK_FORMAT_R32G32B32A32_SFLOAT}), // Float }; ASSERT(components > 0 && components <= 4); diff --git a/Source/Core/VideoCommon/FramebufferManager.cpp b/Source/Core/VideoCommon/FramebufferManager.cpp index 211adda800..43c213f8ba 100644 --- a/Source/Core/VideoCommon/FramebufferManager.cpp +++ b/Source/Core/VideoCommon/FramebufferManager.cpp @@ -837,12 +837,12 @@ bool FramebufferManager::CompilePokePipelines() { PortableVertexDeclaration vtx_decl = {}; vtx_decl.position.enable = true; - vtx_decl.position.type = VAR_FLOAT; + vtx_decl.position.type = ComponentFormat::Float; vtx_decl.position.components = 4; vtx_decl.position.integer = false; vtx_decl.position.offset = offsetof(EFBPokeVertex, position); vtx_decl.colors[0].enable = true; - vtx_decl.colors[0].type = VAR_UNSIGNED_BYTE; + vtx_decl.colors[0].type = ComponentFormat::UByte; vtx_decl.colors[0].components = 4; vtx_decl.colors[0].integer = false; vtx_decl.colors[0].offset = offsetof(EFBPokeVertex, color); diff --git a/Source/Core/VideoCommon/NativeVertexFormat.h b/Source/Core/VideoCommon/NativeVertexFormat.h index e4aa0f7e61..7bbf0bd38c 100644 --- a/Source/Core/VideoCommon/NativeVertexFormat.h +++ b/Source/Core/VideoCommon/NativeVertexFormat.h @@ -8,6 +8,7 @@ #include "Common/CommonTypes.h" #include "Common/Hash.h" +#include "VideoCommon/CPMemory.h" // m_components enum @@ -45,18 +46,9 @@ enum VB_HAS_UVTEXMTXSHIFT = 13, }; -enum VarType -{ - VAR_UNSIGNED_BYTE, // GX_U8 = 0 - VAR_BYTE, // GX_S8 = 1 - VAR_UNSIGNED_SHORT, // GX_U16 = 2 - VAR_SHORT, // GX_S16 = 3 - VAR_FLOAT, // GX_F32 = 4 -}; - struct AttributeFormat { - VarType type; + ComponentFormat type; int components; int offset; bool enable; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 16d36f7453..31cfd36aee 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -986,9 +986,9 @@ bool Renderer::InitializeImGui() ImGui::GetStyle().WindowRounding = 7.0f; PortableVertexDeclaration vdecl = {}; - vdecl.position = {VAR_FLOAT, 2, offsetof(ImDrawVert, pos), true, false}; - vdecl.texcoords[0] = {VAR_FLOAT, 2, offsetof(ImDrawVert, uv), true, false}; - vdecl.colors[0] = {VAR_UNSIGNED_BYTE, 4, offsetof(ImDrawVert, col), true, false}; + vdecl.position = {ComponentFormat::Float, 2, offsetof(ImDrawVert, pos), true, false}; + vdecl.texcoords[0] = {ComponentFormat::Float, 2, offsetof(ImDrawVert, uv), true, false}; + vdecl.colors[0] = {ComponentFormat::UByte, 4, offsetof(ImDrawVert, col), true, false}; vdecl.stride = sizeof(ImDrawVert); m_imgui_vertex_format = CreateNativeVertexFormat(vdecl); if (!m_imgui_vertex_format) diff --git a/Source/Core/VideoCommon/ShaderCache.cpp b/Source/Core/VideoCommon/ShaderCache.cpp index 8b1196cabc..b72dd238ff 100644 --- a/Source/Core/VideoCommon/ShaderCache.cpp +++ b/Source/Core/VideoCommon/ShaderCache.cpp @@ -1095,7 +1095,7 @@ void ShaderCache::QueueUberShaderPipelines() // All attributes will be enabled in GetUberVertexFormat. PortableVertexDeclaration dummy_vertex_decl = {}; dummy_vertex_decl.position.components = 4; - dummy_vertex_decl.position.type = VAR_FLOAT; + dummy_vertex_decl.position.type = ComponentFormat::Float; dummy_vertex_decl.position.enable = true; dummy_vertex_decl.stride = sizeof(float) * 4; NativeVertexFormat* dummy_vertex_format = diff --git a/Source/Core/VideoCommon/VertexLoader.cpp b/Source/Core/VideoCommon/VertexLoader.cpp index aaf7a477f7..69f669cd4c 100644 --- a/Source/Core/VideoCommon/VertexLoader.cpp +++ b/Source/Core/VideoCommon/VertexLoader.cpp @@ -91,7 +91,7 @@ void VertexLoader::CompileVertexTranslator() m_native_vtx_decl.posmtx.components = 4; m_native_vtx_decl.posmtx.enable = true; m_native_vtx_decl.posmtx.offset = nat_offset; - m_native_vtx_decl.posmtx.type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.posmtx.type = ComponentFormat::UByte; m_native_vtx_decl.posmtx.integer = true; nat_offset += 4; } @@ -110,7 +110,7 @@ void VertexLoader::CompileVertexTranslator() m_native_vtx_decl.position.components = pos_elements; m_native_vtx_decl.position.enable = true; m_native_vtx_decl.position.offset = nat_offset; - m_native_vtx_decl.position.type = VAR_FLOAT; + m_native_vtx_decl.position.type = ComponentFormat::Float; m_native_vtx_decl.position.integer = false; nat_offset += pos_elements * sizeof(float); @@ -134,7 +134,7 @@ void VertexLoader::CompileVertexTranslator() m_native_vtx_decl.normals[i].components = 3; m_native_vtx_decl.normals[i].enable = true; m_native_vtx_decl.normals[i].offset = nat_offset; - m_native_vtx_decl.normals[i].type = VAR_FLOAT; + m_native_vtx_decl.normals[i].type = ComponentFormat::Float; m_native_vtx_decl.normals[i].integer = false; nat_offset += 12; } @@ -143,7 +143,7 @@ void VertexLoader::CompileVertexTranslator() for (size_t i = 0; i < m_VtxDesc.low.Color.Size(); i++) { m_native_vtx_decl.colors[i].components = 4; - m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.colors[i].type = ComponentFormat::UByte; m_native_vtx_decl.colors[i].integer = false; TPipelineFunction pFunc = @@ -166,7 +166,7 @@ void VertexLoader::CompileVertexTranslator() for (size_t i = 0; i < m_VtxDesc.high.TexCoord.Size(); i++) { m_native_vtx_decl.texcoords[i].offset = nat_offset; - m_native_vtx_decl.texcoords[i].type = VAR_FLOAT; + m_native_vtx_decl.texcoords[i].type = ComponentFormat::Float; m_native_vtx_decl.texcoords[i].integer = false; const auto tc = m_VtxDesc.high.TexCoord[i].Value(); diff --git a/Source/Core/VideoCommon/VertexLoaderARM64.cpp b/Source/Core/VideoCommon/VertexLoaderARM64.cpp index 106f1cfd9e..330deef548 100644 --- a/Source/Core/VideoCommon/VertexLoaderARM64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderARM64.cpp @@ -221,7 +221,7 @@ int VertexLoaderARM64::ReadVertex(VertexComponentFormat attribute, ComponentForm native_format->components = count_out; native_format->enable = true; native_format->offset = m_dst_ofs; - native_format->type = VAR_FLOAT; + native_format->type = ComponentFormat::Float; native_format->integer = false; m_dst_ofs += sizeof(float) * count_out; @@ -429,7 +429,7 @@ void VertexLoaderARM64::GenerateVertexLoader() m_native_vtx_decl.posmtx.components = 4; m_native_vtx_decl.posmtx.enable = true; m_native_vtx_decl.posmtx.offset = m_dst_ofs; - m_native_vtx_decl.posmtx.type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.posmtx.type = ComponentFormat::UByte; m_native_vtx_decl.posmtx.integer = true; m_src_ofs += sizeof(u8); m_dst_ofs += sizeof(u32); @@ -493,7 +493,7 @@ void VertexLoaderARM64::GenerateVertexLoader() for (u8 i = 0; i < m_VtxDesc.low.Color.Size(); i++) { m_native_vtx_decl.colors[i].components = 4; - m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.colors[i].type = ComponentFormat::UByte; m_native_vtx_decl.colors[i].integer = false; if (m_VtxDesc.low.Color[i] != VertexComponentFormat::NotPresent) @@ -509,7 +509,7 @@ void VertexLoaderARM64::GenerateVertexLoader() m_native_vtx_decl.colors[i].components = 4; m_native_vtx_decl.colors[i].enable = true; m_native_vtx_decl.colors[i].offset = m_dst_ofs; - m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.colors[i].type = ComponentFormat::UByte; m_native_vtx_decl.colors[i].integer = false; m_dst_ofs += 4; } @@ -518,7 +518,7 @@ void VertexLoaderARM64::GenerateVertexLoader() for (u8 i = 0; i < m_VtxDesc.high.TexCoord.Size(); i++) { m_native_vtx_decl.texcoords[i].offset = m_dst_ofs; - m_native_vtx_decl.texcoords[i].type = VAR_FLOAT; + m_native_vtx_decl.texcoords[i].type = ComponentFormat::Float; m_native_vtx_decl.texcoords[i].integer = false; int elements = m_VtxAttr.GetTexElements(i) == TexComponentCount::S ? 1 : 2; @@ -540,7 +540,7 @@ void VertexLoaderARM64::GenerateVertexLoader() { m_native_vtx_decl.texcoords[i].components = 3; m_native_vtx_decl.texcoords[i].enable = true; - m_native_vtx_decl.texcoords[i].type = VAR_FLOAT; + m_native_vtx_decl.texcoords[i].type = ComponentFormat::Float; m_native_vtx_decl.texcoords[i].integer = false; LDRB(IndexType::Unsigned, scratch2_reg, src_reg, texmatidx_ofs[i]); diff --git a/Source/Core/VideoCommon/VertexLoaderManager.cpp b/Source/Core/VideoCommon/VertexLoaderManager.cpp index ef1e2f7aee..b0922e5a6e 100644 --- a/Source/Core/VideoCommon/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/VertexLoaderManager.cpp @@ -146,7 +146,8 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl) std::memset(&new_decl, 0, sizeof(new_decl)); new_decl.stride = decl.stride; - auto MakeDummyAttribute = [](AttributeFormat& attr, VarType type, int components, bool integer) { + auto MakeDummyAttribute = [](AttributeFormat& attr, ComponentFormat type, int components, + bool integer) { attr.type = type; attr.components = components; attr.offset = 0; @@ -164,32 +165,32 @@ NativeVertexFormat* GetUberVertexFormat(const PortableVertexDeclaration& decl) if (decl.position.enable) CopyAttribute(new_decl.position, decl.position); else - MakeDummyAttribute(new_decl.position, VAR_FLOAT, 1, false); + MakeDummyAttribute(new_decl.position, ComponentFormat::Float, 1, false); for (size_t i = 0; i < std::size(new_decl.normals); i++) { if (decl.normals[i].enable) CopyAttribute(new_decl.normals[i], decl.normals[i]); else - MakeDummyAttribute(new_decl.normals[i], VAR_FLOAT, 1, false); + MakeDummyAttribute(new_decl.normals[i], ComponentFormat::Float, 1, false); } for (size_t i = 0; i < std::size(new_decl.colors); i++) { if (decl.colors[i].enable) CopyAttribute(new_decl.colors[i], decl.colors[i]); else - MakeDummyAttribute(new_decl.colors[i], VAR_UNSIGNED_BYTE, 4, false); + MakeDummyAttribute(new_decl.colors[i], ComponentFormat::UByte, 4, false); } for (size_t i = 0; i < std::size(new_decl.texcoords); i++) { if (decl.texcoords[i].enable) CopyAttribute(new_decl.texcoords[i], decl.texcoords[i]); else - MakeDummyAttribute(new_decl.texcoords[i], VAR_FLOAT, 1, false); + MakeDummyAttribute(new_decl.texcoords[i], ComponentFormat::Float, 1, false); } if (decl.posmtx.enable) CopyAttribute(new_decl.posmtx, decl.posmtx); else - MakeDummyAttribute(new_decl.posmtx, VAR_UNSIGNED_BYTE, 1, true); + MakeDummyAttribute(new_decl.posmtx, ComponentFormat::UByte, 1, true); return GetOrCreateMatchingFormat(new_decl); } diff --git a/Source/Core/VideoCommon/VertexLoaderX64.cpp b/Source/Core/VideoCommon/VertexLoaderX64.cpp index 4022863e59..40ae508219 100644 --- a/Source/Core/VideoCommon/VertexLoaderX64.cpp +++ b/Source/Core/VideoCommon/VertexLoaderX64.cpp @@ -122,7 +122,7 @@ int VertexLoaderX64::ReadVertex(OpArg data, VertexComponentFormat attribute, Com native_format->components = count_out; native_format->enable = true; native_format->offset = m_dst_ofs; - native_format->type = VAR_FLOAT; + native_format->type = ComponentFormat::Float; native_format->integer = false; m_dst_ofs += sizeof(float) * count_out; @@ -421,7 +421,7 @@ void VertexLoaderX64::GenerateVertexLoader() m_native_vtx_decl.posmtx.components = 4; m_native_vtx_decl.posmtx.enable = true; m_native_vtx_decl.posmtx.offset = m_dst_ofs; - m_native_vtx_decl.posmtx.type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.posmtx.type = ComponentFormat::UByte; m_native_vtx_decl.posmtx.integer = true; m_src_ofs += sizeof(u8); m_dst_ofs += sizeof(u32); @@ -467,7 +467,7 @@ void VertexLoaderX64::GenerateVertexLoader() m_native_vtx_decl.colors[i].components = 4; m_native_vtx_decl.colors[i].enable = true; m_native_vtx_decl.colors[i].offset = m_dst_ofs; - m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE; + m_native_vtx_decl.colors[i].type = ComponentFormat::UByte; m_native_vtx_decl.colors[i].integer = false; m_dst_ofs += 4; } @@ -488,7 +488,7 @@ void VertexLoaderX64::GenerateVertexLoader() { m_native_vtx_decl.texcoords[i].components = 3; m_native_vtx_decl.texcoords[i].enable = true; - m_native_vtx_decl.texcoords[i].type = VAR_FLOAT; + m_native_vtx_decl.texcoords[i].type = ComponentFormat::Float; m_native_vtx_decl.texcoords[i].integer = false; MOVZX(64, 8, scratch1, MDisp(src_reg, texmatidx_ofs[i])); if (m_VtxDesc.high.TexCoord[i] != VertexComponentFormat::NotPresent)