Kelsidavis-WoWee/include/rendering/vk_shader.hpp
Kelsi e805eae33c refactor: add [[nodiscard]] to shader/asset load functions, suppress warnings
Add [[nodiscard]] to VkShaderModule::loadFromFile, Shader::loadFromFile/
loadFromSource, AssetManifest::load, DbcLoader::load — all return bool
indicating success/failure that callers should check.

Suppress with (void) at 17 call sites where validity is checked via
isValid() after loading rather than the return value (m2_renderer
recreatePipelines, swim_effects recreatePipelines).
2026-03-27 15:17:19 -07:00

45 lines
1.3 KiB
C++

#pragma once
#include <vulkan/vulkan.h>
#include <string>
#include <vector>
namespace wowee {
namespace rendering {
class VkShaderModule {
public:
VkShaderModule() = default;
~VkShaderModule();
VkShaderModule(const VkShaderModule&) = delete;
VkShaderModule& operator=(const VkShaderModule&) = delete;
VkShaderModule(VkShaderModule&& other) noexcept;
VkShaderModule& operator=(VkShaderModule&& other) noexcept;
// Load a SPIR-V file from disk
[[nodiscard]] bool loadFromFile(VkDevice device, const std::string& path);
// Load from raw SPIR-V bytes
bool loadFromMemory(VkDevice device, const uint32_t* code, size_t sizeBytes);
void destroy();
::VkShaderModule getModule() const { return module_; }
bool isValid() const { return module_ != VK_NULL_HANDLE; }
// Create a VkPipelineShaderStageCreateInfo for this module
VkPipelineShaderStageCreateInfo stageInfo(VkShaderStageFlagBits stage,
const char* entryPoint = "main") const;
private:
VkDevice device_ = VK_NULL_HANDLE;
::VkShaderModule module_ = VK_NULL_HANDLE;
};
// Convenience: load a shader stage directly from a .spv file
VkPipelineShaderStageCreateInfo loadShaderStage(VkDevice device,
const std::string& path, VkShaderStageFlagBits stage);
} // namespace rendering
} // namespace wowee