fix(cmake): afegir cmake/spv_to_header.cmake per convertir SPIR-V a headers C++
El fitxer era referenciat per CMakeLists.txt però mai no s'havia creat, causant error de build immediat. Genera arrays uint8_t embeguts a partir dels binaris .spv compilats per glslc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
20
cmake/spv_to_header.cmake
Normal file
20
cmake/spv_to_header.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Converts a SPIR-V binary to a C++ header with an embedded uint8_t array.
|
||||
# cmake -DINPUT=<spv> -DOUTPUT=<h> -DVAR_NAME=<name> -P spv_to_header.cmake
|
||||
|
||||
if(NOT DEFINED INPUT OR NOT DEFINED OUTPUT OR NOT DEFINED VAR_NAME)
|
||||
message(FATAL_ERROR "Usage: -DINPUT=x.spv -DOUTPUT=x.h -DVAR_NAME=kname -P spv_to_header.cmake")
|
||||
endif()
|
||||
|
||||
file(READ "${INPUT}" raw_hex HEX)
|
||||
string(REGEX REPLACE "([0-9a-fA-F][0-9a-fA-F])" "0x\\1," hex_bytes "${raw_hex}")
|
||||
string(REGEX REPLACE ",$" "" hex_bytes "${hex_bytes}")
|
||||
string(LENGTH "${raw_hex}" hex_len)
|
||||
math(EXPR byte_count "${hex_len} / 2")
|
||||
|
||||
file(WRITE "${OUTPUT}"
|
||||
"#pragma once
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
static const uint8_t ${VAR_NAME}[] = { ${hex_bytes} };
|
||||
static const size_t ${VAR_NAME}_size = ${byte_count};
|
||||
")
|
||||
Reference in New Issue
Block a user