summaryrefslogtreecommitdiff
path: root/src/video_core/shader_interpreter.h
diff options
context:
space:
mode:
authorGravatar bunnei2015-07-21 19:04:05 -0400
committerGravatar bunnei2015-08-15 17:33:41 -0400
commit642b9b503040f7da02dcb2c52f3cd4cbf6fee4b2 (patch)
tree85643112608a15fafc304d41c4457a50c453bfcd /src/video_core/shader_interpreter.h
parentMerge pull request #1027 from lioncash/debugger (diff)
downloadyuzu-642b9b503040f7da02dcb2c52f3cd4cbf6fee4b2.tar.gz
yuzu-642b9b503040f7da02dcb2c52f3cd4cbf6fee4b2.tar.xz
yuzu-642b9b503040f7da02dcb2c52f3cd4cbf6fee4b2.zip
GPU: Refactor "VertexShader" namespace to "Shader".
- Also renames "vertex_shader.*" to "shader_interpreter.*"
Diffstat (limited to 'src/video_core/shader_interpreter.h')
-rw-r--r--src/video_core/shader_interpreter.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/video_core/shader_interpreter.h b/src/video_core/shader_interpreter.h
new file mode 100644
index 000000000..942a30841
--- /dev/null
+++ b/src/video_core/shader_interpreter.h
@@ -0,0 +1,72 @@
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 <type_traits>
8
9#include "common/vector_math.h"
10
11#include "pica.h"
12
13namespace Pica {
14
15namespace Shader {
16
17struct InputVertex {
18 Math::Vec4<float24> attr[16];
19};
20
21struct OutputVertex {
22 OutputVertex() = default;
23
24 // VS output attributes
25 Math::Vec4<float24> pos;
26 Math::Vec4<float24> dummy; // quaternions (not implemented, yet)
27 Math::Vec4<float24> color;
28 Math::Vec2<float24> tc0;
29 Math::Vec2<float24> tc1;
30 float24 pad[6];
31 Math::Vec2<float24> tc2;
32
33 // Padding for optimal alignment
34 float24 pad2[4];
35
36 // Attributes used to store intermediate results
37
38 // position after perspective divide
39 Math::Vec3<float24> screenpos;
40 float24 pad3;
41
42 // Linear interpolation
43 // factor: 0=this, 1=vtx
44 void Lerp(float24 factor, const OutputVertex& vtx) {
45 pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor);
46
47 // TODO: Should perform perspective correct interpolation here...
48 tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor);
49 tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor);
50 tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor);
51
52 screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor);
53
54 color = color * factor + vtx.color * (float24::FromFloat32(1) - factor);
55 }
56
57 // Linear interpolation
58 // factor: 0=v0, 1=v1
59 static OutputVertex Lerp(float24 factor, const OutputVertex& v0, const OutputVertex& v1) {
60 OutputVertex ret = v0;
61 ret.Lerp(factor, v1);
62 return ret;
63 }
64};
65static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD");
66static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size");
67
68OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup);
69
70} // namespace
71
72} // namespace