12#include <utility/graphic/shader.hpp>
14namespace utility::graphic
18 void validateSpirv(
const std::string &data,
const char *which)
20 if (data.size() %
sizeof(uint32_t) != 0) {
21 throw std::invalid_argument(
23 +
" shader bytecode length is not a multiple of 4");
30 validateSpirv(vertString,
"Vertex");
31 validateSpirv(fragString,
"Fragment");
34 std::vector<uint32_t>(vertString.size() /
sizeof(uint32_t));
35 std::memcpy(
_vertSPIRV.data(), vertString.data(), vertString.size());
38 std::vector<uint32_t>(fragString.size() /
sizeof(uint32_t));
39 std::memcpy(
_fragSPIRV.data(), fragString.data(), fragString.size());
const std::vector< uint32_t > & getVertexCode() const
Retrieves the SPIR-V bytecode for the vertex shader.
const std::vector< uint32_t > & getFragmentCode() const
Retrieves the SPIR-V bytecode for the fragment shader.
Shader(const std::string &vertString, const std::string &fragString)
Constructs a Shader object by loading vertex and fragment shader bytecode from strings.
std::vector< uint32_t > _fragSPIRV
SPIR-V bytecode for the fragment shader.
std::vector< uint32_t > _vertSPIRV
SPIR-V bytecode for the vertex shader.