diff options
Diffstat (limited to 'src/video_core/swrasterizer/rasterizer.h')
| -rw-r--r-- | src/video_core/swrasterizer/rasterizer.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/video_core/swrasterizer/rasterizer.h b/src/video_core/swrasterizer/rasterizer.h new file mode 100644 index 000000000..3a72ac343 --- /dev/null +++ b/src/video_core/swrasterizer/rasterizer.h | |||
| @@ -0,0 +1,48 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "video_core/shader/shader.h" | ||
| 8 | |||
| 9 | namespace Pica { | ||
| 10 | |||
| 11 | namespace Rasterizer { | ||
| 12 | |||
| 13 | struct Vertex : Shader::OutputVertex { | ||
| 14 | Vertex(const OutputVertex& v) : OutputVertex(v) {} | ||
| 15 | |||
| 16 | // Attributes used to store intermediate results | ||
| 17 | // position after perspective divide | ||
| 18 | Math::Vec3<float24> screenpos; | ||
| 19 | |||
| 20 | // Linear interpolation | ||
| 21 | // factor: 0=this, 1=vtx | ||
| 22 | void Lerp(float24 factor, const Vertex& vtx) { | ||
| 23 | pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor); | ||
| 24 | |||
| 25 | // TODO: Should perform perspective correct interpolation here... | ||
| 26 | tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor); | ||
| 27 | tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor); | ||
| 28 | tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor); | ||
| 29 | |||
| 30 | screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor); | ||
| 31 | |||
| 32 | color = color * factor + vtx.color * (float24::FromFloat32(1) - factor); | ||
| 33 | } | ||
| 34 | |||
| 35 | // Linear interpolation | ||
| 36 | // factor: 0=v0, 1=v1 | ||
| 37 | static Vertex Lerp(float24 factor, const Vertex& v0, const Vertex& v1) { | ||
| 38 | Vertex ret = v0; | ||
| 39 | ret.Lerp(factor, v1); | ||
| 40 | return ret; | ||
| 41 | } | ||
| 42 | }; | ||
| 43 | |||
| 44 | void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2); | ||
| 45 | |||
| 46 | } // namespace Rasterizer | ||
| 47 | |||
| 48 | } // namespace Pica | ||