nicegraf
ngf_shader_stage_info Struct Reference

Data Fields

ngf_stage_type type
 
const void * content
 
uint32_t content_length
 
const char * debug_name
 
const char * entry_point_name
 

Detailed Description

Describes a programmable shader stage.

Field Documentation

◆ content

const void* ngf_shader_stage_info::content

This shall be a pointer to a memory buffer containing the code for the shader stage.

The specific contents of the buffer depend on which backend nicegraf is being used with:

  • for the Vulkan backend, nicegraf expects the SPIR-V bytecode for the shader stage.
  • for the Metal backend, nicegraf expects the source code for the shader stage in the Metal Shading Language.

Additionally, the Metal backend expects the code to contain a special comment, mapping all <descriptor set, binding> pairs to the native Metal argument table slots. The comment shall be a C-style block comment - beginning with a forward slash, followed by an asterisk - containing the following word:

NGF_NATIVE_BINDING_MAP

followed by a newline character.

Each of the following lines until the end of the comment shall have the following format:

(s b) : m

where s is the set number, b is the binding number within the set, and m is the index of the corresponding resource in Metal's argument table.

For example, let's say the Metal shader refers to index 3 in the texture argument table. Adding the following line to the binding map comment

(0 1) : 3

would tell the nicegraf metal backend to use the third slot of the texture argument table when an image is bound to set 0, binding 1 using ngf_cmd_bind_resources.

When compiling HLSL shaders using nicegraf-shaderc, the comment with the binding map is generated automatically.

◆ content_length

uint32_t ngf_shader_stage_info::content_length

The number of bytes in the ngf_shader_stage_info::content buffer.

◆ debug_name

const char* ngf_shader_stage_info::debug_name

Optional name, will appear in debug logs, may be NULL.

◆ entry_point_name

const char* ngf_shader_stage_info::entry_point_name

Entry point name for this shader stage.

◆ type

ngf_stage_type ngf_shader_stage_info::type

Stage type (vert/frag/etc.)