From d76c7f75a282d0292d1a6d34f7ef5746f0a4c625 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 20 Mar 2026 11:36:52 +0100 Subject: [PATCH] fix(cmake): afegir cmake/spv_to_header.cmake per convertir SPIR-V a headers C++ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cmake/spv_to_header.cmake | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cmake/spv_to_header.cmake diff --git a/cmake/spv_to_header.cmake b/cmake/spv_to_header.cmake new file mode 100644 index 0000000..7a4029f --- /dev/null +++ b/cmake/spv_to_header.cmake @@ -0,0 +1,20 @@ +# Converts a SPIR-V binary to a C++ header with an embedded uint8_t array. +# cmake -DINPUT= -DOUTPUT= -DVAR_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 +#include +static const uint8_t ${VAR_NAME}[] = { ${hex_bytes} }; +static const size_t ${VAR_NAME}_size = ${byte_count}; +")