shader

Header: kmsroots/shader.h

Table of contents (click to go)

Macros

Enums

Unions

Structs

  1. kmr_shader_spirv

  2. kmr_shader_spirv_create_info

Functions

  1. kmr_shader_spirv_create()

  2. kmr_shader_spirv_destroy()

Function Pointers

API Documentation

kmr_shader_spirv

struct kmr_shader_spirv
void *result;
const unsigned char *bytes;
unsigned long byteSize;
result
Pointer to an opaque handle to the results of a call to any shaderc_compile_into_*()
Unfortunately we can’t release/free until after the shader module is created.
bytes
Buffer that stores a spirv byte code.
byteSize
Byte size of spirv byte code buffer.

kmr_shader_spirv_create_info

struct kmr_shader_spirv_create_info
unsigned int kind;
const char *source;
const char *filename;
const char *entryPoint;

More information can be found at libshaderc/shaderc.h.

kind
Used to specify what type of shader to create SPIR-V bytes from
source
Pointer to a buffer containing actual shader code
filename
Used as a tag to identify the source string
entryPoint
Used to define the function name in the GLSL source that acts
as an entry point for the shader

kmr_shader_spirv_create

struct kmr_shader_spirv *kmr_shader_spirv_create(struct kmr_shader_spirv_create_info *spirvInfo);

Takes in a character buffer containing shader code, it then compiles char buff into SPIRV-bytes at runtime. These SPIRV-bytes can later be passed to vulkan.

Parameters:
spirvInfo
Pointer to a struct kmr_shader_spirv_create_info
Returns:
on success: pointer to struct kmr_shader_spriv
on failure: NULL

kmr_shader_spirv_destroy

void kmr_shader_spirv_destroy(struct kmr_shader_spirv *spirv);

Frees any allocated memory and closes FD’s (if open) created after kmr_shader_spirv_create() call

Parameters:
session
Must pass a valid pointer to a struct kmr_shader_spirv
/* Free'd members with fd's closed */
struct kmr_shader_spirv {
        void *result;
};