Skip to content

Commit

Permalink
Make runtime shader compilation optional (#251)
Browse files Browse the repository at this point in the history
* Move shader compilation to libcute-shader

* Fix user shader compilation

* Remove unnecessary include

* Make cf_make_shader_from_bytecode more friendly to code generator

* Add cute-shaderc

* Implement draw shader compilation

* Fix syntax error in generated header

* Pre-compile builtin shaders

* Pre-compile imgui shaders

* Update hello_triangle sample

* Update shallow_water sample

* Update recolor sample

* Update spaceshooter example

* Update waves sample

* Update metaballs sample

* Make CI build both variants of CF_GLSLANG

* Skip uploading artifact for variant without runtime shader compilation

* Ensure that src/data/builtin_shaders_bytecode.h is rebuilt when needed

* Simplify hello_triangle sample

* Enable PIC in libcute-shader when building CF as a dynamic library

* Stack allocate the list of builtin includes

* Add VFS support in cute-shader

* Make the runtime compiler lookup cf_shader_directory for include

* Revert samples which uses inline shader

* Add preprocessed shader source as comment in generated header

* Style fix

* Remove unnecessary dependencies

* Add reflection info to shader compiler

* Make CF use reflection info from cute-shader

* Make CF and cute-shader share the CF_ShaderBytecode definition

* Add extern "C"

* Fetching and building of glslang optional

* Make workflow use the new options

* Add doc to CF_ShaderInputInfo

* Clean up

* Add -obytecode= to cute-shaderc to write raw SPIRV blob

* Create documentation for changes

* Typo and wornding in doc

* Update coding style to follow CF convention

* Add const to NULL declarations

This allows the header to be compiled as C too.
  • Loading branch information
bullno1 authored Dec 18, 2024
1 parent 4d223c9 commit 4c09206
Show file tree
Hide file tree
Showing 35 changed files with 10,013 additions and 895 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
# Matrix feature for cross-platform coverage. Names the build "Build X"
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: "Build ${{ matrix.platform.name }}"
name: "Build ${{ matrix.platform.name }} (CF_RUNTIME_SHADER_COMPILATION=${{ matrix.runtime_shader_compilation.value }})"
runs-on: ${{ matrix.platform.os }}
timeout-minutes: 20

Expand All @@ -22,6 +22,9 @@ jobs:
# Don't cancel other in-progress jobs if one fails.
fail-fast: false
matrix:
runtime_shader_compilation:
- { value: 'ON', cmake_arg: '-DCF_RUNTIME_SHADER_COMPILATION=ON' }
- { value: 'OFF', cmake_arg: '-DCF_RUNTIME_SHADER_COMPILATION=OFF' }
platform:
# Diabled MinGW as it was having trouble with DX12 headers being out of date.
# - { name: "Windows (MinGW-w64)", os: windows-latest, artifact: 'mingw-w64', generate: '-G "MinGW Makefiles"' }
Expand All @@ -45,7 +48,7 @@ jobs:

- name: Create build folder with CMake
run: |
cmake ${{ matrix.platform.generate }} -B build_folder
cmake ${{ matrix.platform.generate }} ${{ matrix.runtime_shader_compilation.cmake_arg }} -B build_folder
- name: Build project binary (non-MSVC)
run: |
Expand Down Expand Up @@ -129,3 +132,4 @@ jobs:
if-no-files-found: error
name: ${{ matrix.platform.artifact }}
path: ./dist/
if: matrix.runtime_shader_compilation.value == 'ON'
143 changes: 100 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# Todo - Fix how turning some of these off breaks the build.
option(CF_FRAMEWORK_STATIC "Build static library for Cute Framework." ON)
option(CF_GLSLANG "Build CF with online shader compilation support." ON)
option(CF_GLSLANG_OPTIMIZER "Build CF with online shader compilation + optmization support (requires python 3.x installation)." ON)
option(CF_RUNTIME_SHADER_COMPILATION "Build CF with online shader compilation support (requires python 3.x installation)." ON)
option(CF_CUTE_SHADERC "Build cute-shaderc, an offline shader compiler (requires python 3.x installation)." ON)
option(CF_FRAMEWORK_APPLE_FRAMEWORK "Build CF libraries as Apple Framework" OFF)

# Platform detection.
Expand Down Expand Up @@ -177,6 +177,7 @@ set(CF_HDRS
src/internal/cute_aseprite_cache_internal.h
src/internal/cute_alloc_internal.h
src/internal/yyjson.h
src/data/builtin_shaders_bytecode.h
)

if(CF_FRAMEWORK_STATIC)
Expand Down Expand Up @@ -329,58 +330,78 @@ else()
endif()
target_include_directories(cute PUBLIC ${SDL3_INCLUDE_DIRS})

# glslang + SPIRV stuff for online shader compilation (optional).
if (CF_GLSLANG)
add_definitions(-DCF_RUNTIME_SHADER_COMPILATION)
if (CF_RUNTIME_SHADER_COMPILATION OR CF_CUTE_SHADERC)
# glslang for shader compilation.
set(GLSLANG_TESTS_DEFAULT OFF CACHE BOOL "Do not build glslang tests.")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Do not build glslang as a shared lib.")
SET(ENABLE_OPT CF_GLSLANG_OPTIMIZER CACHE BOOL "Do not use SPIR-V Tools.")
set(ENABLE_OPT ON CACHE BOOL "Enable optimization.")
set(SKIP_SPIRV_TOOLS_INSTALL OFF CACHE BOOL "Don't install the SPIR-V Tools as they are built.")
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Don't build any SPIR-V Tools executables/tests.")
set(SPIRV_WERROR OFF CACHE BOOL "Turn off SPIR-V warnings as error.")
set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "Turn off some standalone binary tools for glslang.")
set(GLSLANG_ENABLE_INSTALL OFF CACHE BOOL "Disable installation option for glslang.")

