diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-05-16 18:55:58 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-05-16 18:55:58 +0200 |
commit | 107684b00d65eac84e4bf2dfd34073d309230d50 (patch) | |
tree | 131215f9b95d1a8a24fa92c99982ee691a7b4724 /blob | |
parent | 766a817a23403ea2aeb325bea9f340f54a3e7987 (diff) |
move shader compilation from runtime to compile-time
Diffstat (limited to 'blob')
-rwxr-xr-x | blob | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -0,0 +1,25 @@ +#!/bin/sh +input="$1" +base="$2" +symbol_base="$(echo "$base" | tr '[:punct:]' '_')" + +# assembly (used to compile data with custom symbol name) +cat << EOF > "$base.s" +.section .rodata +.global ${symbol_base}_head +${symbol_base}_head: +.incbin "$input" +EOF + +# C header +cat << EOF > "$base.h" +#pragma once +// NOTE: THIS FILE IS GENERATED, DO NOT EDIT +#include <stddef.h> + +extern const char ${symbol_base}_head; +const char* ${symbol_base} = &${symbol_base}_head; +const size_t ${symbol_base}_size = $(wc -c < "$input"); + +EOF + |