2018-08-23 23:30:27 +02:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-01-06 07:58:43 +01:00
|
|
|
#include <array>
|
2019-04-04 17:58:06 +02:00
|
|
|
#include <atomic>
|
2019-04-29 02:08:31 +02:00
|
|
|
#include <bitset>
|
2018-08-23 23:30:27 +02:00
|
|
|
#include <memory>
|
2019-09-25 04:34:18 +02:00
|
|
|
#include <string>
|
2019-01-05 05:00:06 +01:00
|
|
|
#include <tuple>
|
2019-02-03 01:14:36 +01:00
|
|
|
#include <unordered_map>
|
2019-09-25 04:34:18 +02:00
|
|
|
#include <unordered_set>
|
2019-04-04 17:58:06 +02:00
|
|
|
#include <vector>
|
2019-01-05 05:00:06 +01:00
|
|
|
|
|
|
|
#include <glad/glad.h>
|
2018-08-23 23:30:27 +02:00
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2019-11-18 22:35:21 +01:00
|
|
|
#include "video_core/engines/shader_type.h"
|
2018-08-23 23:30:27 +02:00
|
|
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
2020-05-23 01:55:38 +02:00
|
|
|
#include "video_core/shader_cache.h"
|
2018-08-23 23:30:27 +02:00
|
|
|
|
2020-06-12 02:24:45 +02:00
|
|
|
namespace Tegra {
|
|
|
|
class MemoryManager;
|
2019-04-06 22:59:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace Core::Frontend {
|
|
|
|
class EmuWindow;
|
|
|
|
}
|
2019-01-15 20:28:42 +01:00
|
|
|
|
2018-08-23 23:30:27 +02:00
|
|
|
namespace OpenGL {
|
|
|
|
|
2019-04-10 23:03:52 +02:00
|
|
|
class Device;
|
2018-11-08 12:08:00 +01:00
|
|
|
class RasterizerOpenGL;
|
|
|
|
|
2018-08-23 23:30:27 +02:00
|
|
|
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
|
2020-02-26 20:13:47 +01:00
|
|
|
|
2021-04-26 08:53:26 +02:00
|
|
|
struct GraphicsProgramKey {
|
|
|
|
struct TransformFeedbackState {
|
|
|
|
struct Layout {
|
|
|
|
u32 stream;
|
|
|
|
u32 varying_count;
|
|
|
|
u32 stride;
|
|
|
|
};
|
|
|
|
std::array<Layout, Maxwell::NumTransformFeedbackBuffers> layouts;
|
|
|
|
std::array<std::array<u8, 128>, Maxwell::NumTransformFeedbackBuffers> varyings;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::array<u64, 6> unique_hashes;
|
|
|
|
std::array<u8, Maxwell::NumRenderTargets> color_formats;
|
|
|
|
union {
|
|
|
|
u32 raw;
|
|
|
|
BitField<0, 1, u32> xfb_enabled;
|
|
|
|
BitField<1, 1, u32> early_z;
|
|
|
|
BitField<2, 4, Maxwell::PrimitiveTopology> gs_input_topology;
|
|
|
|
BitField<6, 2, u32> tessellation_primitive;
|
|
|
|
BitField<8, 2, u32> tessellation_spacing;
|
|
|
|
BitField<10, 1, u32> tessellation_clockwise;
|
|
|
|
};
|
|
|
|
u32 padding;
|
|
|
|
TransformFeedbackState xfb_state;
|
|
|
|
|
|
|
|
[[nodiscard]] size_t Size() const noexcept {
|
|
|
|
if (xfb_enabled != 0) {
|
|
|
|
return sizeof(GraphicsProgramKey);
|
|
|
|
} else {
|
|
|
|
return offsetof(GraphicsProgramKey, padding);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static_assert(std::has_unique_object_representations_v<GraphicsProgramKey>);
|
|
|
|
static_assert(std::is_trivially_copyable_v<GraphicsProgramKey>);
|
|
|
|
static_assert(std::is_trivially_constructible_v<GraphicsProgramKey>);
|
|
|
|
|
|
|
|
class GraphicsProgram {
|
2018-08-23 23:30:27 +02:00
|
|
|
public:
|
2021-04-26 08:53:26 +02:00
|
|
|
private:
|
2018-08-23 23:30:27 +02:00
|
|
|
};
|
|
|
|
|
2021-04-26 08:53:26 +02:00
|
|
|
class ShaderCache : public VideoCommon::ShaderCache {
|
2018-08-23 23:30:27 +02:00
|
|
|
public:
|
2021-04-26 08:53:26 +02:00
|
|
|
explicit ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindow& emu_window_,
|
|
|
|
Tegra::GPU& gpu_, Tegra::Engines::Maxwell3D& maxwell3d_,
|
|
|
|
Tegra::Engines::KeplerCompute& kepler_compute_,
|
|
|
|
Tegra::MemoryManager& gpu_memory_, const Device& device_);
|
|
|
|
~ShaderCache();
|
2018-11-08 12:08:00 +01:00
|
|
|
|
2019-01-06 07:58:43 +01:00
|
|
|
private:
|
2019-04-06 22:59:56 +02:00
|
|
|
Core::Frontend::EmuWindow& emu_window;
|
2020-06-12 02:24:45 +02:00
|
|
|
Tegra::GPU& gpu;
|
2019-04-10 23:03:52 +02:00
|
|
|
const Device& device;
|
2018-08-23 23:30:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace OpenGL
|