if (CF_GLSLANG_OPTIMIZER)
find_package(Python3 REQUIRED)
FetchContent_Declare(
glslang
URL https://github.com/KhronosGroup/glslang/archive/refs/tags/14.3.0.zip
DOWNLOAD_EXTRACT_TIMESTAMP ON
PATCH_COMMAND ${Python3_EXECUTABLE} update_glslang_sources.py
)
FetchContent_MakeAvailable(glslang)
endif()
set(SPIRV_CROSS_CLI OFF CACHE BOOL "Turn off building SPIR-Cross CLI.")
find_package(Python3 REQUIRED)
FetchContent_Declare(
SPIRV_CROSS
GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Cross.git
GIT_TAG main
CMAKE_ARGS -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON -DSPIRV_CROSS_CLI=OFF -DSPIRV_CROSS_SHARED=OFF -DSPIRV_CROSS_STATIC=ON
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
glslang
URL https://github.com/KhronosGroup/glslang/archive/refs/tags/14.3.0.zip
DOWNLOAD_EXTRACT_TIMESTAMP ON
PATCH_COMMAND ${Python3_EXECUTABLE} update_glslang_sources.py
)
set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE BOOL "Disable SPIRV-Cross tests")
set(SPIRV_CROSS_ENABLE_GLSLANG_INSTALL OFF CACHE BOOL "Disable GLSLANG install")
set(SPIRV_CROSS_SHARED OFF CACHE BOOL "Build SPIRV-Cross as shared library")
set(SPIRV_CROSS_STATIC ON CACHE BOOL "Do not build SPIRV-Cross as static library")
set(SPIRV_CROSS_C_API ON CACHE BOOL "Enable the C API")
set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS ON CACHE BOOL "Turn off exceptions in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_REFLECT OFF CACHE BOOL "Turn off reflection in SPIRV-Cross.")
set(SPIRV_CROSS_SKIP_INSTALL OFF CACHE BOOL "Turn off install targets in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_UTIL OFF CACHE BOOL "Turn off utils in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_CPP OFF CACHE BOOL "Turn off CPP target support in SPIRV-Cross.")
set(SPIRV_CROSS_FORCE_PIC $<NOT:${CF_FRAMEWORK_STATIC}> CACHE BOOL "Force position-independent code for all targets.")
if (WINDOWS)
set(SPIRV_CROSS_ENABLE_MSL OFF CACHE BOOL "Turn off MSL support when on windows.")
FetchContent_MakeAvailable(glslang)

