diff options
| author | Pokechu22 <Pokechu022@gmail.com> | 2021-06-26 12:48:28 -0700 |
|---|---|---|
| committer | Pokechu22 <Pokechu022@gmail.com> | 2021-12-18 15:21:48 -0800 |
| commit | 27cb7044669c62922be6f68913007d2567ce2480 (patch) | |
| tree | d976e86d2b88e2ef9b0a005e65d0776645d67316 /Source/Core/VideoCommon | |
| parent | 1a964891f83ef9332c425dd69fe2f277b8ceb992 (diff) | |
Eliminate VarType for ComponentFormat
Diffstat (limited to 'Source/Core/VideoCommon')
| -rw-r--r-- | Source/Core/VideoCommon/FramebufferManager.cpp | 4 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/NativeVertexFormat.h | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/RenderBase.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/ShaderCache.cpp | 2 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoader.cpp | 10 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderARM64.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderManager.cpp | 13 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/VertexLoaderX64.cpp | 8 |
8 files changed, 30 insertions, 37 deletions
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) |
