diff options
author | bunnei <bunneidev@gmail.com> | 2015-07-22 01:09:11 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-08-15 23:33:42 +0200 |
commit | 18527b9e21a95445fbee45fea29f674fbdd2aae1 (patch) | |
tree | bf037c3877e288b561cd7f075c24d3ce8e449a85 /src/video_core/shader/shader_interpreter.h | |
parent | GPU: Refactor "VertexShader" namespace to "Shader". (diff) | |
download | yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar.gz yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar.bz2 yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar.lz yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar.xz yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.tar.zst yuzu-18527b9e21a95445fbee45fea29f674fbdd2aae1.zip |
Diffstat (limited to 'src/video_core/shader/shader_interpreter.h')
-rw-r--r-- | src/video_core/shader/shader_interpreter.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h new file mode 100644 index 000000000..f2900bfc6 --- /dev/null +++ b/src/video_core/shader/shader_interpreter.h @@ -0,0 +1,72 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <type_traits> + +#include "common/vector_math.h" + +#include "video_core/pica.h" + +namespace Pica { + +namespace Shader { + +struct InputVertex { + Math::Vec4<float24> attr[16]; +}; + +struct OutputVertex { + OutputVertex() = default; + + // VS output attributes + Math::Vec4<float24> pos; + Math::Vec4<float24> dummy; // quaternions (not implemented, yet) + Math::Vec4<float24> color; + Math::Vec2<float24> tc0; + Math::Vec2<float24> tc1; + float24 pad[6]; + Math::Vec2<float24> tc2; + + // Padding for optimal alignment + float24 pad2[4]; + + // Attributes used to store intermediate results + + // position after perspective divide + Math::Vec3<float24> screenpos; + float24 pad3; + + // Linear interpolation + // factor: 0=this, 1=vtx + void Lerp(float24 factor, const OutputVertex& vtx) { + pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor); + + // TODO: Should perform perspective correct interpolation here... + tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor); + tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor); + tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor); + + screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor); + + color = color * factor + vtx.color * (float24::FromFloat32(1) - factor); + } + + // Linear interpolation + // factor: 0=v0, 1=v1 + static OutputVertex Lerp(float24 factor, const OutputVertex& v0, const OutputVertex& v1) { + OutputVertex ret = v0; + ret.Lerp(factor, v1); + return ret; + } +}; +static_assert(std::is_pod<OutputVertex>::value, "Structure is not POD"); +static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size"); + +OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup); + +} // namespace + +} // namespace |