2014-07-26 19:17:09 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-07-26 19:17:09 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-06-21 15:02:11 +02:00
|
|
|
#include <type_traits>
|
2014-07-26 19:17:09 +02:00
|
|
|
|
2015-06-21 15:02:11 +02:00
|
|
|
#include "common/vector_math.h"
|
2014-07-26 19:17:09 +02:00
|
|
|
|
2015-07-22 01:09:11 +02:00
|
|
|
#include "video_core/pica.h"
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
namespace Pica {
|
|
|
|
|
2015-07-22 01:04:05 +02:00
|
|
|
namespace Shader {
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
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;
|
2014-12-06 19:10:08 +01:00
|
|
|
Math::Vec2<float24> tc1;
|
|
|
|
float24 pad[6];
|
|
|
|
Math::Vec2<float24> tc2;
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
// Padding for optimal alignment
|
2014-12-06 19:10:08 +01:00
|
|
|
float24 pad2[4];
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
// Attributes used to store intermediate results
|
|
|
|
|
|
|
|
// position after perspective divide
|
|
|
|
Math::Vec3<float24> screenpos;
|
2014-12-06 19:10:08 +01:00
|
|
|
float24 pad3;
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
// 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);
|
2014-12-06 19:10:08 +01:00
|
|
|
tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor);
|
|
|
|
tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor);
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
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");
|
2014-08-12 20:04:28 +02:00
|
|
|
static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size");
|
2014-07-26 19:17:09 +02:00
|
|
|
|
2015-03-22 00:31:40 +01:00
|
|
|
OutputVertex RunShader(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup);
|
2014-07-26 19:17:09 +02:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
} // namespace
|