Topaz 5.0
Topaz Game Engine
Loading...
Searching...
No Matches

Description

Create shaders to carry out programmable GPU work.

Typedefs

using tz::gpu::shader_handle = tz::handle<shader_tag_t>
 Corresponds to a previously-created shader program (for graphics or compute).
 

Function Documentation

◆ create_graphics_shader()

std::expected< shader_handle, tz::error_code > tz::gpu::create_graphics_shader ( std::string_view vertex_source,
std::string_view fragment_source )

Create a new shader intended for graphics GPU work, comprised of a vertex and fragment shader.

Parameters
vertex_sourceCode for the vertex shader, in SPIRV.
fragment_sourceCode for the fragment shader, in SPIRV.
Returns
On success: A shader_handle corresponding to the newly-created shader program.
tz::error_code::oom If CPU memory is exhausted whilst trying to create the shader program.
tz::error_code::voom If GPU memory is exhausted whilst trying to create the shader program.
tz::error_code::unknown_error If some other undocumented error occurs.

◆ create_compute_shader()

std::expected< shader_handle, tz::error_code > tz::gpu::create_compute_shader ( std::string_view compute_source)

Create a new shader intended for compute GPU work, comprised of a single compute shader.

Parameters
compute_sourceCode for the compute shader, in SPIRV.
Returns
On success: A shader_handle corresponding to the newly-created shader program.
tz::error_code::oom If CPU memory is exhausted whilst trying to create the shader program.
tz::error_code::voom If GPU memory is exhausted whilst trying to create the shader program.
tz::error_code::unknown_error If some other undocumented error occurs.

◆ destroy_shader()

void tz::gpu::destroy_shader ( shader_handle )

Manually destroy a previously-created shader.

If you are certain that you are done with a shader program, you can destroy it here, causing all of its memory to be available for reuse.

Note
If you never destroy a shader manually, it will automatically be destroyed for you when you call tz::terminate.
Warning
Be aware of GPU synchronisation! Ensure that you do not destroy a shader that is currently in-use by ongoing GPU work. Take care to ensure that renderers using the resource have finished their work before tearing it down.

Macro Definition Documentation

◆ ImportedShaderHeader

#define ImportedShaderHeader ( shader_name,
shader_type )

Retrieves a file path which is intended to be #included in a application's main source file. Once included, the imported shader's source code can be retrieved as a constexpr string_view via ImportedShaderSource

◆ ImportedShaderSource

#define ImportedShaderSource ( shader_name,
shader_type )

Retrieves a token representing a std::string_view which contains the shader's compiled results. On Vulkan, this will be SPIRV, and GLSL source code for OpenGL. You can only retrieve an imported shader's source if the imported header has been included via ImportedShaderHeader

Typedef Documentation

◆ shader_handle

using tz::gpu::shader_handle = tz::handle<shader_tag_t>

Corresponds to a previously-created shader program (for graphics or compute).