Blender V5.0
vk_shader_module.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "vk_shader_module.hh"
10#include "vk_backend.hh"
11#include "vk_shader.hh"
12
13#include <iomanip>
14#include <sstream>
15
16namespace blender::gpu {
18{
20 if (vk_shader_module != VK_NULL_HANDLE) {
22 vk_shader_module = VK_NULL_HANDLE;
23 }
24}
25
27{
28 BLI_assert(vk_shader_module == VK_NULL_HANDLE);
29 if (compilation_result.GetCompilationStatus() != shaderc_compilation_status_success &&
30 spirv_binary.is_empty())
31 {
32 return;
33 }
34
35 VkShaderModuleCreateInfo create_info = {};
36 create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
37 if (!spirv_binary.is_empty()) {
38 create_info.codeSize = spirv_binary.size() * sizeof(uint32_t);
39 create_info.pCode = spirv_binary.data();
40 }
41 else {
42 create_info.codeSize = (compilation_result.end() - compilation_result.begin()) *
43 sizeof(uint32_t);
44 create_info.pCode = compilation_result.begin();
45 }
46
47 const VKDevice &device = VKBackend::get().device;
48 vkCreateShaderModule(device.vk_handle(), &create_info, nullptr, &vk_shader_module);
50}
51
53{
57 std::stringstream ss;
58 ss << std::setfill('0') << std::setw(sizeof(uint64_t) * 2) << std::hex << hash;
59 sources_hash = ss.str();
60 BLI_assert(!sources_hash.empty());
61}
62
63} // namespace blender::gpu
#define BLI_assert(a)
Definition BLI_assert.h:46
unsigned long long int uint64_t
static VKBackend & get()
Definition vk_backend.hh:91
VkDevice vk_handle() const
Definition vk_device.hh:311
static VKDiscardPool & discard_pool_get()
void discard_shader_module(VkShaderModule vk_shader_module)
shaderc::SpvCompilationResult compilation_result
void finalize(StringRefNull name)
void object_label(GLenum type, GLuint object, const char *name)
Definition gl_debug.cc:329
#define hash
Definition noise_c.cc:154
const char * name