mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-24 20:36:24 -05:00
glsl_decompiler: Implementation
This commit is contained in:
parent
fbc67a0563
commit
0c6fb456e0
3 changed files with 1483 additions and 0 deletions
|
@ -84,6 +84,8 @@ add_library(video_core STATIC
|
||||||
shader/decode/xmad.cpp
|
shader/decode/xmad.cpp
|
||||||
shader/decode/other.cpp
|
shader/decode/other.cpp
|
||||||
shader/decode.cpp
|
shader/decode.cpp
|
||||||
|
shader/glsl_decompiler.cpp
|
||||||
|
shader/glsl_decompiler.h
|
||||||
shader/shader_ir.cpp
|
shader/shader_ir.cpp
|
||||||
shader/shader_ir.h
|
shader/shader_ir.h
|
||||||
surface.cpp
|
surface.cpp
|
||||||
|
|
1393
src/video_core/shader/glsl_decompiler.cpp
Normal file
1393
src/video_core/shader/glsl_decompiler.cpp
Normal file
File diff suppressed because it is too large
Load diff
88
src/video_core/shader/glsl_decompiler.h
Normal file
88
src/video_core/shader/glsl_decompiler.h
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// Copyright 2018 yuzu Emulator Project
|
||||||
|
// Licensed under GPLv2 or any later version
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include "common/common_types.h"
|
||||||
|
#include "video_core/engines/maxwell_3d.h"
|
||||||
|
#include "video_core/shader/shader_ir.h"
|
||||||
|
|
||||||
|
namespace VideoCommon::Shader {
|
||||||
|
class ShaderIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace OpenGL::GLShader {
|
||||||
|
|
||||||
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
||||||
|
|
||||||
|
class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer {
|
||||||
|
public:
|
||||||
|
explicit ConstBufferEntry(const VideoCommon::Shader::ConstBuffer& entry,
|
||||||
|
Maxwell::ShaderStage stage, const std::string& name, u32 index)
|
||||||
|
: VideoCommon::Shader::ConstBuffer{entry}, stage{stage}, name{name}, index{index} {}
|
||||||
|
|
||||||
|
const std::string& GetName() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Maxwell::ShaderStage GetStage() const {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 GetIndex() const {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 GetHash() const {
|
||||||
|
return (static_cast<u32>(stage) << 16) | index;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
Maxwell::ShaderStage stage{};
|
||||||
|
u32 index{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class SamplerEntry : public VideoCommon::Shader::Sampler {
|
||||||
|
public:
|
||||||
|
explicit SamplerEntry(const VideoCommon::Shader::Sampler& entry, Maxwell::ShaderStage stage,
|
||||||
|
const std::string& name)
|
||||||
|
: VideoCommon::Shader::Sampler{entry}, stage{stage}, name{name} {}
|
||||||
|
|
||||||
|
const std::string& GetName() const {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Maxwell::ShaderStage GetStage() const {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 GetHash() const {
|
||||||
|
return (static_cast<u32>(stage) << 16) | GetIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string name;
|
||||||
|
Maxwell::ShaderStage stage{};
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ShaderEntries {
|
||||||
|
std::vector<ConstBufferEntry> const_buffers;
|
||||||
|
std::vector<SamplerEntry> samplers;
|
||||||
|
std::array<bool, Maxwell::NumClipDistances> clip_distances{};
|
||||||
|
std::size_t shader_length{};
|
||||||
|
};
|
||||||
|
|
||||||
|
using ProgramResult = std::pair<std::string, ShaderEntries>;
|
||||||
|
|
||||||
|
std::string GetCommonDeclarations();
|
||||||
|
|
||||||
|
ProgramResult Decompile(const VideoCommon::Shader::ShaderIR& ir, Maxwell::ShaderStage stage,
|
||||||
|
const std::string& suffix);
|
||||||
|
|
||||||
|
} // namespace OpenGL::GLShader
|
Loading…
Reference in a new issue