summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorFernandoS27 <fsahmkow27@gmail.com>2018-10-20 01:47:06 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2018-10-24 23:50:43 +0200
commitabefe293986f42b8912a561b7978e952eca7bfee (patch)
treeb79c31cb3d02f6aa7cf39f3b3ed2b147e045d355 /src/video_core/renderer_opengl
parentMerge pull request #1565 from lioncash/audio (diff)
downloadyuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar.gz
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar.bz2
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar.lz
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar.xz
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.tar.zst
yuzu-abefe293986f42b8912a561b7978e952eca7bfee.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 81ffb24e4..c1a86755a 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -279,6 +279,7 @@ public:
const Tegra::Shader::Header& header)
: shader{shader}, declarations{declarations}, stage{stage}, suffix{suffix}, header{header},
fixed_pipeline_output_attributes_used{} {
+ local_memory_size = 0;
BuildRegisterList();
BuildInputList();
}
@@ -436,6 +437,24 @@ public:
shader.AddLine(dest + " = " + src + ';');
}
+ std::string GetLocalMemoryAsFloat(const std::string index) {
+ return "lmem[" + index + "]";
+ }
+
+ std::string GetLocalMemoryAsInteger(const std::string index, bool is_signed = false) {
+ const std::string func{is_signed ? "floatToIntBits" : "floatBitsToUint"};
+ return func + "(lmem[" + index + "])";
+ }
+
+ void SetLocalMemoryAsFloat(const std::string index, const std::string value) {
+ shader.AddLine("lmem[" + index + "] = " + value);
+ }
+
+ void SetLocalMemoryAsInteger(const std::string index, const std::string value, bool is_signed = false) {
+ const std::string func{is_signed ? "intBitsToFloat" : "uintBitsToFloat"};
+ shader.AddLine("lmem[" + index + "] = " + func + '(' + value + ')');
+ }
+
std::string GetControlCode(const Tegra::Shader::ControlCode cc) const {
switch (cc) {
case Tegra::Shader::ControlCode::NEU:
@@ -533,6 +552,7 @@ public:
void GenerateDeclarations(const std::string& suffix) {
GenerateVertex();
GenerateRegisters(suffix);
+ GenerateLocalMemory();
GenerateInternalFlags();
GenerateInputAttrs();
GenerateOutputAttrs();
@@ -578,6 +598,10 @@ public:
return entry.GetName();
}
+ void SetLocalMemory(u64 lmem) {
+ local_memory_size = lmem;
+ }
+
private:
/// Generates declarations for registers.
void GenerateRegisters(const std::string& suffix) {
@@ -588,6 +612,14 @@ private:
declarations.AddNewLine();
}
+ /// Generates declarations for local memory.
+ void GenerateLocalMemory() {
+ if (local_memory_size > 0) {
+ declarations.AddLine("float lmem[" + std::to_string((local_memory_size - 1 + 4) / 4) + "];");
+ declarations.AddNewLine();
+ }
+ }
+
/// Generates declarations for internal flags.
void GenerateInternalFlags() {
for (u32 ii = 0; ii < static_cast<u64>(InternalFlag::Amount); ii++) {
@@ -895,6 +927,7 @@ private:
const std::string& suffix;
const Tegra::Shader::Header& header;
std::unordered_set<Attribute::Index> fixed_pipeline_output_attributes_used;
+ u64 local_memory_size;
};
class GLSLGenerator {
@@ -904,6 +937,9 @@ public:
: subroutines(subroutines), program_code(program_code), main_offset(main_offset),
stage(stage), suffix(suffix) {
std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header));
+ local_memory_size = (header.common2.shader_local_memory_high_size << 24) |
+ header.common1.shader_local_memory_low_size;
+ regs.SetLocalMemory(local_memory_size);
Generate(suffix);
}
@@ -3575,6 +3611,7 @@ private:
const u32 main_offset;
Maxwell3D::Regs::ShaderStage stage;
const std::string& suffix;
+ u64 local_memory_size;
ShaderWriter shader;
ShaderWriter declarations;