# cute-shader, a glslang wrapper
set(CUTE_SHADER_SRCS src/cute_shader/cute_shader.cpp)
add_library(cute-shader STATIC ${CUTE_SHADER_SRCS})
target_link_libraries(cute-shader PRIVATE glslang glslang-default-resource-limits SPIRV)
if (NOT MSVC AND NOT CF_FRAMEWORK_STATIC)
target_compile_options(cute-shader PRIVATE -fPIC)
endif()
if (APPLE)
set(SPIRV_CROSS_ENABLE_HLSL OFF CACHE BOOL "Turn off HLSL support when on windows.")
target_include_directories(cute-shader PUBLIC include) # For cute_shader_info.h

# Linking cute-shader for online shader compilation (optional).
if (CF_RUNTIME_SHADER_COMPILATION)
target_compile_definitions(cute PUBLIC CF_RUNTIME_SHADER_COMPILATION)
set(CF_LINK_LIBS ${CF_LINK_LIBS} cute-shader)
endif()

# cute-shaderc, an offline shader compiler
if (CF_CUTE_SHADERC)
set(CUTE_SHADERC_SRCS src/cute_shader/cute_shaderc.cpp)
add_executable(cute-shaderc ${CUTE_SHADERC_SRCS})
target_link_libraries(cute-shaderc cute-shader)
endif()
FetchContent_MakeAvailable(SPIRV_CROSS)
set(CF_LINK_LIBS ${CF_LINK_LIBS} glslang glslang-default-resource-limits SPIRV SPIRV-Tools SPIRV-Tools-opt spirv-cross-c)
endif()

