mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
Merge pull request #1554 from FernandoS27/pointsize
Implement PointSize Output Attribute.
This commit is contained in:
commit
69b35d7615
3 changed files with 28 additions and 5 deletions
|
@ -79,6 +79,7 @@ union Attribute {
|
||||||
constexpr explicit Attribute(u64 value) : value(value) {}
|
constexpr explicit Attribute(u64 value) : value(value) {}
|
||||||
|
|
||||||
enum class Index : u64 {
|
enum class Index : u64 {
|
||||||
|
PointSize = 6,
|
||||||
Position = 7,
|
Position = 7,
|
||||||
Attribute_0 = 8,
|
Attribute_0 = 8,
|
||||||
Attribute_31 = 39,
|
Attribute_31 = 39,
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
@ -276,7 +277,8 @@ public:
|
||||||
GLSLRegisterManager(ShaderWriter& shader, ShaderWriter& declarations,
|
GLSLRegisterManager(ShaderWriter& shader, ShaderWriter& declarations,
|
||||||
const Maxwell3D::Regs::ShaderStage& stage, const std::string& suffix,
|
const Maxwell3D::Regs::ShaderStage& stage, const std::string& suffix,
|
||||||
const Tegra::Shader::Header& header)
|
const Tegra::Shader::Header& header)
|
||||||
: shader{shader}, declarations{declarations}, stage{stage}, suffix{suffix}, header{header} {
|
: shader{shader}, declarations{declarations}, stage{stage}, suffix{suffix}, header{header},
|
||||||
|
fixed_pipeline_output_attributes_used{} {
|
||||||
BuildRegisterList();
|
BuildRegisterList();
|
||||||
BuildInputList();
|
BuildInputList();
|
||||||
}
|
}
|
||||||
|
@ -479,11 +481,16 @@ public:
|
||||||
shader.AddLine("amem[" + buf_index + "][" +
|
shader.AddLine("amem[" + buf_index + "][" +
|
||||||
std::to_string(static_cast<u32>(attribute)) + ']' +
|
std::to_string(static_cast<u32>(attribute)) + ']' +
|
||||||
GetSwizzle(elem) + " = " + src + ';');
|
GetSwizzle(elem) + " = " + src + ';');
|
||||||
|
} else {
|
||||||
|
if (attribute == Attribute::Index::PointSize) {
|
||||||
|
fixed_pipeline_output_attributes_used.insert(attribute);
|
||||||
|
shader.AddLine(dest + " = " + src + ';');
|
||||||
} else {
|
} else {
|
||||||
shader.AddLine(dest + GetSwizzle(elem) + " = " + src + ';');
|
shader.AddLine(dest + GetSwizzle(elem) + " = " + src + ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Generates code representing a uniform (C buffer) register, interpreted as the input type.
|
/// Generates code representing a uniform (C buffer) register, interpreted as the input type.
|
||||||
std::string GetUniform(u64 index, u64 offset, GLSLRegister::Type type,
|
std::string GetUniform(u64 index, u64 offset, GLSLRegister::Type type,
|
||||||
|
@ -524,6 +531,7 @@ public:
|
||||||
|
|
||||||
/// Add declarations.
|
/// Add declarations.
|
||||||
void GenerateDeclarations(const std::string& suffix) {
|
void GenerateDeclarations(const std::string& suffix) {
|
||||||
|
GenerateVertex();
|
||||||
GenerateRegisters(suffix);
|
GenerateRegisters(suffix);
|
||||||
GenerateInternalFlags();
|
GenerateInternalFlags();
|
||||||
GenerateInputAttrs();
|
GenerateInputAttrs();
|
||||||
|
@ -683,6 +691,20 @@ private:
|
||||||
declarations.AddNewLine();
|
declarations.AddNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenerateVertex() {
|
||||||
|
if (stage != Maxwell3D::Regs::ShaderStage::Vertex)
|
||||||
|
return;
|
||||||
|
declarations.AddLine("out gl_PerVertex {");
|
||||||
|
++declarations.scope;
|
||||||
|
declarations.AddLine("vec4 gl_Position;");
|
||||||
|
for (auto& o : fixed_pipeline_output_attributes_used) {
|
||||||
|
if (o == Attribute::Index::PointSize)
|
||||||
|
declarations.AddLine("float gl_PointSize;");
|
||||||
|
}
|
||||||
|
--declarations.scope;
|
||||||
|
declarations.AddLine("};");
|
||||||
|
}
|
||||||
|
|
||||||
/// Generates code representing a temporary (GPR) register.
|
/// Generates code representing a temporary (GPR) register.
|
||||||
std::string GetRegister(const Register& reg, unsigned elem) {
|
std::string GetRegister(const Register& reg, unsigned elem) {
|
||||||
if (reg == Register::ZeroIndex) {
|
if (reg == Register::ZeroIndex) {
|
||||||
|
@ -836,6 +858,8 @@ private:
|
||||||
/// Generates code representing the declaration name of an output attribute register.
|
/// Generates code representing the declaration name of an output attribute register.
|
||||||
std::string GetOutputAttribute(Attribute::Index attribute) {
|
std::string GetOutputAttribute(Attribute::Index attribute) {
|
||||||
switch (attribute) {
|
switch (attribute) {
|
||||||
|
case Attribute::Index::PointSize:
|
||||||
|
return "gl_PointSize";
|
||||||
case Attribute::Index::Position:
|
case Attribute::Index::Position:
|
||||||
return "position";
|
return "position";
|
||||||
default:
|
default:
|
||||||
|
@ -870,6 +894,7 @@ private:
|
||||||
const Maxwell3D::Regs::ShaderStage& stage;
|
const Maxwell3D::Regs::ShaderStage& stage;
|
||||||
const std::string& suffix;
|
const std::string& suffix;
|
||||||
const Tegra::Shader::Header& header;
|
const Tegra::Shader::Header& header;
|
||||||
|
std::unordered_set<Attribute::Index> fixed_pipeline_output_attributes_used;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GLSLGenerator {
|
class GLSLGenerator {
|
||||||
|
|
|
@ -19,9 +19,6 @@ ProgramResult GenerateVertexShader(const ShaderSetup& setup) {
|
||||||
out += Decompiler::GetCommonDeclarations();
|
out += Decompiler::GetCommonDeclarations();
|
||||||
|
|
||||||
out += R"(
|
out += R"(
|
||||||
out gl_PerVertex {
|
|
||||||
vec4 gl_Position;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (location = 0) out vec4 position;
|
layout (location = 0) out vec4 position;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue