Skip to content

Commit

Permalink
softgpu: Add transform pipeline functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
neobrain committed Aug 16, 2013
1 parent 232a037 commit 1430ca3
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,8 @@ add_library(GPU OBJECT
GPU/Null/NullGpu.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
1 change: 1 addition & 0 deletions GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(SRCS
GLES/VertexShaderGenerator.cpp
Null/NullGpu.cpp
Software/SoftGpu.cpp
Software/TransformUnit.cpp
)

set(SRCS ${SRCS})
Expand Down
2 changes: 2 additions & 0 deletions GPU/GPU.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<ClInclude Include="Math3D.h" />
<ClInclude Include="Null\NullGpu.h" />
<ClInclude Include="Software\SoftGpu.h" />
<ClInclude Include="Software\TransformUnit.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ext\xbrz\xbrz.cpp" />
Expand All @@ -185,6 +186,7 @@
<ClCompile Include="Math3D.cpp" />
<ClCompile Include="Null\NullGpu.cpp" />
<ClCompile Include="Software\SoftGpu.cpp" />
<ClCompile Include="Software\TransformUnit.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.vcxproj">
Expand Down
6 changes: 6 additions & 0 deletions GPU/GPU.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<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 @@ -123,6 +126,9 @@
<ClCompile Include="Software\SoftGpu.cpp">
<Filter>Software</Filter>
</ClCompile>
<ClCompile Include="Software\TransformUnit.cpp">
<Filter>Software</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
Expand Down
49 changes: 49 additions & 0 deletions GPU/Software/TransformUnit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2013- PPSSPP Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.

// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/

// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include "TransformUnit.h"
#include "../GPUState.h"

WorldCoords TransformUnit::ModelToWorld(const ModelCoords& coords)
{
Mat3x3<float> world_matrix(gstate.worldMatrix);
return WorldCoords(world_matrix * coords) + Vec3<float>(gstate.worldMatrix[9], gstate.worldMatrix[10], gstate.worldMatrix[11]);
}

ViewCoords TransformUnit::WorldToView(const WorldCoords& coords)
{
Mat3x3<float> view_matrix(gstate.viewMatrix);
return ViewCoords(view_matrix * coords) + Vec3<float>(gstate.viewMatrix[9], gstate.viewMatrix[10], gstate.viewMatrix[11]);
}

ClipCoords TransformUnit::ViewToClip(const ViewCoords& coords)
{
ClipCoords ret;
return ret;
}

ScreenCoords TransformUnit::ClipToScreen(const ClipCoords& coords)
{
ScreenCoords ret;
return ret;
}

DrawingCoords TransformUnit::ScreenToDrawing(const ScreenCoords& coords)
{
DrawingCoords ret;
return ret;
}
47 changes: 47 additions & 0 deletions GPU/Software/TransformUnit.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) 2013- PPSSPP Project.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.

// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/

// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#pragma once

#include "CommonTypes.h"
#include "../Math3D.h"

typedef u16 fixed16;
typedef u16 u10; // TODO: erm... :/

typedef Vec3<float> ModelCoords;
typedef Vec3<float> WorldCoords;
typedef Vec3<float> ViewCoords;
typedef Vec4<float> ClipCoords; // Range: -w <= x/y/z <= w

struct ScreenCoords
{
fixed16 x;
fixed16 y;
u16 z;
};

typedef Vec2<u10> DrawingCoords;

class TransformUnit
{
WorldCoords ModelToWorld(const ModelCoords& coords);
ViewCoords WorldToView(const WorldCoords& coords);
ClipCoords ViewToClip(const ViewCoords& coords);
ScreenCoords ClipToScreen(const ClipCoords& coords);
DrawingCoords ScreenToDrawing(const ScreenCoords& coords);
};

0 comments on commit 1430ca3

Please sign in to comment.