1#ifndef TOPAZ_GPU_RESOURCE_HPP
2#define TOPAZ_GPU_RESOURCE_HPP
3#include "tz/core/error.hpp"
4#include "tz/core/handle.hpp"
32 return static_cast<buffer_flag>(
static_cast<int>(lhs) |
static_cast<int>(rhs));
37 return static_cast<int>(lhs) &
static_cast<int>(rhs);
49 std::span<const std::byte>
data;
51 const char*
name =
"<untitled buffer resource>";
88 return static_cast<image_flag>(
static_cast<int>(lhs) |
static_cast<int>(rhs));
93 return static_cast<int>(lhs) &
static_cast<int>(rhs);
111 std::span<const std::byte>
data;
113 const char*
name =
"<untitled image resource>";
127 constexpr auto window_resource =
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
buffer_flag
Specifies optional behaviours for a buffer.
Definition resource.hpp:21
image_type
Describes the internal format of an image's data.
Definition resource.hpp:63
tz::error_code draw_buffer_write(resource_handle draw_buffer, std::uint32_t count, std::span< const draw_t > draws)
Write draw-indirect-count + commands into a buffer resource.
tz::error_code destroy_resource(resource_handle res)
Manually destroy a resource.
tz::error_code index_buffer_write(resource_handle index_buffer, std::span< const index_t > indices)
Write indices into a buffer resource.
std::expected< resource_handle, tz::error_code > create_buffer(buffer_info)
Create a new buffer.
std::expected< resource_handle, tz::error_code > create_image(image_info)
Create a new image.
constexpr auto window_resource
Corresponds to either the window image (as a colour target) or the system depth image (as a depth tar...
Definition resource.hpp:127
std::span< const std::byte > resource_read(resource_handle res)
Retrieves the current data within a resource.
std::size_t resource_size(resource_handle res)
Retrieve the size of a resource's data, in bytes.
void buffer_resize(resource_handle bufh, std::size_t new_size_bytes)
Resize a buffer resource.
image_flag
Specifies optional behaviours for a buffer.
Definition resource.hpp:77
unsigned int image_get_width(resource_handle res)
Retrieve the width of an image resource.
unsigned int image_get_height(resource_handle res)
Retrieve the height of an image resource.
tz::error_code resource_write(resource_handle res, std::span< const std::byte > new_data, std::size_t offset=0)
Write some new data to a resource. The thread will block until the changes are resident GPU-side.
void image_resize(resource_handle imgh, unsigned int new_width, unsigned int new_height)
Resize an image resource.
tz::error_code draw_buffer_indexed_write(resource_handle draw_buffer, std::uint32_t count, std::span< const draw_indexed_t > draws)
Write draw-indirect-count + indexed commands into a buffer resource.
@ draw
Buffer can be used as a draw buffer by a graphics pass.
Definition resource.hpp:25
@ dynamic_access
Buffer data will be writable directly from the CPU. Resource writes targetting buffers that are dynam...
Definition resource.hpp:27
@ index
Buffer can be used as an index buffer by a graphics pass.
Definition resource.hpp:23
@ depth
Image is comprised of 32-bit floats per pixel, but is only used as a depth image.
@ rgba
Image data is in a 32-bit RGBA unsigned normalised format.
@ floats
Image is comprised of 32-bit floats per pixel, but cannot be used as a depth image....
@ colour_target
Image can be used as a colour target by a graphics pass.
Definition resource.hpp:79
@ resize_to_match_window_resource
Image will be automatically resized to match the dimensions of the window. In addition,...
Definition resource.hpp:83
@ depth_target
Image can be used as a depth target by a graphics pass.
Definition resource.hpp:81
std::uint32_t index_t
Represents a single index. Indices are always 32-bit unsigned integers.
Definition resource.hpp:182
Specifies creation flags for a buffer.
Definition resource.hpp:47
const char * name
What name shall I have when you're looking at me in your graphics debugger of choice?...
Definition resource.hpp:51
buffer_flag flags
Any extra optional flags to specify?
Definition resource.hpp:53
std::span< const std::byte > data
What initial data shall I have?
Definition resource.hpp:49
Represents a single indexed draw-call.
Definition resource.hpp:207
std::uint32_t first_index
Index of the first index to draw (within the index buffer).
Definition resource.hpp:213
std::int32_t vertex_offset
An offset added to each index value before indexing into the vertex buffer.
Definition resource.hpp:215
std::uint32_t instance_count
Number of instances to draw. If you're not doing GPU instancing, you probably want this to be 1.
Definition resource.hpp:211
std::uint32_t first_instance
Instance ID of the first instance to draw.
Definition resource.hpp:217
std::uint32_t index_count
Number of indices (vertices) to draw.
Definition resource.hpp:209
Represents a single unindexed draw-call.
Definition resource.hpp:190
std::uint32_t first_instance
Instance ID of the first instance to draw.
Definition resource.hpp:198
std::uint32_t vertex_count
Number of vertices to draw.
Definition resource.hpp:192
std::uint32_t first_vertex
Index of the first vertex to draw. Essentially offsets gl_VertexIndex. (TODO: confirm that this is tr...
Definition resource.hpp:196
std::uint32_t instance_count
Number of instances to draw. If you're not doing GPU instancing, you probably want this to be 1.
Definition resource.hpp:194
Specifies creation flags for an image.
Definition resource.hpp:103
std::span< const std::byte > data
What initial data shall I have?
Definition resource.hpp:111
unsigned int height
Height of the image, in pixels.
Definition resource.hpp:107
image_flag flags
Any extra optional flags to specify?
Definition resource.hpp:115
unsigned int width
Width of the image, in pixels.
Definition resource.hpp:105
const char * name
What name shall I have when you're looking at me in your graphics debugger of choice?...
Definition resource.hpp:113
image_type type
Describes the format of the image data.
Definition resource.hpp:109