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 <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "video_core/engines/maxwell_3d.h"
|
|
|
|
#include "video_core/shader/shader_ir.h"
|
|
|
|
|
2019-04-10 23:03:52 +02:00
|
|
|
namespace OpenGL {
|
|
|
|
class Device;
|
|
|
|
}
|
|
|
|
|
2018-12-21 01:45:49 +01:00
|
|
|
namespace VideoCommon::Shader {
|
|
|
|
class ShaderIR;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace OpenGL::GLShader {
|
|
|
|
|
2019-01-15 06:42:25 +01:00
|
|
|
struct ShaderEntries;
|
|
|
|
|
2018-12-21 01:45:49 +01:00
|
|
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
2019-01-15 06:42:25 +01:00
|
|
|
using ProgramResult = std::pair<std::string, ShaderEntries>;
|
|
|
|
using SamplerEntry = VideoCommon::Shader::Sampler;
|
2018-12-21 01:45:49 +01:00
|
|
|
|
|
|
|
class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer {
|
|
|
|
public:
|
2019-01-15 05:07:57 +01:00
|
|
|
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{};
|
|
|
|
};
|
|
|
|
|
2018-12-29 06:44:54 +01:00
|
|
|
class GlobalMemoryEntry {
|
|
|
|
public:
|
2019-02-07 04:05:41 +01:00
|
|
|
explicit GlobalMemoryEntry(u32 cbuf_index, u32 cbuf_offset, bool is_read, bool is_written)
|
|
|
|
: cbuf_index{cbuf_index}, cbuf_offset{cbuf_offset}, is_read{is_read}, is_written{
|
|
|
|
is_written} {}
|
2018-12-29 06:44:54 +01:00
|
|
|
|
|
|
|
u32 GetCbufIndex() const {
|
|
|
|
return cbuf_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 GetCbufOffset() const {
|
|
|
|
return cbuf_offset;
|
|
|
|
}
|
|
|
|
|
2019-02-07 04:05:41 +01:00
|
|
|
bool IsRead() const {
|
|
|
|
return is_read;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsWritten() const {
|
|
|
|
return is_written;
|
|
|
|
}
|
|
|
|
|
2018-12-29 06:44:54 +01:00
|
|
|
private:
|
|
|
|
u32 cbuf_index{};
|
|
|
|
u32 cbuf_offset{};
|
2019-02-07 04:05:41 +01:00
|
|
|
bool is_read{};
|
|
|
|
bool is_written{};
|
2018-12-29 06:44:54 +01:00
|
|
|
};
|
|
|
|
|
2018-12-21 01:45:49 +01:00
|
|
|
struct ShaderEntries {
|
|
|
|
std::vector<ConstBufferEntry> const_buffers;
|
|
|
|
std::vector<SamplerEntry> samplers;
|
2019-03-26 22:56:16 +01:00
|
|
|
std::vector<SamplerEntry> bindless_samplers;
|
2018-12-29 06:44:54 +01:00
|
|
|
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{};
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string GetCommonDeclarations();
|
|
|
|
|
2019-04-10 23:03:52 +02:00
|
|
|
ProgramResult Decompile(const Device& device, const VideoCommon::Shader::ShaderIR& ir,
|
|
|
|
Maxwell::ShaderStage stage, const std::string& suffix);
|
2018-12-21 01:45:49 +01:00
|
|
|
|
2019-03-26 22:56:16 +01:00
|
|
|
} // namespace OpenGL::GLShader
|