2#include <engine/engine_export.h>
9#include <unordered_set>
19 using ptr = std::shared_ptr<gpu_program>;
20 using wptr = std::weak_ptr<gpu_program>;
21 using uptr = std::unique_ptr<gpu_program>;
66 const hpp::string_view& sampler,
68 uint8_t attachment = 0,
69 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
80 const hpp::string_view& sampler,
82 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
91 void set_uniform(
const hpp::string_view&
name,
const void* value, std::uint16_t num = 1);
100 void set_uniform(
const hpp::string_view&
name,
const math::vec4& value, std::uint16_t num = 1);
109 void set_uniform(
const hpp::string_view&
name,
const math::vec3& value, std::uint16_t num = 1);
118 void set_uniform(
const hpp::string_view&
name,
const math::vec2& value, std::uint16_t num = 1);
163 std::array<
gfx::shader::
ptr, 2> shaders_cached_{
nullptr,
nullptr};
164 std::shared_ptr<gfx::program> program_;
185 if(uniform ==
nullptr)
187 uniform = std::make_shared<gfx::uniform>(std::string(
name),
type, num);
205void set_transform(
const std::vector<math::transform::mat4_t>& matrices);
213void set_transform(
const std::vector<math::transform>& matrices);
244 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
257 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
272 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
285 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
298 std::uint32_t flags = std::numeric_limits<std::uint32_t>::max());
std::shared_ptr< frame_buffer > ptr
Class representing a GPU program.
void set_uniform(const hpp::string_view &name, const math::vec2 &value, std::uint16_t num=1)
Sets a uniform value in the shader program.
gpu_program()=default
Default constructor.
std::shared_ptr< gpu_program > ptr
void attach_shader(asset_handle< gfx::shader > shader)
Attaches a shader to the GPU program.
std::weak_ptr< gpu_program > wptr
auto begin() -> bool
Begins usage of the program. Checks validity of attached shaders and recreates the internal program i...
void set_texture(std::uint8_t stage, const hpp::string_view &sampler, const gfx::texture *texture, std::uint32_t flags=std::numeric_limits< std::uint32_t >::max())
Sets the texture for a specific stage using a texture.
void populate()
Populates the GPU program.
void set_texture(std::uint8_t stage, const hpp::string_view &sampler, const gfx::frame_buffer *handle, uint8_t attachment=0, std::uint32_t flags=std::numeric_limits< std::uint32_t >::max())
Sets the texture for a specific stage using a frame buffer.
void set_uniform(const hpp::string_view &name, const void *value, std::uint16_t num=1)
Sets a uniform value in the shader program.
auto is_valid() const -> bool
Checks if the GPU program is valid.
void end()
Indicates the end of working with a program.
std::unique_ptr< gpu_program > uptr
void set_uniform(const hpp::string_view &name, const math::vec4 &value, std::uint16_t num=1)
Sets a uniform value in the shader program.
void set_uniform(const hpp::string_view &name, const math::vec3 &value, std::uint16_t num=1)
Sets a uniform value in the shader program.
auto native_handle() const -> gfx::program::handle_type_t
Retrieves the native handle of the internal shader program.
auto get_uniform(const hpp::string_view &name) -> gfx::program::uniform_ptr
Retrieves a uniform from the shader program.
auto get_shaders() const -> const std::vector< asset_handle< gfx::shader > > &
Retrieves the shader assets that created the shader program.
bgfx::Attachment attachment
void set_world_transform(const void *_mtx, uint16_t _num)
uint32_t set_transform(const void *_mtx, uint16_t _num)
bgfx::UniformType::Enum uniform_type
void set_uniform(uniform_handle _handle, const void *_value, uint16_t _num)
void set_texture(uint8_t _stage, uniform_handle _sampler, texture_handle _handle, uint32_t _flags)
Represents a handle to an asset, providing access and management functions.
std::shared_ptr< uniform > uniform_ptr