Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Software Renderer #3197

Merged
merged 116 commits into from Aug 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
19c6fed
Copy NullGpu to SoftGpu.
neobrain Jun 24, 2013
6cd1091
Add an option for enabling software rendering.
neobrain Aug 16, 2013
b1d4919
softgpu: Dummy implementation for CopyDisplayToOutput.
neobrain Jun 24, 2013
232a037
softgpu: Clean up.
neobrain Jun 24, 2013
1430ca3
softgpu: Add transform pipeline functionality.
neobrain Jun 24, 2013
91ad30c
softgpu/TransformUnit: Implement remaining coordinate system transfor…
neobrain Jun 24, 2013
55a94f9
softgpu: Use existing VertexDecoder/VertexReader to add vertex decodi…
neobrain Jun 25, 2013
40cdabe
softgpu: Add vertex position transformation code. Seems to be doing s…
neobrain Jun 25, 2013
a4af6d4
softgpu: Add line drawing. (yep, transform code definitely doesn't wo…
neobrain Jun 25, 2013
209e040
softgpu: Fix some bugs, committing stuff before it breaks again...
neobrain Jun 25, 2013
6e124f3
softgpu: Working vertex position transform!
neobrain Jun 25, 2013
5510434
softgpu: Cleanups.
neobrain Jun 25, 2013
adbe80c
softgpu: Move around some code to keep SoftGpu.cpp clean.
neobrain Jun 25, 2013
142f2a3
softgpu: Move triangle rasterization code to a new file.
neobrain Jun 25, 2013
748d2d6
softgpu: Implement filled triangle rendering.
neobrain Jun 25, 2013
7899a9b
softgpu: Texture coordinate support and something like ARGB4444 textu…
neobrain Jun 25, 2013
f6b51dc
softgpu: Working ARGB4444 texture support.
neobrain Jun 25, 2013
608fd34
softgpu: Implement almost working polygon clipping and fix some bugs.
neobrain Jun 25, 2013
f26d66e
softgpu: Fix a bug in the clipspace->screenspace transformation. Make…
neobrain Jun 26, 2013
b5181c9
softgpu: Add support for RGB565, RGBA5111 and RGBA8888 textures.
neobrain Jun 26, 2013
2aff3a8
softgpu: Move clipping code to a separate file.
neobrain Jun 26, 2013
55d6646
softgpu: Add something like rectangle support. Doesn't seem to work :/
neobrain Jun 26, 2013
0c6a4c1
softgpu: Working rectangle support. Through mode support. Clear mode …
neobrain Jun 26, 2013
02f41ec
softgpu: Perspective correct texture mapping.
neobrain Jun 26, 2013
ed5fa1f
softgpu: Fix vertex color decoding.
neobrain Jun 26, 2013
a317876
softgpu: Add (probably broken) rectangle clipping support.
neobrain Jun 27, 2013
8f861d8
softgpu: Add naive rectangle clipper (which works just as bad).
neobrain Jun 28, 2013
73e3b78
softgpu: Support flat triangle shading.
neobrain Jun 28, 2013
bfd9266
softgpu: Add support for ambient lighting.
neobrain Jun 28, 2013
288de89
softgpu: Support indexed rendering.
neobrain Jun 28, 2013
7fdce30
softgpu: Implement diffuse lighting.
neobrain Jun 28, 2013
b42b30e
softgpu: Store color values as integers instead of as floating points.
neobrain Jun 28, 2013
48d75da
softgpu: Implement attenuation and spot factors.
neobrain Jun 28, 2013
0bf4956
softgpu: Implement per-light ambient lighting.
neobrain Jun 28, 2013
704a416
softgpu: Implement powered diffuse lighting.
neobrain Jun 28, 2013
6c1b4ba
softgpu: Implement specular lighting.
neobrain Jun 29, 2013
41e2005
softgpu: Fix various bugs.
neobrain Jun 29, 2013
c5544eb
softgpu: Fix some lighting bugs. Ambient and diffuse light should be …
neobrain Jun 29, 2013
219b353
softgpu: Transform normals correctly.
neobrain Jun 29, 2013
fd65b7c
softgpu: New try at specular lighting, still doesn't seem to work...
neobrain Jun 29, 2013
b1a4762
softgpu: Fix specular lighting (or rather, the dumb code that always …
neobrain Jun 29, 2013
29921e4
softgpu: Disable alpha blending when copying framebuffer to screen.
neobrain Jun 29, 2013
3cdf2a7
softgpu: Write to the correct frame buffer in RAM.
neobrain Jun 29, 2013
72a7170
softgpu: Storing view coordinates in VertexData is not necessary anym…
neobrain Jun 29, 2013
00b7fbd
softgpu: Implement depth testing.
neobrain Jun 29, 2013
b33646c
softgpu: Disable texturing in clear mode.
neobrain Jun 29, 2013
bd49480
softgpu: Add initial support for triangle strips. No idea if they work.
neobrain Jun 29, 2013
0e1e8fe
softgpu: Clean up depth testing code.
neobrain Jun 29, 2013
cc043ad
softgpu: Implement texture functions.
neobrain Jun 29, 2013
6930e29
softgpu: Implement color doubling and color addition.
neobrain Jun 29, 2013
15d0d2e
softgpu: Fix (?) texture coordinate reading for through mode. Needs r…
neobrain Jul 3, 2013
df40c76
softgpu: Do weird stuff with no profit. Check this=> TODO
neobrain Jul 3, 2013
247ea27
softgpu: Implement alpha blending.
neobrain Jul 3, 2013
8e7f35f
softgpu: Workaround a bug in through mode (in Rasterizer::DrawTriangl…
neobrain Jul 3, 2013
f270d3b
softgpu: Simplify Rasterizer::DrawTriangle by passing individual vert…
neobrain Jul 11, 2013
ce953f1
softgpu: Use Vec4 instead of our own Color4 class for color handling.
neobrain Jul 11, 2013
4231264
softgpu: Clean up Rasterizer code by using Math3D's Vec4 functionality.
neobrain Jul 11, 2013
b0d3848
softgpu: Don't draw pixels which lie on the right side of a triangle.
neobrain Jul 12, 2013
f447957
softgpu: Use the actual z coordinate of a triangle in through mode, too.
neobrain Jul 12, 2013
06290c5
softgpu: Fix an issue where texture coordinates were not initialized …
neobrain Jul 18, 2013
26d80c1
softgpu/TransformPipeline: Clean up VertexData::Lerp by using Math3D …
neobrain Jul 18, 2013
602e0e5
softgpu: Add working CLUT support.
neobrain Jul 11, 2013
3f9633e
softgpu: Fix a dumb mistake in the alpha blending code. How did this …
neobrain Jul 19, 2013
3ccc0c1
softgpu/Rasterizer: Warning fixes.
neobrain Jul 19, 2013
27414c0
softgpu/Rasterizer: Fix decal texfunc.
neobrain Jul 25, 2013
8929b0c
softgpu/Rasterizer: Fix (or rather workaround) a critical integer ove…
neobrain Jul 19, 2013
40c83de
softgpu: Fix vertex order when drawing rectangles.
neobrain Jul 19, 2013
84425aa
softgpu: Fix (?) interpolation method for z and color values.
neobrain Jul 19, 2013
0dbe5c5
softgpu: Cleanup CLUT lookup code and fix a critical bug related to i…
neobrain Jul 19, 2013
df141ff
softgpu: Implement stencil testing. Add some TODOs. Disable alpha ble…
neobrain Jul 19, 2013
e1cc254
softgpu: Fix fast texture storage mode and use correct texture buffer…
neobrain Jul 19, 2013
90b868d
softgpu/Rasterizer: Clean up texture sampling code.
neobrain Jul 19, 2013
e7ac41c
softgpu: Possibly fix a bug. Or make things worse. I don't know :/
neobrain Jul 19, 2013
c549ee0
softgpu: Fix some alpha blending bugs.
neobrain Jul 19, 2013
88348a3
softgpu: Fix rgba texture function.
neobrain Jul 20, 2013
2336f4c
softgpu: Assign texture alpha value to 255 when no alpha channel is p…
neobrain Jul 20, 2013
dedb3de
softgpu: Add support for 32 bit and 16 bit index texture formats.
neobrain Jul 21, 2013
54c9303
softgpu: static inline everything.
neobrain Jul 21, 2013
37ef488
softgpu: Support RGB565, RGBA5551 and RGBA4444 CLUT formats.
neobrain Jul 21, 2013
ccb487c
softgpu: Clip primitives when one of their vertices is outside the sc…
neobrain Jul 21, 2013
b2d4df2
Fixes for CLUT decoding
neobrain Jul 21, 2013
a013aad
softgpu: Fix incorrect depth buffer write base address.
neobrain Jul 21, 2013
c957574
softgpu: Implement color masking.
neobrain Jul 21, 2013
4e1d2f0
softgpu: Implement logic ops.
neobrain Jul 21, 2013
d91d5c0
GPUState: Fix depth buffer stride getter.
neobrain Jul 21, 2013
c8f1819
softgpu: Fix triangle borders not fitting together properly.
neobrain Jul 23, 2013
44035df
SoftGpu: Add support for triangle fans.
neobrain Jul 23, 2013
e1216e9
softgpu: Implement texture scaling, texture offset and texture coordi…
neobrain Jul 23, 2013
2ea7162
softgpu: Implement depth range test.
neobrain Jul 23, 2013
917dc27
softgpu: Small cleanup in Clipper.
neobrain Jul 23, 2013
f35e085
softgpu: Change framebuffer writes to act on actual 16 bit pixels if …
neobrain Jul 23, 2013
62b384e
softgpu: Lots of clearmode fixes.
neobrain Jul 23, 2013
002ab3e
softgpu: Hackfix CLUT4 texture deswizzling.
neobrain Jul 23, 2013
0c6a9dc
softgpu: Optimization, part 1.
neobrain Jul 24, 2013
b22a82d
softgpu: Optimization, part 2.
neobrain Jul 24, 2013
bacadef
softgpu: Optimization, part 3.
neobrain Jul 24, 2013
104feea
softgpu: Restructure texture sampling code a bit.
neobrain Jul 24, 2013
d2f3096
softgpu: Make perspective correct uv mapping code more readable and i…
neobrain Jul 24, 2013
1450157
softgpu: Implement environment mapping.
neobrain Jul 24, 2013
f6feb87
softgpu/Rasterizer: Structure some code more clearly.
neobrain Jul 24, 2013
ad8449c
softgpu: Add some safety checks.
neobrain Jul 24, 2013
f4cb929
softgpu: Fix a lighting bug.
neobrain Jul 24, 2013
11a94e1
softgpu: Implement spline surface drawing (without patch subdivision).
neobrain Jul 24, 2013
6b90aa2
softgpu: Polish some helper function signatures.
neobrain Jul 25, 2013
9bc3e8b
softgpu: Generate texture coordinates for environment mapping even if…
neobrain Jul 25, 2013
e984374
GPU: Explicitily assign enum values for GEComparison.
neobrain Jul 25, 2013
2962d24
softgpu: Implement skinning.
neobrain Jul 25, 2013
838d22d
softgpu: Implement memory transfers.
neobrain Jul 26, 2013
fc33677
softgpu: Fix normal-mode rectangle drawing.
neobrain Jul 27, 2013
4557750
softgpu: Disable clipping if it's not requested by the game. Also fix…
neobrain Jul 27, 2013
67f95d3
softgpu: Some cleanups in SoftGpu.cpp
neobrain Jul 27, 2013
d0c05b7
softgpu: Fix some stencil testing related bugs.
neobrain Jul 27, 2013
c707140
softgpu: Implement normal reversal.
neobrain Jul 27, 2013
74eafca
softgpu: Process rasterization in screen space, rather than drawing s…
neobrain Jul 28, 2013
edc0dd9
GPU: Remove unncessary flags in the VC project file.
neobrain Aug 17, 2013
f02f13f
Fix Qt and Android build.
neobrain Aug 17, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1015,6 +1015,16 @@ add_library(GPU OBJECT
GPU/Math3D.h
GPU/Null/NullGpu.cpp
GPU/Null/NullGpu.h
GPU/Software/Clipper.cpp
GPU/Software/Clipper.h
GPU/Software/Lighting.cpp
GPU/Software/Lighting.h
GPU/Software/Rasterizer.cpp
GPU/Software/Rasterizer.h
GPU/Software/SoftGpu.cpp
GPU/Software/SoftGpu.h
GPU/Software/TransformUnit.cpp
GPU/Software/TransformUnit.h
GPU/ge_constants.h)
setup_target_project(GPU GPU)

Expand Down
2 changes: 2 additions & 0 deletions Core/Config.cpp
Expand Up @@ -108,6 +108,7 @@ void Config::Load(const char *iniFileName)
1
#endif
); // default is buffered rendering mode
graphics->Get("SoftwareRendering", &bSoftwareRendering, false);
graphics->Get("HardwareTransform", &bHardwareTransform, true);
graphics->Get("TextureFiltering", &iTexFiltering, 1);
graphics->Get("SSAA", &bAntiAliasing, 0);
Expand Down Expand Up @@ -242,6 +243,7 @@ void Config::Save()
graphics->Set("ShowFPSCounter", iShowFPSCounter);
graphics->Set("ResolutionScale", iWindowZoom);
graphics->Set("RenderingMode", iRenderingMode);
graphics->Set("SoftwareRendering", bSoftwareRendering);
graphics->Set("HardwareTransform", bHardwareTransform);
graphics->Set("TextureFiltering", iTexFiltering);
graphics->Set("SSAA", bAntiAliasing);
Expand Down
3 changes: 2 additions & 1 deletion Core/Config.h
Expand Up @@ -65,7 +65,8 @@ struct Config
std::string languageIni;

// GFX
bool bHardwareTransform;
bool bSoftwareRendering;
bool bHardwareTransform; // only used in the GLES backend
int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering 2 = Read Framebuffer to memory (CPU) 3 = Read Framebuffer to memory (GPU)
int iTexFiltering; // 1 = off , 2 = nearest , 3 = linear , 4 = linear(CG)
#ifdef BLACKBERRY
Expand Down
5 changes: 5 additions & 0 deletions GPU/CMakeLists.txt
Expand Up @@ -14,6 +14,11 @@ set(SRCS
GLES/VertexDecoder.cpp
GLES/VertexShaderGenerator.cpp
Null/NullGpu.cpp
Software/Clipper.cpp
Software/Lighting.cpp
Software/Rasterizer.cpp
Software/SoftGpu.cpp
Software/TransformUnit.cpp
)

set(SRCS ${SRCS})
Expand Down
13 changes: 12 additions & 1 deletion GPU/GPU.vcxproj
Expand Up @@ -158,6 +158,12 @@
<ClInclude Include="GPUState.h" />
<ClInclude Include="Math3D.h" />
<ClInclude Include="Null\NullGpu.h" />
<ClInclude Include="Software\Clipper.h" />
<ClInclude Include="Software\Colors.h" />
<ClInclude Include="Software\Lighting.h" />
<ClInclude Include="Software\Rasterizer.h" />
<ClInclude Include="Software\SoftGpu.h" />
<ClInclude Include="Software\TransformUnit.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ext\xbrz\xbrz.cpp" />
Expand All @@ -179,6 +185,11 @@
<ClCompile Include="GPUState.cpp" />
<ClCompile Include="Math3D.cpp" />
<ClCompile Include="Null\NullGpu.cpp" />
<ClCompile Include="Software\Clipper.cpp" />
<ClCompile Include="Software\Lighting.cpp" />
<ClCompile Include="Software\Rasterizer.cpp" />
<ClCompile Include="Software\SoftGpu.cpp" />
<ClCompile Include="Software\TransformUnit.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.vcxproj">
Expand All @@ -191,4 +202,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
35 changes: 34 additions & 1 deletion GPU/GPU.vcxproj.filters
Expand Up @@ -68,6 +68,24 @@
<ClInclude Include="GLES\TextureScaler.h">
<Filter>GLES</Filter>
</ClInclude>
<ClInclude Include="Software\Colors.h">
<Filter>Software</Filter>
</ClInclude>
<ClInclude Include="Software\Clipper.h">
<Filter>Software</Filter>
</ClInclude>
<ClInclude Include="Software\Lighting.h">
<Filter>Software</Filter>
</ClInclude>
<ClInclude Include="Software\Rasterizer.h">
<Filter>Software</Filter>
</ClInclude>
<ClInclude Include="Software\SoftGpu.h">
<Filter>Software</Filter>
</ClInclude>
<ClInclude Include="Software\TransformUnit.h">
<Filter>Software</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math3D.cpp">
Expand Down Expand Up @@ -117,8 +135,23 @@
<ClCompile Include="GLES\TextureScaler.cpp">
<Filter>GLES</Filter>
</ClCompile>
<ClCompile Include="Software\Clipper.cpp">
<Filter>Software</Filter>
</ClCompile>
<ClCompile Include="Software\Lighting.cpp">
<Filter>Software</Filter>
</ClCompile>
<ClCompile Include="Software\Rasterizer.cpp">
<Filter>Software</Filter>
</ClCompile>
<ClCompile Include="Software\SoftGpu.cpp">
<Filter>Software</Filter>
</ClCompile>
<ClCompile Include="Software\TransformUnit.cpp">
<Filter>Software</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>
3 changes: 2 additions & 1 deletion GPU/GPUState.cpp
Expand Up @@ -20,6 +20,7 @@
#include "GLES/ShaderManager.h"
#include "GLES/DisplayListInterpreter.h"
#include "Null/NullGpu.h"
#include "Software/SoftGpu.h"
#include "../Core/CoreParameter.h"
#include "../Core/System.h"

Expand All @@ -37,7 +38,7 @@ void GPU_Init() {
gpu = new GLES_GPU();
break;
case GPU_SOFTWARE:
gpu = new NullGPU();
gpu = new SoftGPU();
break;
}
}
Expand Down
16 changes: 14 additions & 2 deletions GPU/GPUState.h
Expand Up @@ -211,6 +211,10 @@ struct GPUgstate
float tgenMatrix[12];
float boneMatrix[12 * 8]; // Eight bone matrices.

GEBufferFormat FrameBufFormat() const { return static_cast<GEBufferFormat>(framebufpixformat & 3); }
int FrameBufStride() const { return fbwidth&0x7C0; }
int DepthBufStride() const { return zbwidth&0x7C0; }

// Pixel Pipeline
bool isModeClear() const { return clearmode & 1; }
bool isFogEnabled() const { return fogEnable & 1; }
Expand All @@ -221,6 +225,7 @@ struct GPUgstate
bool isClearModeDepthWriteEnabled() const { return (clearmode&0x400) != 0; }
bool isClearModeColorMask() const { return (clearmode&0x100) != 0; }
bool isClearModeAlphaMask() const { return (clearmode&0x200) != 0; }
u32 getClearModeColorMask() const { return ((clearmode&0x100) ? 0xFFFFFF : 0) | ((clearmode&0x200) ? 0xFF000000 : 0); } // TODO: Different convention than getColorMask, confusing!

// Blend
int getBlendFuncA() const { return blend & 0xF; }
Expand Down Expand Up @@ -322,10 +327,14 @@ struct GPUgstate
unsigned int getSpecularColorB(int chan) const { return (lcolor[2+chan*3]>>16)&0xFF; }

// UV gen
int getUVGenMode() const { return texmapmode & 3;} // 2 bits
int getUVProjMode() const { return (texmapmode >> 8) & 3;} // 2 bits
GETexMapMode getUVGenMode() const { return static_cast<GETexMapMode>(texmapmode & 3);} // 2 bits
GETexProjMapMode getUVProjMode() const { return static_cast<GETexProjMapMode>((texmapmode >> 8) & 3);} // 2 bits
int getUVLS0() const { return texshade & 0x3; } // 2 bits
int getUVLS1() const { return (texshade >> 8) & 0x3; } // 2 bits

bool isTexCoordClampedS() const { return texwrap & 1; }
bool isTexCoordClampedT() const { return (texwrap >> 8) & 1; }

int getScissorX1() const { return scissor1 & 0x3FF; }
int getScissorY1() const { return (scissor1 >> 10) & 0x3FF; }
int getScissorX2() const { return scissor2 & 0x3FF; }
Expand All @@ -341,6 +350,9 @@ struct GPUgstate
bool isModeThrough() const { return (vertType & GE_VTYPE_THROUGH) != 0; }
int getWeightMask() const { return vertType & GE_VTYPE_WEIGHT_MASK; }
int getNumBoneWeights() const { return 1 + ((vertType & GE_VTYPE_WEIGHTCOUNT_MASK) >> GE_VTYPE_WEIGHTCOUNT_SHIFT); }
bool isSkinningEnabled() const { return ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE); }

GEPatchPrimType getPatchPrimitiveType() const { return static_cast<GEPatchPrimType>(patchprimitive & 3); }

// Real data in the context ends here
};
Expand Down