# SPIRV-Cross for SDL_gpu_shadercross
set(SPIRV_CROSS_CLI OFF CACHE BOOL "Turn off building SPIRV-Cross CLI.")
FetchContent_Declare(
SPIRV_CROSS
GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Cross.git
GIT_TAG main
CMAKE_ARGS -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS=ON -DSPIRV_CROSS_CLI=OFF -DSPIRV_CROSS_SHARED=OFF -DSPIRV_CROSS_STATIC=ON
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
set(SPIRV_CROSS_ENABLE_TESTS OFF CACHE BOOL "Disable SPIRV-Cross tests")
set(SPIRV_CROSS_ENABLE_GLSLANG_INSTALL OFF CACHE BOOL "Disable GLSLANG install")
set(SPIRV_CROSS_SHARED OFF CACHE BOOL "Build SPIRV-Cross as shared library")
set(SPIRV_CROSS_STATIC ON CACHE BOOL "Do not build SPIRV-Cross as static library")
set(SPIRV_CROSS_C_API ON CACHE BOOL "Enable the C API")
set(SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS ON CACHE BOOL "Turn off exceptions in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_REFLECT OFF CACHE BOOL "Turn off reflection in SPIRV-Cross.")
set(SPIRV_CROSS_SKIP_INSTALL OFF CACHE BOOL "Turn off install targets in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_UTIL OFF CACHE BOOL "Turn off utils in SPIRV-Cross.")
set(SPIRV_CROSS_ENABLE_CPP OFF CACHE BOOL "Turn off CPP target support in SPIRV-Cross.")
set(SPIRV_CROSS_FORCE_PIC $<NOT:${CF_FRAMEWORK_STATIC}> CACHE BOOL "Force position-independent code for all targets.")
if (WINDOWS)
set(SPIRV_CROSS_ENABLE_MSL OFF CACHE BOOL "Turn off MSL support when on windows.")
endif()
if (APPLE)
set(SPIRV_CROSS_ENABLE_HLSL OFF CACHE BOOL "Turn off HLSL support when on windows.")
endif()
FetchContent_MakeAvailable(SPIRV_CROSS)
set(CF_LINK_LIBS ${CF_LINK_LIBS} spirv-cross-c)

# Some platform specific settings.
if(EMSCRIPTEN)
target_compile_options(cute PUBLIC -O1 -fno-rtti -fno-exceptions)
Expand Down Expand Up @@ -409,6 +430,18 @@ elseif(APPLE)
endif()
endif()

# Precompile builtin shaders
if (CF_CUTE_SHADERC)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/data/builtin_shaders_bytecode.h
COMMAND cute-shaderc
-type=builtin
-oheader=${CMAKE_CURRENT_SOURCE_DIR}/src/data/builtin_shaders_bytecode.h
DEPENDS src/cute_shader/builtin_shaders.h
DEPENDS cute-shaderc
)
endif()

# Link up all dependencies to Cute.
target_link_libraries(cute PUBLIC ${CF_LINK_LIBS})

Expand Down Expand Up @@ -466,10 +499,10 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
add_executable(docsparser samples/docs_parser.cpp)
add_executable(scratch samples/scratch.cpp)
add_executable(https samples/https.c)
add_executable(spaceshooter samples/spaceshooter.cpp)
add_executable(spaceshooter samples/spaceshooter.cpp samples/spaceshooter_data/flash_shd.h)
add_executable(draw_to_texture samples/draw_to_texture.c)
add_executable(hello_triangle samples/hello_triangle.c)
add_executable(waves samples/waves.cpp)
add_executable(waves samples/waves.cpp samples/waves_data/waves_shd.h)
add_executable(shallow_water samples/shallow_water.cpp)
add_executable(noise samples/noise.c)
add_executable(fetch_image samples/fetch_image.cpp)
Expand Down Expand Up @@ -537,6 +570,30 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
endif()
endforeach()

# Pre-compile shaders for certain samples.
if (CF_CUTE_SHADERC)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/samples/spaceshooter_data/flash_shd.h
COMMAND cute-shaderc
-type=draw
-varname=s_flash_shd_bytecode
-oheader=${CMAKE_CURRENT_SOURCE_DIR}/samples/spaceshooter_data/flash_shd.h
${CMAKE_CURRENT_SOURCE_DIR}/samples/spaceshooter_data/flash.shd
DEPENDS samples/spaceshooter_data/flash.shd
DEPENDS cute-shaderc
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/samples/waves_data/waves_shd.h
COMMAND cute-shaderc
-type=draw
-varname=s_waves_shd_bytecode
-oheader=${CMAKE_CURRENT_SOURCE_DIR}/samples/waves_data/waves_shd.h
${CMAKE_CURRENT_SOURCE_DIR}/samples/waves_data/waves.shd
DEPENDS samples/waves_data/waves.shd
DEPENDS cute-shaderc
)
endif()

# Copy over some folders for certain samples.
add_custom_command(TARGET spaceshooter PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/samples/spaceshooter_data $<TARGET_FILE_DIR:spaceshooter>/spaceshooter_data)
add_custom_command(TARGET waves PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/samples/waves_data $<TARGET_FILE_DIR:waves>/waves_data)
Expand Down
9 changes: 9 additions & 0 deletions docs/api_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ This is a list of all functions in Cute Framework organized by categories. This
- [cf_draw_TSR_absolute](/draw/cf_draw_tsr_absolute.md)
- [cf_fetch_image](/draw/cf_fetch_image.md)
- [cf_make_draw_shader](/draw/cf_make_draw_shader.md)
- [cf_make_draw_shader_from_bytecode](/draw/cf_make_draw_shader_from_bytecode.md)
- [cf_make_draw_shader_from_source](/draw/cf_make_draw_shader_from_source.md)
- [cf_make_premade_sprite](/draw/cf_make_premade_sprite.md)
- [cf_register_premade_atlas](/draw/cf_register_premade_atlas.md)
Expand All @@ -403,6 +404,7 @@ This is a list of all functions in Cute Framework organized by categories. This

### structs
- [CF_AtlasSubImage](/draw/cf_atlassubimage.md)
- [CF_DrawShaderBytecode](/draw/cf_drawshaderbytecode.md)
- [CF_TemporaryImage](/draw/cf_temporaryimage.md)
- [CF_Vertex](/draw/cf_vertex.md)

Expand Down Expand Up @@ -900,6 +902,7 @@ This is a list of all functions in Cute Framework organized by categories. This
- [cf_draw_elements](/graphics/cf_draw_elements.md)
- [cf_filter_to_string](/graphics/cf_filter_to_string.md)
- [cf_fract_color](/graphics/cf_fract_color.md)
- [cf_free_shader_bytecode](/graphics/cf_free_shader_bytecode.md)
- [cf_hsv_to_rgb](/graphics/cf_hsv_to_rgb.md)
- [cf_hue](/graphics/cf_hue.md)
- [cf_make_canvas](/graphics/cf_make_canvas.md)
Expand Down Expand Up @@ -993,6 +996,11 @@ This is a list of all functions in Cute Framework organized by categories. This
- [CF_Pixel](/graphics/cf_pixel.md)
- [CF_RenderState](/graphics/cf_renderstate.md)
- [CF_Shader](/graphics/cf_shader.md)
- [CF_ShaderBytecode](/graphics/cf_shaderbytecode.md)
- [CF_ShaderInfo](/graphics/cf_shaderinfo.md)
- [CF_ShaderInputInfo](/graphics/cf_shaderinputinfo.md)
- [CF_ShaderUniformInfo](/graphics/cf_shaderuniforminfo.md)
- [CF_ShaderUniformMemberInfo](/graphics/cf_shaderuniformmemberinfo.md)
- [CF_StencilFunction](/graphics/cf_stencilfunction.md)
- [CF_StencilParams](/graphics/cf_stencilparams.md)
- [CF_Texture](/graphics/cf_texture.md)
Expand All @@ -1009,6 +1017,7 @@ This is a list of all functions in Cute Framework organized by categories. This
- [CF_Filter](/graphics/cf_filter.md)
- [CF_PixelFormat](/graphics/cf_pixelformat.md)
- [CF_PixelFormatOp](/graphics/cf_pixelformatop.md)
- [CF_ShaderInfoDataType](/graphics/cf_shaderinfodatatype.md)
- [CF_ShaderStage](/graphics/cf_shaderstage.md)
- [CF_StencilOp](/graphics/cf_stencilop.md)
- [CF_TextureUsageFlagBits](/graphics/cf_textureusageflagbits.md)
Expand Down
29 changes: 29 additions & 0 deletions docs/draw/cf_drawshaderbytecode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[//]: # (This file is automatically generated by Cute Framework's docs parser.)
[//]: # (Do not edit this file by hand!)
[//]: # (See: https://github.com/RandyGaul/cute_framework/blob/master/samples/docs_parser.cpp)
[](../header.md ':include')

# CF_DrawShaderBytecode

Category: [draw](/api_reference?id=draw)
GitHub: [cute_draw.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_draw.h)
---

Bytecode for a draw shader.

Struct Members | Description
--- | ---
`CF_ShaderBytecode draw_shader` | Bytecode for draw shader.
`CF_ShaderBytecode blit_shader` | Bytecode for blit shader.

## Remarks

This can be created using the `cute-shaderc` compiler.

## Related Pages

[CF_Shader](/graphics/cf_shader.md)
[cf_draw_push_shader](/draw/cf_draw_push_shader.md)
[cf_draw_pop_shader](/draw/cf_draw_pop_shader.md)
[cf_draw_peek_shader](/draw/cf_draw_peek_shader.md)
[cf_make_draw_shader_from_bytecode](/draw/cf_make_draw_shader_from_bytecode.md)
29 changes: 29 additions & 0 deletions docs/draw/cf_make_draw_shader_from_bytecode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[//]: # (This file is automatically generated by Cute Framework's docs parser.)
[//]: # (Do not edit this file by hand!)
[//]: # (See: https://github.com/RandyGaul/cute_framework/blob/master/samples/docs_parser.cpp)
[](../header.md ':include')

# cf_make_draw_shader_from_bytecode

Category: [draw](/api_reference?id=draw)
GitHub: [cute_draw.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_draw.h)
---

Creates a custom draw shader from bytecode.

```cpp
CF_Shader cf_make_draw_shader_from_bytecode(CF_DrawShaderBytecode bytecode);
```
## Remarks
Your shader must be written in GLSL 450, and must follow some specific rules to be compatible with the draw API. For more in-depth explanations,
see CF's docs on [Draw Shaders](https://randygaul.github.io/cute_framework/#/topics/drawing?id=shaders).
## Related Pages
[CF_Shader](/graphics/cf_shader.md)
[CF_DrawShaderBytecode](/draw/cf_drawshaderbytecode.md)
[cf_draw_push_shader](/draw/cf_draw_push_shader.md)
[cf_draw_pop_shader](/draw/cf_draw_pop_shader.md)
[cf_draw_peek_shader](/draw/cf_draw_peek_shader.md)
6 changes: 4 additions & 2 deletions docs/graphics/cf_compile_shader_to_bytecode.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GitHub: [cute_graphics.h](https://github.com/RandyGaul/cute_framework/blob/maste
Compiles a shader to SPIR-V bytecode.

```cpp
const dyna uint8_t* cf_compile_shader_to_bytecode(const char* shader_src, CF_ShaderStage stage);
CF_ShaderBytecode cf_compile_shader_to_bytecode(const char* shader_src, CF_ShaderStage stage);
```
Parameters | Description
Expand All @@ -25,9 +25,11 @@ stage | The shaderstrage to differentiate between vertex or fragment shaders.
This function is good for precompiling shaders to bytecode, which can help speed up app
startup times. SPIR-V blobs can be saved straight to disk and shipped with your game. Load
the bytecode blob pair (vertex + fragment shader blobs) into a [CF_Shader](/graphics/cf_shader.md) via [cf_make_shader_from_bytecode](/graphics/cf_make_shader_from_bytecode.md).
The value returned from this function should be passed to [cf_free_shader_bytecode](/graphics/cf_free_shader_bytecode.md) when it is no longer needed.
## Related Pages
[CF_Shader](/graphics/cf_shader.md)
[CF_ShaderBytecode](/graphics/cf_shaderbytecode.md)
[cf_make_shader_from_bytecode](/graphics/cf_make_shader_from_bytecode.md)
[cf_make_shader_from_bytecode](/graphics/cf_make_shader_from_bytecode.md)
[cf_free_shader_bytecode](/graphics/cf_free_shader_bytecode.md)
26 changes: 26 additions & 0 deletions docs/graphics/cf_free_shader_bytecode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[//]: # (This file is automatically generated by Cute Framework's docs parser.)
[//]: # (Do not edit this file by hand!)
[//]: # (See: https://github.com/RandyGaul/cute_framework/blob/master/samples/docs_parser.cpp)
[](../header.md ':include')

# cf_free_shader_bytecode

Category: [graphics](/api_reference?id=graphics)
GitHub: [cute_graphics.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_graphics.h)
---

Free a bytecode blob previously returned from [cf_compile_shader_to_bytecode](/graphics/cf_compile_shader_to_bytecode.md).

```cpp
void cf_free_shader_bytecode(CF_ShaderBytecode bytecode);
```
Parameters | Description
--- | ---
bytecode | The bytecode blob to free.
## Remarks
This function must only be called on the bytecode blob returned from [cf_compile_shader_to_bytecode](/graphics/cf_compile_shader_to_bytecode.md).
It cannot be called on the bytecode blob generated as a header from the `cute-shaderc` compiler.
Loading

0 comments on commit 4c09206

Please sign in to comment.