2021-03-19 23:28:31 +01:00
|
|
|
// Copyright 2021 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
2021-04-01 06:36:22 +02:00
|
|
|
#include <atomic>
|
2021-04-04 02:41:49 +02:00
|
|
|
#include <condition_variable>
|
|
|
|
#include <mutex>
|
2021-03-19 23:28:31 +01:00
|
|
|
|
2021-04-01 06:36:22 +02:00
|
|
|
#include "common/thread_worker.h"
|
2021-03-19 23:28:31 +01:00
|
|
|
#include "shader_recompiler/shader_info.h"
|
|
|
|
#include "video_core/engines/maxwell_3d.h"
|
|
|
|
#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
|
2021-04-01 06:36:22 +02:00
|
|
|
#include "video_core/renderer_vulkan/vk_buffer_cache.h"
|
2021-03-19 23:28:31 +01:00
|
|
|
#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
|
|
|
|
#include "video_core/renderer_vulkan/vk_texture_cache.h"
|
|
|
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
|
|
|
|
|
|
|
namespace Vulkan {
|
|
|
|
|
|
|
|
class Device;
|
|
|
|
class RenderPassCache;
|
|
|
|
class VKScheduler;
|
|
|
|
class VKUpdateDescriptorQueue;
|
|
|
|
|
|
|
|
class GraphicsPipeline {
|
|
|
|
static constexpr size_t NUM_STAGES = Tegra::Engines::Maxwell3D::Regs::MaxShaderStage;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit GraphicsPipeline(Tegra::Engines::Maxwell3D& maxwell3d,
|
|
|
|
Tegra::MemoryManager& gpu_memory, VKScheduler& scheduler,
|
2021-04-01 06:36:22 +02:00
|
|
|
BufferCache& buffer_cache, TextureCache& texture_cache,
|
|
|
|
const Device& device, VKDescriptorPool& descriptor_pool,
|
2021-03-19 23:28:31 +01:00
|
|
|
VKUpdateDescriptorQueue& update_descriptor_queue,
|
2021-04-01 06:36:22 +02:00
|
|
|
Common::ThreadWorker* worker_thread,
|
2021-03-19 23:28:31 +01:00
|
|
|
RenderPassCache& render_pass_cache, const FixedPipelineState& state,
|
|
|
|
std::array<vk::ShaderModule, NUM_STAGES> stages,
|
|
|
|
const std::array<const Shader::Info*, NUM_STAGES>& infos);
|
|
|
|
|
|
|
|
void Configure(bool is_indexed);
|
|
|
|
|
2021-04-01 06:36:22 +02:00
|
|
|
GraphicsPipeline& operator=(GraphicsPipeline&&) noexcept = delete;
|
|
|
|
GraphicsPipeline(GraphicsPipeline&&) noexcept = delete;
|
2021-03-19 23:28:31 +01:00
|
|
|
|
|
|
|
GraphicsPipeline& operator=(const GraphicsPipeline&) = delete;
|
|
|
|
GraphicsPipeline(const GraphicsPipeline&) = delete;
|
|
|
|
|
|
|
|
private:
|
2021-04-01 06:36:22 +02:00
|
|
|
void MakePipeline(const Device& device, VkRenderPass render_pass);
|
2021-03-19 23:28:31 +01:00
|
|
|
|
2021-04-01 06:36:22 +02:00
|
|
|
Tegra::Engines::Maxwell3D& maxwell3d;
|
|
|
|
Tegra::MemoryManager& gpu_memory;
|
|
|
|
TextureCache& texture_cache;
|
|
|
|
BufferCache& buffer_cache;
|
|
|
|
VKScheduler& scheduler;
|
|
|
|
VKUpdateDescriptorQueue& update_descriptor_queue;
|
|
|
|
const FixedPipelineState state;
|
2021-03-19 23:28:31 +01:00
|
|
|
|
|
|
|
std::array<vk::ShaderModule, NUM_STAGES> spv_modules;
|
|
|
|
std::array<Shader::Info, NUM_STAGES> stage_infos;
|
|
|
|
vk::DescriptorSetLayout descriptor_set_layout;
|
|
|
|
DescriptorAllocator descriptor_allocator;
|
|
|
|
vk::PipelineLayout pipeline_layout;
|
|
|
|
vk::DescriptorUpdateTemplateKHR descriptor_update_template;
|
|
|
|
vk::Pipeline pipeline;
|
2021-04-04 02:41:49 +02:00
|
|
|
|
|
|
|
std::condition_variable build_condvar;
|
|
|
|
std::mutex build_mutex;
|
|
|
|
std::atomic_bool is_built{false};
|
2021-03-19 23:28:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Vulkan
|