diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 1bbc69a150..a4dad8293b 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -11,7 +11,6 @@ set(SRCS Src/BPFunctions.cpp Src/HiresTextures.cpp Src/ImageWrite.cpp Src/IndexGenerator.cpp - Src/LightingShaderGen.cpp Src/MainBase.cpp Src/OnScreenDisplay.cpp Src/OpcodeDecoding.cpp diff --git a/Source/Core/VideoCommon/Src/LightingShaderGen.cpp b/Source/Core/VideoCommon/Src/LightingShaderGen.cpp deleted file mode 100644 index 58da3612f5..0000000000 --- a/Source/Core/VideoCommon/Src/LightingShaderGen.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#include "LightingShaderGen.h" -#include "NativeVertexFormat.h" -#include "XFMemory.h" diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.h b/Source/Core/VideoCommon/Src/PixelShaderGen.h index 210dd9dd32..150a69902e 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.h +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.h @@ -55,14 +55,13 @@ const s_svar PSVar_Loc[] = { {I_COLORS, C_COLORS, 4 }, {I_PMATERIALS, C_PMATERIALS, 4 }, }; -// TODO: Should compact packing be enabled? -//#pragma pack(4) +#pragma pack(1) struct pixel_shader_uid_data { // TODO: Optimize field order for easy access! u32 num_values; // TODO: Shouldn't be a u32 - u32 NumValues() const { return num_values; } // TODO: Can be optimized :) + u32 NumValues() const { return num_values; } u32 components; u32 dstAlphaMode : 2; @@ -117,6 +116,7 @@ struct pixel_shader_uid_data u32 xfregs_numTexGen_numTexGens : 4; struct { + // TODO: Can save a lot space by removing the padding bits u32 cc : 24; u32 ac : 24; @@ -147,7 +147,7 @@ struct pixel_shader_uid_data // TODO: I think we're fine without an enablePixelLighting field, should probably double check, though.. LightingUidData lighting; }; -//#pragma pack() +#pragma pack() typedef ShaderUid PixelShaderUid; typedef ShaderCode PixelShaderCode; // TODO: Obsolete diff --git a/Source/Core/VideoCommon/Src/ShaderGenCommon.h b/Source/Core/VideoCommon/Src/ShaderGenCommon.h index 53f2405f8a..c8f8ff8345 100644 --- a/Source/Core/VideoCommon/Src/ShaderGenCommon.h +++ b/Source/Core/VideoCommon/Src/ShaderGenCommon.h @@ -199,10 +199,9 @@ static void DeclareUniform(T& object, API_TYPE api_type, bool using_ubos, const object.Write(";\n"); } -#pragma pack(4) +#pragma pack(1) /** * Common uid data used for shader generators that use lighting calculations. - * Expected to be stored as a member called "lighting". */ struct LightingUidData { diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp index a7e3a3d923..81d45cd6ad 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.cpp @@ -401,7 +401,7 @@ static void GenerateVertexShader(T& out, u32 components, API_TYPE api_type) { const PostMtxInfo& postInfo = xfregs.postMtxInfo[i]; - uid_data.postMtxInfo[i] = xfregs.postMtxInfo[i].index; + uid_data.postMtxInfo[i].index = xfregs.postMtxInfo[i].index; int postidx = postInfo.index; out.Write("float4 P0 = " I_POSTTRANSFORMMATRICES"[%d];\n" "float4 P1 = " I_POSTTRANSFORMMATRICES"[%d];\n" @@ -419,7 +419,7 @@ static void GenerateVertexShader(T& out, u32 components, API_TYPE api_type) } else { - uid_data.postMtxInfo[i] |= xfregs.postMtxInfo[i].normalize << 6; + uid_data.postMtxInfo[i].normalize = xfregs.postMtxInfo[i].normalize; if (postInfo.normalize) out.Write("o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i); diff --git a/Source/Core/VideoCommon/Src/VertexShaderGen.h b/Source/Core/VideoCommon/Src/VertexShaderGen.h index 3b233a22fe..797fe7d108 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderGen.h +++ b/Source/Core/VideoCommon/Src/VertexShaderGen.h @@ -71,22 +71,26 @@ struct vertex_shader_uid_data u32 NumValues() const { return num_values; } u32 components; - u32 num_values : 16; // TODO: Shouldn't be a u32 + u32 num_values : 16; // TODO: u8 might be enough, actually u32 numColorChans : 2; u32 numTexGens : 4; u32 dualTexTrans_enabled : 1; - u32 texMtxInfo_n_projection : 16; // XF_TEXPROJ_X + u32 texMtxInfo_n_projection : 16; // Stored separately to guarantee that the texMtxInfo struct is 8 bits wide struct { - u32 inputform : 2; // XF_TEXINPUT_X - u32 texgentype : 3; // XF_TEXGEN_X - u32 sourcerow : 5; // XF_SRCGEOM_X - u32 embosssourceshift : 3; // what generated texcoord to use - u32 embosslightshift : 3; // light index that is used - } texMtxInfo[8]; // TODO: Wasting space + u32 inputform : 2; + u32 texgentype : 3; + u32 sourcerow : 5; + u32 embosssourceshift : 3; + u32 embosslightshift : 3; + } texMtxInfo[8]; - u8 postMtxInfo[8]; // index + normalize + 1 padding bit, TODO: Can be made a struct again.. + struct { + u32 index : 6; + u32 normalize : 1; + u32 pad : 1; + } postMtxInfo[8]; LightingUidData lighting; }; diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 617e4ec567..1e7a56f578 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -190,7 +190,6 @@ - diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters index e988d34e12..785e55877f 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj.filters +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj.filters @@ -113,9 +113,6 @@ Base - - Shader Generators - Util @@ -294,4 +291,4 @@ {e2a527a2-ccc8-4ab8-a93e-dd2628c0f3b6} - \ No newline at end of file +