renderer_vulkan: Drop vk_pipeline.h/cpp

This commit is contained in:
GPUCode
2022-05-05 17:00:50 +03:00
parent ab9b84f721
commit 5858bd3116
3 changed files with 0 additions and 111 deletions

View File

@@ -81,8 +81,6 @@ add_library(video_core STATIC
renderer_vulkan/vk_rasterizer_cache.h
renderer_vulkan/vk_rasterizer.cpp
renderer_vulkan/vk_rasterizer.h
renderer_vulkan/vk_pipeline.cpp
renderer_vulkan/vk_pipeline.h
renderer_vulkan/vk_shader_state.h
renderer_vulkan/vk_state.cpp
renderer_vulkan/vk_state.h

View File

@@ -1,61 +0,0 @@
// Copyright 2022 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/assert.h"
#include "common/logging/log.h"
#include "common/common_types.h"
#include "video_core/renderer_vulkan/vk_pipeline.h"
#include "video_core/renderer_vulkan/vk_instance.h"
#include <shaderc/shaderc.hpp>
namespace Vulkan {
shaderc::Compiler compiler;
void VKPipeline::Info::AddShaderModule(const vk::ShaderModule& source, vk::ShaderStageFlagBits stage)
{
shaderc_shader_kind shader_stage;
std::string name;
switch (stage)
{
case vk::ShaderStageFlagBits::eVertex:
shader_stage = shaderc_glsl_vertex_shader;
name = "Vertex shader";
break;
case vk::ShaderStageFlagBits::eCompute:
shader_stage = shaderc_glsl_compute_shader;
name = "Compute shader";
break;
case vk::ShaderStageFlagBits::eFragment:
shader_stage = shaderc_glsl_fragment_shader;
name = "Fragment shader";
break;
default:
LOG_CRITICAL(Render_Vulkan, "Unknown vulkan shader stage {}", stage);
UNREACHABLE();
}
shaderc::CompileOptions options;
options.SetOptimizationLevel(shaderc_optimization_level_performance);
options.SetAutoBindUniforms(true);
options.SetAutoMapLocations(true);
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_2);
auto result = compiler.CompileGlslToSpv(source.c_str(), shader_stage, name.c_str(), options);
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
LOG_CRITICAL(Render_Vulkan, "Failed to compile GLSL shader with error: {}", result.GetErrorMessage());
UNREACHABLE();
}
auto shader_code = std::vector<uint32_t>{ result.cbegin(), result.cend() };
vk::ShaderModuleCreateInfo module_info({}, shader_code);
auto module = g_vk_instace->GetDevice().createShaderModuleUnique(module_info);
shader_stages.emplace_back(vk::PipelineShaderStageCreateFlags(), stage, module.get(), "main");
return std::move(module);
}
} // namespace Vulkan

View File

@@ -1,48 +0,0 @@
// Copyright 2022 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <utility>
#include <variant>
#include "video_core/renderer_vulkan/vk_texture.h"
namespace Vulkan {
using Resource = std::variant<VKBuffer, VKTexture>;
/// Vulkan pipeline objects represent a collection of shader modules
class VKPipeline final : private NonCopyable {
public:
/// Includes all required information to build a Vulkan pipeline object
class Info : private NonCopyable {
Info() = default;
~Info() = default;
/// Assign a shader module to a specific stage
void AddShaderModule(const vk::ShaderModule& module, vk::ShaderStageFlagBits stage);
/// Add a texture or a buffer to the target descriptor set
void AddResource(const Resource& resource, vk::DescriptorType type, vk::ShaderStageFlags stages, int set = 0);
private:
using ResourceInfo = std::pair<std::reference_wrapper<Resource>, vk::DescriptorSetLayoutBinding>;
std::unordered_map<int, std::vector<ResourceInfo>> descriptor_sets;
std::vector<vk::PipelineShaderStageCreateInfo> shader_stages;
};
VKPipeline() = default;
~VKPipeline() = default;
/// Create a new Vulkan pipeline object
void Create(const Info& info);
void Create(vk::PipelineLayoutCreateInfo layout_info);
private:
vk::UniquePipeline pipeline;
vk::UniquePipelineLayout pipeline_layout;
};
} // namespace OpenGL