1#ifndef TOPAZ_GPU_PASS_HPP
2#define TOPAZ_GPU_PASS_HPP
3#include "tz/core/handle.hpp"
4#include "tz/core/vector.hpp"
5#include "tz/gpu/resource.hpp"
6#include "tz/gpu/shader.hpp"
32 constexpr pass_flag operator|(pass_flag lhs, pass_flag rhs)
34 return static_cast<pass_flag
>(
static_cast<int>(lhs) |
static_cast<int>(rhs));
37 constexpr bool operator&(pass_flag lhs, pass_flag& rhs)
39 return static_cast<int>(lhs) &
static_cast<int>(rhs);
59 return static_cast<graphics_flag>(
static_cast<int>(lhs) |
static_cast<int>(rhs));
64 return static_cast<int>(lhs) &
static_cast<int>(rhs);
182 pass_flag
flags =
static_cast<pass_flag
>(0);
184 const char*
name =
"<untitled pass>";
197 constexpr auto present_pass =
static_cast<tz::hanval
>(std::numeric_limits<std::underlying_type_t<tz::hanval>>::max() - 1);
error_code
Error codes for Topaz.
Definition error.hpp:14
constexpr nullhand_t nullhand
Definition handle.hpp:22
pass_type
Describes what kind of GPU work a pass will involve.
Definition pass.hpp:21
constexpr auto present_pass
Meta-pass that acts as an action to present the system image to the screen.
Definition pass.hpp:197
void pass_set_kernel(pass_handle compute_pass, tz::v3u kernel)
Set the compute kernel of an existing compute pass.
std::expected< pass_handle, tz::error_code > create_pass(pass_info)
Create a new pass.
cull
Specifies face culling behaviour of a graphics pass.
Definition pass.hpp:72
graphics_flag
Specifies optional behaviours for a graphics pass.
Definition pass.hpp:47
void pass_set_scissor(pass_handle graphics_pass, tz::v4u scissor)
Set the scissor rectangle of an existing graphics pass.
tz::error_code pass_add_image_resource(pass_handle pass, resource_handle res)
Add a new image resource to be used in the pass.
void pass_set_triangle_count(pass_handle graphics_pass, std::size_t triangle_count)
Set the triangle count of an existing graphics pass.
void destroy_pass(pass_handle)
Manually destroy a pass.
@ compute
Compute Pass - involves bespoke GPU-side processing via a compute shader.
@ render
Render Pass - involves rendering some kind of geometry via a vertex and fragment shader.
@ none
Do not perform any face culling.
@ back
Cull the back face.
@ front
Cull the front face.
@ both
Cull front and back faces.
@ dont_clear
Do not clear the colour target images prior to rendering - whatever data they held previously will be...
Definition pass.hpp:49
@ no_depth_write
Disable depth writes - i.e when a depth test is passed by a fragment, the old depth value is not over...
Definition pass.hpp:53
@ no_depth_test
Disable depth testing - i.e fragments that are behind another may still draw over it.
Definition pass.hpp:51
Specifies creation flags for a new compute pass.
Definition pass.hpp:146
tz::v3u kernel
Number of workgroups (XYZ) to dispatch every frame.
Definition pass.hpp:148
Specifies creation flags for a new graphics pass.
Definition pass.hpp:90
resource_handle depth_target
Optional depth target. This will act as the depth image when performing depth testing/writes.
Definition pass.hpp:98
resource_handle index_buffer
Buffer containing indices drawn in a single invocation of the pass.
Definition pass.hpp:109
tz::v4u scissor
Scissor rectangle, components represent {offsetx, offsety, extentx, extenty} in pixels....
Definition pass.hpp:94
tz::v4f clear_colour
When a colour target is cleared, what colour (RGBA normalised floats) should it be cleared to?
Definition pass.hpp:92
graphics_flag flags
Specifies extra optional behaviour for the pass.
Definition pass.hpp:126
std::span< const resource_handle > colour_targets
List of all colour targets. The n'th colour target specified here will be the n'th output of the frag...
Definition pass.hpp:96
cull culling
Describe which faces will be culled during rendering.
Definition pass.hpp:124
resource_handle draw_buffer
Buffer containing an initial count and draw commands which may or may not be used in a single invocat...
Definition pass.hpp:122
std::size_t triangle_count
Number of triangles to draw in a single invocation of the pass.
Definition pass.hpp:136
Specifies creation flags for a new pass.
Definition pass.hpp:158
pass_compute_state compute
Describe the compute state. If the pass is a graphics pass, this is ignored.
Definition pass.hpp:162
pass_flag flags
Specifies extra optional behaviour for the pass.
Definition pass.hpp:182
pass_graphics_state graphics
Describe the graphics state. If the pass is a compute pass, this is ignored.
Definition pass.hpp:160
const char * name
Name identifying the pass. Debug tools/error checking will refer to the pass by this name if you prov...
Definition pass.hpp:184
std::span< const resource_handle > resources
List of all resources used in the shader program.
Definition pass.hpp:180
shader_handle shader
Corresponds to the shader that will run during execution. This must refer to a valid shader program c...
Definition pass.hpp:164
static constexpr vector< unsigned int, N > zero()
Definition vector.hpp:26
static constexpr vector< unsigned int, N > filled(unsigned int t)
Definition vector.hpp:32