Finishing touches.

This commit is contained in:
NeoBrainX 2013-06-28 17:43:53 +02:00
parent ba310ce096
commit 166a9c5637
8 changed files with 21 additions and 30 deletions

View File

@ -11,7 +11,6 @@ set(SRCS Src/BPFunctions.cpp
Src/HiresTextures.cpp Src/HiresTextures.cpp
Src/ImageWrite.cpp Src/ImageWrite.cpp
Src/IndexGenerator.cpp Src/IndexGenerator.cpp
Src/LightingShaderGen.cpp
Src/MainBase.cpp Src/MainBase.cpp
Src/OnScreenDisplay.cpp Src/OnScreenDisplay.cpp
Src/OpcodeDecoding.cpp Src/OpcodeDecoding.cpp

View File

@ -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"

View File

@ -55,14 +55,13 @@ const s_svar PSVar_Loc[] = { {I_COLORS, C_COLORS, 4 },
{I_PMATERIALS, C_PMATERIALS, 4 }, {I_PMATERIALS, C_PMATERIALS, 4 },
}; };
// TODO: Should compact packing be enabled? #pragma pack(1)
//#pragma pack(4)
struct pixel_shader_uid_data struct pixel_shader_uid_data
{ {
// TODO: Optimize field order for easy access! // TODO: Optimize field order for easy access!
u32 num_values; // TODO: Shouldn't be a u32 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 components;
u32 dstAlphaMode : 2; u32 dstAlphaMode : 2;
@ -117,6 +116,7 @@ struct pixel_shader_uid_data
u32 xfregs_numTexGen_numTexGens : 4; u32 xfregs_numTexGen_numTexGens : 4;
struct { struct {
// TODO: Can save a lot space by removing the padding bits
u32 cc : 24; u32 cc : 24;
u32 ac : 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.. // TODO: I think we're fine without an enablePixelLighting field, should probably double check, though..
LightingUidData lighting; LightingUidData lighting;
}; };
//#pragma pack() #pragma pack()
typedef ShaderUid<pixel_shader_uid_data> PixelShaderUid; typedef ShaderUid<pixel_shader_uid_data> PixelShaderUid;
typedef ShaderCode PixelShaderCode; // TODO: Obsolete typedef ShaderCode PixelShaderCode; // TODO: Obsolete

View File

@ -199,10 +199,9 @@ static void DeclareUniform(T& object, API_TYPE api_type, bool using_ubos, const
object.Write(";\n"); object.Write(";\n");
} }
#pragma pack(4) #pragma pack(1)
/** /**
* Common uid data used for shader generators that use lighting calculations. * Common uid data used for shader generators that use lighting calculations.
* Expected to be stored as a member called "lighting".
*/ */
struct LightingUidData struct LightingUidData
{ {

View File

@ -401,7 +401,7 @@ static void GenerateVertexShader(T& out, u32 components, API_TYPE api_type)
{ {
const PostMtxInfo& postInfo = xfregs.postMtxInfo[i]; 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; int postidx = postInfo.index;
out.Write("float4 P0 = " I_POSTTRANSFORMMATRICES"[%d];\n" out.Write("float4 P0 = " I_POSTTRANSFORMMATRICES"[%d];\n"
"float4 P1 = " 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 else
{ {
uid_data.postMtxInfo[i] |= xfregs.postMtxInfo[i].normalize << 6; uid_data.postMtxInfo[i].normalize = xfregs.postMtxInfo[i].normalize;
if (postInfo.normalize) if (postInfo.normalize)
out.Write("o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i); out.Write("o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i);

View File

@ -71,22 +71,26 @@ struct vertex_shader_uid_data
u32 NumValues() const { return num_values; } u32 NumValues() const { return num_values; }
u32 components; 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 numColorChans : 2;
u32 numTexGens : 4; u32 numTexGens : 4;
u32 dualTexTrans_enabled : 1; 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 { struct {
u32 inputform : 2; // XF_TEXINPUT_X u32 inputform : 2;
u32 texgentype : 3; // XF_TEXGEN_X u32 texgentype : 3;
u32 sourcerow : 5; // XF_SRCGEOM_X u32 sourcerow : 5;
u32 embosssourceshift : 3; // what generated texcoord to use u32 embosssourceshift : 3;
u32 embosslightshift : 3; // light index that is used u32 embosslightshift : 3;
} texMtxInfo[8]; // TODO: Wasting space } 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; LightingUidData lighting;
}; };

View File

@ -190,7 +190,6 @@
<ClCompile Include="Src\HiresTextures.cpp" /> <ClCompile Include="Src\HiresTextures.cpp" />
<ClCompile Include="Src\ImageWrite.cpp" /> <ClCompile Include="Src\ImageWrite.cpp" />
<ClCompile Include="Src\IndexGenerator.cpp" /> <ClCompile Include="Src\IndexGenerator.cpp" />
<ClCompile Include="Src\LightingShaderGen.cpp" />
<ClCompile Include="Src\MainBase.cpp" /> <ClCompile Include="Src\MainBase.cpp" />
<ClCompile Include="Src\memcpy_amd.cpp" /> <ClCompile Include="Src\memcpy_amd.cpp" />
<ClCompile Include="Src\OnScreenDisplay.cpp" /> <ClCompile Include="Src\OnScreenDisplay.cpp" />

View File

@ -113,9 +113,6 @@
<ClCompile Include="Src\VertexManagerBase.cpp"> <ClCompile Include="Src\VertexManagerBase.cpp">
<Filter>Base</Filter> <Filter>Base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Src\LightingShaderGen.cpp">
<Filter>Shader Generators</Filter>
</ClCompile>
<ClCompile Include="Src\FPSCounter.cpp"> <ClCompile Include="Src\FPSCounter.cpp">
<Filter>Util</Filter> <Filter>Util</Filter>
</ClCompile> </ClCompile>
@ -294,4 +291,4 @@
<UniqueIdentifier>{e2a527a2-ccc8-4ab8-a93e-dd2628c0f3b6}</UniqueIdentifier> <UniqueIdentifier>{e2a527a2-ccc8-4ab8-a93e-dd2628c0f3b6}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
</Project> </Project>