yuzu/src/video_core/renderer_opengl/gl_compute_pipeline.h

93 lines
2.4 KiB
C++
Raw Normal View History

2021-05-23 09:28:34 +02:00
// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <array>
#include <type_traits>
#include "common/common_types.h"
#include "shader_recompiler/shader_info.h"
#include "video_core/renderer_opengl/gl_buffer_cache.h"
#include "video_core/renderer_opengl/gl_resource_manager.h"
#include "video_core/renderer_opengl/gl_texture_cache.h"
namespace Tegra {
class MemoryManager;
}
namespace Tegra::Engines {
class KeplerCompute;
}
namespace Shader {
struct Info;
}
namespace OpenGL {
class Device;
2021-05-23 09:28:34 +02:00
class ProgramManager;
struct ComputePipelineKey {
2021-05-23 09:28:34 +02:00
u64 unique_hash;
u32 shared_memory_size;
std::array<u32, 3> workgroup_size;
size_t Hash() const noexcept;
bool operator==(const ComputePipelineKey&) const noexcept;
2021-05-23 09:28:34 +02:00
bool operator!=(const ComputePipelineKey& rhs) const noexcept {
2021-05-23 09:28:34 +02:00
return !operator==(rhs);
}
};
static_assert(std::has_unique_object_representations_v<ComputePipelineKey>);
static_assert(std::is_trivially_copyable_v<ComputePipelineKey>);
static_assert(std::is_trivially_constructible_v<ComputePipelineKey>);
2021-05-23 09:28:34 +02:00
class ComputePipeline {
2021-05-23 09:28:34 +02:00
public:
explicit ComputePipeline(const Device& device, TextureCache& texture_cache_,
BufferCache& buffer_cache_, Tegra::MemoryManager& gpu_memory_,
Tegra::Engines::KeplerCompute& kepler_compute_,
ProgramManager& program_manager_, const Shader::Info& info_,
2021-06-22 07:12:11 +02:00
std::string code, std::vector<u32> code_v);
2021-05-23 09:28:34 +02:00
void Configure();
[[nodiscard]] bool WritesGlobalMemory() const noexcept {
return writes_global_memory;
}
2021-05-23 09:28:34 +02:00
private:
TextureCache& texture_cache;
BufferCache& buffer_cache;
Tegra::MemoryManager& gpu_memory;
Tegra::Engines::KeplerCompute& kepler_compute;
ProgramManager& program_manager;
Shader::Info info;
OGLProgram source_program;
OGLAssemblyProgram assembly_program;
VideoCommon::ComputeUniformBufferSizes uniform_buffer_sizes{};
2021-05-23 09:28:34 +02:00
u32 num_texture_buffers{};
u32 num_image_buffers{};
bool use_storage_buffers{};
bool writes_global_memory{};
2021-05-23 09:28:34 +02:00
};
} // namespace OpenGL
namespace std {
template <>
struct hash<OpenGL::ComputePipelineKey> {
size_t operator()(const OpenGL::ComputePipelineKey& k) const noexcept {
2021-05-23 09:28:34 +02:00
return k.Hash();
}
};
} // namespace std