suyu/src/video_core/renderer_opengl/gl_shader_decompiler.h

72 lines
1.7 KiB
C++
Raw Normal View History

2018-12-21 01:45:49 +01:00
// Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <set>
2018-12-21 01:45:49 +01:00
#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(u32 max_offset, bool is_indirect, u32 index)
: VideoCommon::Shader::ConstBuffer{max_offset, is_indirect}, index{index} {}
2018-12-21 01:45:49 +01:00
u32 GetIndex() const {
return index;
}
private:
u32 index{};
};
using SamplerEntry = VideoCommon::Shader::Sampler;
class GlobalMemoryEntry {
public:
explicit GlobalMemoryEntry(u32 cbuf_index, u32 cbuf_offset)
: cbuf_index{cbuf_index}, cbuf_offset{cbuf_offset} {}
u32 GetCbufIndex() const {
return cbuf_index;
}
u32 GetCbufOffset() const {
return cbuf_offset;
}
private:
u32 cbuf_index{};
u32 cbuf_offset{};
};
2018-12-21 01:45:49 +01:00
struct ShaderEntries {
std::vector<ConstBufferEntry> const_buffers;
std::vector<SamplerEntry> samplers;
std::vector<GlobalMemoryEntry> global_memory_entries;
2018-12-21 01:45:49 +01:00
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