Part of #136993. Share as much of the ShaderCompiler implementations as possible. Remove the ShaderCompiler/ShaderCompilerGeneric split and make most of its functions non virtual. Move the `get_compiler` function from `Context` to `GPUBackend` and creation/deletion to `GPUBackend::init/delete_resources`. Add a `batch_cancel` function to `ShaderCompiler` (needed for the GPUPass refactor). As a nice extra, the multithreaded OpenGL compilation has become faster too. The barbershop materials + EEVEE static shaders have gone from 27s to 22s. I have not observed any performance difference on Vulkan or Metal. Pull Request: https://projects.blender.org/blender/blender/pulls/136676
40 lines
794 B
C++
40 lines
794 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "gpu_shader_private.hh"
|
|
|
|
#include "BLI_map.hh"
|
|
#include "BLI_task.h"
|
|
#include "BLI_vector.hh"
|
|
|
|
#include "shaderc/shaderc.hpp"
|
|
|
|
#include <mutex>
|
|
|
|
namespace blender::gpu {
|
|
class VKShader;
|
|
class VKShaderModule;
|
|
|
|
/**
|
|
* Vulkan shader compiler.
|
|
*
|
|
* Is used for both single threaded compilation by calling `VKShaderCompiler::compile_module` or
|
|
* batch based compilation.
|
|
*/
|
|
class VKShaderCompiler {
|
|
public:
|
|
static bool compile_module(VKShader &shader,
|
|
shaderc_shader_kind stage,
|
|
VKShaderModule &shader_module);
|
|
|
|
static void cache_dir_clear_old();
|
|
};
|
|
} // namespace blender::gpu
|