2023-01-14 17:38:59 +11:00
/*
librashader . h
SPDX - License - Identifier : MIT
This file is part of the librashader C headers .
Copyright 2022 chyyran
Permission is hereby granted , free of charge , to any person obtaining a copy of
this software and associated documentation files ( the " Software " ) , to deal in
the Software without restriction , including without limitation the rights to
use , copy , modify , merge , publish , distribute , sublicense , and / or sell copies of
the Software , and to permit persons to whom the Software is furnished to do so ,
subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software .
THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY , FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER LIABILITY , WHETHER
IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM , OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE .
*/
2023-01-27 11:05:48 +11:00
2022-12-04 10:32:10 +11:00
# ifndef __LIBRASHADER_H__
# define __LIBRASHADER_H__
# pragma once
# include <stdarg.h>
# include <stdbool.h>
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
2023-01-14 09:59:22 +11:00
# if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)
2022-12-05 16:06:37 +11:00
# include <d3d11.h>
# else
2023-01-27 11:05:48 +11:00
typedef void ID3D11Device ;
2023-02-11 10:08:11 +11:00
typedef void ID3D11DeviceContext ;
2023-01-27 11:05:48 +11:00
typedef void ID3D11RenderTargetView ;
typedef void ID3D11ShaderResourceView ;
2022-12-05 16:06:37 +11:00
# endif
2023-01-14 09:59:22 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
2023-01-15 19:01:23 +11:00
# include <vulkan\vulkan.h>
2023-01-27 11:05:48 +11:00
# else
typedef int32_t VkFormat ;
typedef uint64_t VkImage ;
typedef void * VkPhysicalDevice ;
typedef void * VkInstance ;
typedef void * VkCommandBuffer ;
2023-01-14 09:59:22 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)
# include <d3d12.h>
# else
typedef void ID3D12GraphicsCommandList ;
typedef void ID3D12Device ;
typedef void ID3D12Resource ;
typedef void D3D12_CPU_DESCRIPTOR_HANDLE ;
# endif
2022-12-04 10:32:10 +11:00
2023-01-27 11:05:48 +11:00
2022-12-05 14:37:03 +11:00
/// Error codes for librashader error types.
enum LIBRA_ERRNO
# ifdef __cplusplus
2023-02-09 13:21:40 +11:00
: int32_t
2023-01-21 16:31:29 +11:00
# endif // __cplusplus
2023-02-09 13:21:40 +11:00
{
LIBRA_ERRNO_UNKNOWN_ERROR = 0 ,
LIBRA_ERRNO_INVALID_PARAMETER = 1 ,
LIBRA_ERRNO_INVALID_STRING = 2 ,
LIBRA_ERRNO_PRESET_ERROR = 3 ,
LIBRA_ERRNO_PREPROCESS_ERROR = 4 ,
LIBRA_ERRNO_SHADER_PARAMETER_ERROR = 5 ,
LIBRA_ERRNO_REFLECT_ERROR = 6 ,
LIBRA_ERRNO_RUNTIME_ERROR = 7 ,
2022-12-05 14:37:03 +11:00
} ;
# ifndef __cplusplus
typedef int32_t LIBRA_ERRNO ;
2023-01-21 16:31:29 +11:00
# endif // __cplusplus
2022-12-05 14:37:03 +11:00
2023-01-14 08:05:13 +11:00
/// A Direct3D 11 filter chain.
2023-01-14 09:59:22 +11:00
typedef struct _filter_chain_d3d11 _filter_chain_d3d11 ;
2023-02-06 18:17:30 +11:00
/// A Direct3D 12 filter chain.
typedef struct _filter_chain_d3d12 _filter_chain_d3d12 ;
2023-01-14 09:59:22 +11:00
/// An OpenGL filter chain.
typedef struct _filter_chain_gl _filter_chain_gl ;
/// A Vulkan filter chain.
typedef struct _filter_chain_vk _filter_chain_vk ;
2022-12-04 10:32:10 +11:00
2022-12-05 14:37:03 +11:00
/// The error type for librashader.
2022-12-04 10:32:10 +11:00
typedef struct _libra_error _libra_error ;
2023-01-21 16:31:29 +11:00
/// A shader preset including all specified parameters, textures, and paths to specified shaders.
2022-12-05 14:37:03 +11:00
///
2023-01-21 16:31:29 +11:00
/// A shader preset can be used to create a filter chain runtime instance, or reflected to get
/// parameter metadata.
2022-12-04 10:32:10 +11:00
typedef struct _shader_preset _shader_preset ;
2023-01-14 10:10:09 +11:00
/// A handle to a librashader error object.
typedef struct _libra_error * libra_error_t ;
2022-12-04 10:32:10 +11:00
2023-01-14 10:10:09 +11:00
/// A handle to a shader preset object.
typedef struct _shader_preset * libra_shader_preset_t ;
2022-12-04 10:32:10 +11:00
2023-01-15 07:52:58 +11:00
/// A preset parameter.
typedef struct libra_preset_param_t {
2023-02-09 13:21:40 +11:00
/// The name of the parameter
const char * name ;
/// The description of the parameter.
const char * description ;
/// The initial value the parameter is set to.
float initial ;
/// The minimum value that the parameter can be set to.
float minimum ;
/// The maximum value that the parameter can be set to.
float maximum ;
/// The step by which this parameter can be incremented or decremented.
float step ;
2023-01-15 07:52:58 +11:00
} libra_preset_param_t ;
/// A list of preset parameters.
2023-01-21 15:43:45 +11:00
typedef struct libra_preset_param_list_t {
2023-02-09 13:21:40 +11:00
/// A pointer to the parameter
const struct libra_preset_param_t * parameters ;
/// The number of parameters in the list.
uint64_t length ;
/// For internal use only.
/// Changing this causes immediate undefined behaviour on freeing this parameter list.
uint64_t _internal_alloc ;
2023-01-21 15:43:45 +11:00
} libra_preset_param_list_t ;
2023-01-15 07:52:58 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2022-12-05 14:37:03 +11:00
/// A GL function loader that librashader needs to be initialized with.
2023-01-21 16:31:29 +11:00
typedef const void * ( * libra_gl_loader_t ) ( const char * ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:56:57 +11:00
2023-02-12 07:37:21 +11:00
/// API version type alias.
2023-02-10 15:36:09 +11:00
typedef size_t LIBRASHADER_API_VERSION ;
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 09:59:22 +11:00
/// Options for filter chain creation.
typedef struct filter_chain_gl_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// The GLSL version. Should be at least `330`.
2023-02-10 15:36:09 +11:00
uint16_t glsl_version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+.
bool use_dsa ;
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
bool force_no_mipmaps ;
2023-01-14 09:59:22 +11:00
} filter_chain_gl_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-01-14 08:05:13 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// A handle to a OpenGL filter chain.
typedef struct _filter_chain_gl * libra_gl_filter_chain_t ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:56:57 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2022-12-05 14:37:03 +11:00
/// OpenGL parameters for the source image.
2022-12-04 10:56:57 +11:00
typedef struct libra_source_image_gl_t {
2023-01-21 16:31:29 +11:00
/// A texture GLuint to the source image.
uint32_t handle ;
/// The format of the source image.
uint32_t format ;
/// The width of the source image.
uint32_t width ;
2023-01-28 10:17:35 +11:00
/// The height of the source image.
uint32_t height ;
2022-12-04 10:56:57 +11:00
} libra_source_image_gl_t ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:56:57 +11:00
2023-01-14 10:10:09 +11:00
/// Defines the output viewport for a rendered frame.
2022-12-04 10:56:57 +11:00
typedef struct libra_viewport_t {
2023-02-09 13:21:40 +11:00
/// The x offset in the viewport framebuffer to begin rendering from.
float x ;
/// The y offset in the viewport framebuffer to begin rendering from.
float y ;
/// The width of the viewport framebuffer.
uint32_t width ;
/// The height of the viewport framebuffer.
uint32_t height ;
2022-12-04 10:56:57 +11:00
} libra_viewport_t ;
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2022-12-05 14:37:03 +11:00
/// OpenGL parameters for the output framebuffer.
2023-02-09 13:21:40 +11:00
typedef struct libra_output_framebuffer_gl_t {
2023-01-21 16:31:29 +11:00
/// A framebuffer GLuint to the output framebuffer.
2023-02-11 15:31:10 +11:00
uint32_t fbo ;
2023-01-21 16:31:29 +11:00
/// A texture GLuint to the logical buffer of the output framebuffer.
uint32_t texture ;
/// The format of the output framebuffer.
uint32_t format ;
2023-02-09 13:21:40 +11:00
} libra_output_framebuffer_gl_t ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 09:59:22 +11:00
/// Options for each OpenGL shader frame.
typedef struct frame_gl_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to clear the history buffers.
bool clear_history ;
/// The direction of rendering.
/// -1 indicates that the frames are played in reverse order.
int32_t frame_direction ;
2023-01-14 09:59:22 +11:00
} frame_gl_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-01-14 09:59:22 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Handles required to instantiate vulkan
typedef struct libra_device_vk_t {
2023-01-21 16:31:29 +11:00
/// A raw `VkPhysicalDevice` handle
/// for the physical device that will perform rendering.
VkPhysicalDevice physical_device ;
/// A raw `VkInstance` handle
/// for the Vulkan instance that will perform rendering.
VkInstance instance ;
/// A raw `VkDevice` handle
/// for the device attached to the instance that will perform rendering.
VkDevice device ;
/// The entry loader for the Vulkan library.
PFN_vkGetInstanceProcAddr entry ;
2023-01-14 09:59:22 +11:00
} libra_device_vk_t ;
# endif
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
2023-01-14 09:59:22 +11:00
/// Options for filter chain creation.
typedef struct filter_chain_vk_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
size_t version ;
2023-02-09 13:21:40 +11:00
/// The number of frames in flight to keep. If zero, defaults to three.
uint32_t frames_in_flight ;
/// Whether or not to explicitly disable mipmap generation regardless of shader preset settings.
bool force_no_mipmaps ;
/// Use explicit render pass objects It is recommended if possible to use dynamic rendering,
/// because render-pass mode will create new framebuffers per pass.
bool use_render_pass ;
2023-01-14 09:59:22 +11:00
} filter_chain_vk_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-01-14 09:59:22 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
2023-01-14 10:10:09 +11:00
/// A handle to a Vulkan filter chain.
typedef struct _filter_chain_vk * libra_vk_filter_chain_t ;
2023-01-14 09:59:22 +11:00
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
2023-01-28 10:17:35 +11:00
/// Vulkan parameters for the source image.
2023-02-09 13:21:40 +11:00
typedef struct libra_source_image_vk_t {
2023-01-21 16:31:29 +11:00
/// A raw `VkImage` handle to the source image.
VkImage handle ;
/// The `VkFormat` of the source image.
VkFormat format ;
/// The width of the source image.
uint32_t width ;
2023-01-28 10:17:35 +11:00
/// The height of the source image.
uint32_t height ;
2023-02-09 13:21:40 +11:00
} libra_source_image_vk_t ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Vulkan parameters for the output image.
typedef struct libra_output_image_vk_t {
/// A raw `VkImage` handle to the output image.
VkImage handle ;
/// The `VkFormat` of the output image.
VkFormat format ;
} libra_output_image_vk_t ;
2023-01-14 09:59:22 +11:00
# endif
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Options for each OpenGL shader frame.
2023-01-21 16:15:09 +11:00
typedef struct frame_vk_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
size_t version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to clear the history buffers.
bool clear_history ;
/// The direction of rendering.
/// -1 indicates that the frames are played in reverse order.
int32_t frame_direction ;
2023-01-21 16:15:09 +11:00
} frame_vk_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-01-14 09:59:22 +11:00
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Options for Direct3D 11 filter chain creation.
2023-02-06 18:17:30 +11:00
typedef struct filter_chain_d3d11_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to explicitly disable mipmap
/// generation regardless of shader preset settings.
bool force_no_mipmaps ;
2023-02-06 18:17:30 +11:00
} filter_chain_d3d11_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// A handle to a Direct3D 11 filter chain.
typedef struct _filter_chain_d3d11 * libra_d3d11_filter_chain_t ;
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Direct3D 11 parameters for the source image.
typedef struct libra_source_image_d3d11_t {
/// A shader resource view into the source image
2023-02-11 10:08:11 +11:00
ID3D11ShaderResourceView * handle ;
2023-02-06 18:17:30 +11:00
/// The width of the source image.
uint32_t width ;
/// The height of the source image.
uint32_t height ;
} libra_source_image_d3d11_t ;
# endif
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Options for each Direct3D 11 shader frame.
2023-02-06 18:17:30 +11:00
typedef struct frame_d3d11_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to clear the history buffers.
bool clear_history ;
/// The direction of rendering.
/// -1 indicates that the frames are played in reverse order.
int32_t frame_direction ;
2023-02-06 18:17:30 +11:00
} frame_d3d11_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-02-06 18:17:30 +11:00
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-02-06 18:17:30 +11:00
/// Options for Direct3D11 filter chain creation.
typedef struct filter_chain_d3d12_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// Force the HLSL shader pipeline. This may reduce shader compatibility.
bool force_hlsl_pipeline ;
/// Whether or not to explicitly disable mipmap
/// generation for intermediate passes regardless
/// of shader preset settings.
bool force_no_mipmaps ;
2023-02-06 18:17:30 +11:00
} filter_chain_d3d12_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// A handle to a Direct3D 12 filter chain.
typedef struct _filter_chain_d3d12 * libra_d3d12_filter_chain_t ;
# endif
# if defined(LIBRA_RUNTIME_D3D12)
2023-02-09 13:21:40 +11:00
/// Direct3D 12 parameters for the source image.
2023-02-06 18:17:30 +11:00
typedef struct libra_source_image_d3d12_t {
/// The resource containing the image.
2023-02-11 10:08:11 +11:00
ID3D12Resource * resource ;
2023-02-06 18:17:30 +11:00
/// A CPU descriptor handle to a shader resource view of the image.
D3D12_CPU_DESCRIPTOR_HANDLE descriptor ;
/// The format of the image.
DXGI_FORMAT format ;
/// The width of the source image.
uint32_t width ;
/// The height of the source image.
uint32_t height ;
} libra_source_image_d3d12_t ;
# endif
2023-02-09 13:21:40 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// Direct3D 12 parameters for the output image.
typedef struct libra_output_image_d3d12_t {
/// A CPU descriptor handle to a shader resource view of the image.
D3D12_CPU_DESCRIPTOR_HANDLE descriptor ;
/// The format of the image.
DXGI_FORMAT format ;
} libra_output_image_d3d12_t ;
# endif
2023-02-10 15:36:09 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// Options for each Direct3D 12 shader frame.
2023-02-06 18:17:30 +11:00
typedef struct frame_d3d12_opt_t {
2023-02-10 15:36:09 +11:00
/// The librashader API version.
LIBRASHADER_API_VERSION version ;
2023-02-09 13:21:40 +11:00
/// Whether or not to clear the history buffers.
bool clear_history ;
/// The direction of rendering.
/// -1 indicates that the frames are played in reverse order.
int32_t frame_direction ;
2023-02-06 18:17:30 +11:00
} frame_d3d12_opt_t ;
2023-02-10 15:36:09 +11:00
# endif
2023-02-06 18:17:30 +11:00
2023-02-12 07:37:21 +11:00
typedef size_t LIBRASHADER_ABI_VERSION ;
/// Function pointer definition for libra_abi_version
typedef LIBRASHADER_ABI_VERSION ( * PFN_libra_instance_abi_version ) ( void ) ;
/// Function pointer definition for libra_abi_version
typedef LIBRASHADER_API_VERSION ( * PFN_libra_instance_api_version ) ( void ) ;
2023-01-14 11:17:57 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_create
typedef libra_error_t ( * PFN_libra_preset_create ) ( const char * filename , libra_shader_preset_t * out ) ;
2023-01-14 11:17:57 +11:00
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_free
2023-01-14 10:10:09 +11:00
typedef libra_error_t ( * PFN_libra_preset_free ) ( libra_shader_preset_t * preset ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_set_param
typedef libra_error_t ( * PFN_libra_preset_set_param ) ( libra_shader_preset_t * preset ,
const char * name ,
float value ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_get_param
typedef libra_error_t ( * PFN_libra_preset_get_param ) ( libra_shader_preset_t * preset ,
const char * name ,
float * value ) ;
2022-12-04 10:32:10 +11:00
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_print
2023-01-14 10:10:09 +11:00
typedef libra_error_t ( * PFN_libra_preset_print ) ( libra_shader_preset_t * preset ) ;
2022-12-04 10:32:10 +11:00
2023-01-15 09:14:37 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_get_runtime_params
typedef libra_error_t ( * PFN_libra_preset_get_runtime_params ) ( libra_shader_preset_t * preset ,
struct libra_preset_param_list_t * out ) ;
2023-01-21 15:43:45 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_preset_free_runtime_params
typedef libra_error_t ( * PFN_libra_preset_free_runtime_params ) ( struct libra_preset_param_list_t preset ) ;
2023-01-15 09:14:37 +11:00
2023-01-14 11:17:57 +11:00
/// Function pointer definition for libra_error_errno
2023-01-14 10:10:09 +11:00
typedef LIBRA_ERRNO ( * PFN_libra_error_errno ) ( libra_error_t error ) ;
2022-12-04 10:32:10 +11:00
2023-01-14 11:17:57 +11:00
/// Function pointer definition for libra_error_print
2023-01-14 10:10:09 +11:00
typedef int32_t ( * PFN_libra_error_print ) ( libra_error_t error ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 11:17:57 +11:00
/// Function pointer definition for libra_error_free
2023-01-14 10:10:09 +11:00
typedef int32_t ( * PFN_libra_error_free ) ( libra_error_t * error ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 11:17:57 +11:00
/// Function pointer definition for libra_error_write
2023-01-14 10:10:09 +11:00
typedef int32_t ( * PFN_libra_error_write ) ( libra_error_t error , char * * out ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 11:17:57 +11:00
/// Function pointer definition for libra_error_free_string
2023-01-14 10:10:09 +11:00
typedef int32_t ( * PFN_libra_error_free_string ) ( char * * out ) ;
2022-12-05 16:06:37 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_init_context
2023-01-14 10:10:09 +11:00
typedef libra_error_t ( * PFN_libra_gl_init_context ) ( libra_gl_loader_t loader ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_create
typedef libra_error_t ( * PFN_libra_gl_filter_chain_create ) ( libra_shader_preset_t * preset ,
const struct filter_chain_gl_opt_t * options ,
libra_gl_filter_chain_t * out ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_frame
typedef libra_error_t ( * PFN_libra_gl_filter_chain_frame ) ( libra_gl_filter_chain_t * chain ,
size_t frame_count ,
struct libra_source_image_gl_t image ,
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_framebuffer_gl_t out ,
2023-01-21 16:31:29 +11:00
const float * mvp ,
const struct frame_gl_opt_t * opt ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-01-15 07:52:58 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_set_param
typedef libra_error_t ( * PFN_libra_gl_filter_chain_set_param ) ( libra_gl_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_get_param
typedef libra_error_t ( * PFN_libra_gl_filter_chain_get_param ) ( libra_gl_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_set_active_pass_count
typedef libra_error_t ( * PFN_libra_gl_filter_chain_set_active_pass_count ) ( libra_gl_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_get_active_pass_count
typedef libra_error_t ( * PFN_libra_gl_filter_chain_get_active_pass_count ) ( libra_gl_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_gl_filter_chain_free
typedef libra_error_t ( * PFN_libra_gl_filter_chain_free ) ( libra_gl_filter_chain_t * chain ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_create
2023-02-11 19:46:42 +11:00
typedef libra_error_t ( * PFN_libra_vk_filter_chain_create ) ( libra_shader_preset_t * preset ,
struct libra_device_vk_t vulkan ,
2023-02-06 18:17:30 +11:00
const struct filter_chain_vk_opt_t * options ,
libra_vk_filter_chain_t * out ) ;
# endif
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_create_deferred
typedef libra_error_t ( * PFN_libra_vk_filter_chain_create_deferred ) ( libra_shader_preset_t * preset ,
struct libra_device_vk_t vulkan ,
VkCommandBuffer command_buffer ,
const struct filter_chain_vk_opt_t * options ,
libra_vk_filter_chain_t * out ) ;
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_frame
typedef libra_error_t ( * PFN_libra_vk_filter_chain_frame ) ( libra_vk_filter_chain_t * chain ,
VkCommandBuffer command_buffer ,
size_t frame_count ,
2023-02-09 13:21:40 +11:00
struct libra_source_image_vk_t image ,
2023-02-06 18:17:30 +11:00
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_image_vk_t out ,
2023-02-06 18:17:30 +11:00
const float * mvp ,
const struct frame_vk_opt_t * opt ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_set_param
typedef libra_error_t ( * PFN_libra_vk_filter_chain_set_param ) ( libra_vk_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_get_param
typedef libra_error_t ( * PFN_libra_vk_filter_chain_get_param ) ( libra_vk_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_set_active_pass_count
typedef libra_error_t ( * PFN_libra_vk_filter_chain_set_active_pass_count ) ( libra_vk_filter_chain_t * chain ,
uint32_t value ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_get_active_pass_count
typedef libra_error_t ( * PFN_libra_vk_filter_chain_get_active_pass_count ) ( libra_vk_filter_chain_t * chain ,
uint32_t * out ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Function pointer definition for
///libra_vk_filter_chain_free
typedef libra_error_t ( * PFN_libra_vk_filter_chain_free ) ( libra_vk_filter_chain_t * chain ) ;
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_create
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_create ) ( libra_shader_preset_t * preset ,
2023-02-11 10:08:11 +11:00
ID3D11Device * device ,
2023-02-11 19:46:42 +11:00
const struct filter_chain_d3d11_opt_t * options ,
2023-01-21 16:31:29 +11:00
libra_d3d11_filter_chain_t * out ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Function pointer definition for
///libra_d3d11_filter_chain_create_deferred
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_create_deferred ) ( libra_shader_preset_t * preset ,
ID3D11Device * device ,
ID3D11DeviceContext * device_context ,
const struct filter_chain_d3d11_opt_t * options ,
libra_d3d11_filter_chain_t * out ) ;
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_frame
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_frame ) ( libra_d3d11_filter_chain_t * chain ,
2023-02-11 10:08:11 +11:00
ID3D11DeviceContext * device_context ,
2023-01-21 16:31:29 +11:00
size_t frame_count ,
struct libra_source_image_d3d11_t image ,
struct libra_viewport_t viewport ,
2023-02-11 10:08:11 +11:00
ID3D11RenderTargetView * out ,
2023-01-21 16:31:29 +11:00
const float * mvp ,
2023-02-11 19:46:42 +11:00
const struct frame_d3d11_opt_t * options ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 16:06:37 +11:00
2023-01-15 07:52:58 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_set_param
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_set_param ) ( libra_d3d11_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_get_param
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_get_param ) ( libra_d3d11_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_set_active_pass_count
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_set_active_pass_count ) ( libra_d3d11_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_get_active_pass_count
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_get_active_pass_count ) ( libra_d3d11_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Function pointer definition for
2023-01-21 16:31:29 +11:00
///libra_d3d11_filter_chain_free
typedef libra_error_t ( * PFN_libra_d3d11_filter_chain_free ) ( libra_d3d11_filter_chain_t * chain ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-14 11:17:57 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_create
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_create ) ( libra_shader_preset_t * preset ,
2023-02-11 10:08:11 +11:00
ID3D12Device * device ,
2023-02-11 19:46:42 +11:00
const struct filter_chain_d3d12_opt_t * options ,
2023-02-06 18:17:30 +11:00
libra_d3d12_filter_chain_t * out ) ;
2023-01-14 11:17:57 +11:00
# endif
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// Function pointer definition for
///libra_d3d12_filter_chain_create_deferred
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_create_deferred ) ( libra_shader_preset_t * preset ,
ID3D12Device * device ,
ID3D12GraphicsCommandList * command_list ,
const struct filter_chain_d3d12_opt_t * options ,
libra_d3d12_filter_chain_t * out ) ;
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-14 11:17:57 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_frame
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_frame ) ( libra_d3d12_filter_chain_t * chain ,
2023-02-11 10:08:11 +11:00
ID3D12GraphicsCommandList * command_list ,
2023-02-06 18:17:30 +11:00
size_t frame_count ,
struct libra_source_image_d3d12_t image ,
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_image_d3d12_t out ,
2023-02-06 18:17:30 +11:00
const float * mvp ,
2023-02-10 15:36:09 +11:00
const struct frame_d3d12_opt_t * options ) ;
2023-01-14 11:17:57 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_set_param
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_set_param ) ( libra_d3d12_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_get_param
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_get_param ) ( libra_d3d12_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_set_active_pass_count
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_set_active_pass_count ) ( libra_d3d12_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_get_active_pass_count
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_get_active_pass_count ) ( libra_d3d12_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-14 11:17:57 +11:00
/// Function pointer definition for
2023-02-06 18:17:30 +11:00
///libra_d3d12_filter_chain_free
typedef libra_error_t ( * PFN_libra_d3d12_filter_chain_free ) ( libra_d3d12_filter_chain_t * chain ) ;
2023-01-14 11:17:57 +11:00
# endif
2023-02-12 07:37:21 +11:00
/// The current version of the librashader API.
2023-02-10 15:36:09 +11:00
/// Pass this into `version` for config structs.
2023-02-12 07:37:21 +11:00
///
/// API versions are backwards compatible. It is valid to load
/// a librashader C API instance for all API versions less than
/// or equal to LIBRASHADER_CURRENT_VERSION, and subsequent API
/// versions must remain backwards compatible.
/// ## API Versions
/// - API version 0: 0.1.0
2023-02-10 15:36:09 +11:00
# define LIBRASHADER_CURRENT_VERSION 0
2023-02-12 07:37:21 +11:00
/// The current version of the librashader ABI.
/// Used by the loader to check ABI compatibility.
///
/// ABI version 0 is reserved as a sentinel value.
///
/// ABI versions are not backwards compatible. It is not
/// valid to load a librashader C API instance for any ABI
/// version not equal to LIBRASHADER_CURRENT_ABI.
/// ## ABI Versions
/// - ABI version 1: 0.1.0
# define LIBRASHADER_CURRENT_ABI 1
2022-12-04 10:32:10 +11:00
# ifdef __cplusplus
extern " C " {
2023-01-21 16:31:29 +11:00
# endif // __cplusplus
2022-12-04 10:32:10 +11:00
2023-01-14 10:10:09 +11:00
/// Get the error code corresponding to this error object.
///
/// ## Safety
/// - `error` must be valid and initialized.
LIBRA_ERRNO libra_error_errno ( libra_error_t error ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Print the error message.
///
2023-01-21 16:31:29 +11:00
/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0.
2023-01-14 10:10:09 +11:00
/// ## Safety
/// - `error` must be a valid and initialized instance of `libra_error_t`.
int32_t libra_error_print ( libra_error_t error ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Frees any internal state kept by the error.
///
2023-01-21 16:31:29 +11:00
/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0.
/// The resulting error object becomes null.
2023-01-14 10:10:09 +11:00
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `error` must be null or a pointer to a valid and initialized instance of `libra_error_t`.
2023-01-14 10:10:09 +11:00
int32_t libra_error_free ( libra_error_t * error ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Writes the error message into `out`
///
2023-01-21 16:31:29 +11:00
/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0.
2023-01-14 10:10:09 +11:00
/// ## Safety
/// - `error` must be a valid and initialized instance of `libra_error_t`.
2023-01-21 16:31:29 +11:00
/// - `out` must be a non-null pointer. The resulting string must not be modified.
int32_t libra_error_write ( libra_error_t error ,
char * * out ) ;
2023-01-14 10:10:09 +11:00
/// Frees an error string previously allocated by `libra_error_write`.
///
/// After freeing, the pointer will be set to null.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - If `libra_error_write` is not null, it must point to a string previously returned by `libra_error_write`.
/// Attempting to free anything else, including strings or objects from other librashader functions, is immediate
/// Undefined Behaviour.
2023-01-14 10:10:09 +11:00
int32_t libra_error_free_string ( char * * out ) ;
/// Load a preset.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `filename` must be either null or a valid, aligned pointer to a string path to the shader preset.
/// - `out` must be either null, or an aligned pointer to an uninitialized or invalid `libra_shader_preset_t`.
2023-01-14 10:10:09 +11:00
/// ## Returns
2023-01-21 16:31:29 +11:00
/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`.
2023-01-14 10:10:09 +11:00
libra_error_t libra_preset_create ( const char * filename ,
libra_shader_preset_t * out ) ;
/// Free the preset.
///
2023-01-21 16:31:29 +11:00
/// If `preset` is null, this function does nothing. The resulting value in `preset` then becomes
/// null.
2023-01-14 10:10:09 +11:00
///
/// ## Safety
/// - `preset` must be a valid and aligned pointer to a shader preset.
libra_error_t libra_preset_free ( libra_shader_preset_t * preset ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Set the value of the parameter in the preset.
///
/// ## Safety
/// - `preset` must be null or a valid and aligned pointer to a shader preset.
/// - `name` must be null or a valid and aligned pointer to a string.
2023-01-21 16:31:29 +11:00
libra_error_t libra_preset_set_param ( libra_shader_preset_t * preset , const char * name , float value ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Get the value of the parameter as set in the preset.
///
/// ## Safety
/// - `preset` must be null or a valid and aligned pointer to a shader preset.
/// - `name` must be null or a valid and aligned pointer to a string.
/// - `value` may be a pointer to a uninitialized `float`.
2023-01-21 16:31:29 +11:00
libra_error_t libra_preset_get_param ( libra_shader_preset_t * preset , const char * name , float * value ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 10:10:09 +11:00
/// Pretty print the shader preset.
///
/// ## Safety
/// - `preset` must be null or a valid and aligned pointer to a shader preset.
libra_error_t libra_preset_print ( libra_shader_preset_t * preset ) ;
2023-01-14 08:05:13 +11:00
2023-01-21 15:43:45 +11:00
/// Get a list of runtime parameters.
2023-01-14 10:10:09 +11:00
///
2023-01-15 07:52:58 +11:00
/// ## Safety
/// - `preset` must be null or a valid and aligned pointer to a shader preset.
/// - `out` must be an aligned pointer to a `libra_preset_parameter_list_t`.
2023-01-21 16:31:29 +11:00
/// - The output struct should be treated as immutable. Mutating any struct fields
2023-01-21 15:43:45 +11:00
/// in the returned struct may at best cause memory leaks, and at worse
/// cause undefined behaviour when later freed.
2023-01-21 16:31:29 +11:00
/// - It is safe to call `libra_preset_get_runtime_params` multiple times, however
2023-01-21 15:43:45 +11:00
/// the output struct must only be freed once per call.
2023-01-21 16:31:29 +11:00
libra_error_t libra_preset_get_runtime_params ( libra_shader_preset_t * preset ,
struct libra_preset_param_list_t * out ) ;
2023-01-21 15:43:45 +11:00
/// Free the runtime parameters.
///
/// Unlike the other `free` functions provided by librashader,
/// `libra_preset_free_runtime_params` takes the struct directly.
/// The caller must take care to maintain the lifetime of any pointers
/// contained within the input `libra_preset_param_list_t`.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - Any pointers rooted at `parameters` becomes invalid after this function returns,
/// including any strings accessible via the input `libra_preset_param_list_t`.
/// The caller must ensure that there are no live pointers, aliased or unaliased,
/// to data accessible via the input `libra_preset_param_list_t`.
///
/// - Accessing any data pointed to via the input `libra_preset_param_list_t` after it
2023-01-21 15:43:45 +11:00
/// has been freed is a use-after-free and is immediate undefined behaviour.
///
2023-01-21 16:31:29 +11:00
/// - If any struct fields of the input `libra_preset_param_list_t` was modified from
/// their values given after `libra_preset_get_runtime_params`, this may result
/// in undefined behaviour.
libra_error_t libra_preset_free_runtime_params ( struct libra_preset_param_list_t preset ) ;
2023-01-14 08:05:13 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Initialize the OpenGL Context for librashader.
///
2023-01-21 15:43:45 +11:00
/// This only has to be done once throughout the lifetime of the application,
/// unless for whatever reason you switch OpenGL loaders mid-flight.
///
2023-01-14 10:10:09 +11:00
/// ## Safety
2023-01-21 16:31:29 +11:00
/// Attempting to create a filter chain will fail if the GL context is not initialized.
2023-01-14 10:10:09 +11:00
///
2023-01-21 16:31:29 +11:00
/// Reinitializing the OpenGL context with a different loader immediately invalidates previous filter
/// chain objects, and drawing with them causes immediate undefined behaviour.
2023-01-14 10:10:09 +11:00
libra_error_t libra_gl_init_context ( libra_gl_loader_t loader ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
2023-01-21 16:31:29 +11:00
libra_error_t libra_gl_filter_chain_create ( libra_shader_preset_t * preset ,
const struct filter_chain_gl_opt_t * options ,
libra_gl_filter_chain_t * out ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Draw a frame with the given parameters for the given filter chain.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or invalid, this
2023-01-14 10:10:09 +11:00
/// function will return an error.
2023-01-21 16:31:29 +11:00
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to 16 consecutive `float`
2023-01-14 10:10:09 +11:00
/// values for the model view projection matrix.
2023-01-21 16:31:29 +11:00
/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_gl_opt_t`
2023-01-14 10:10:09 +11:00
/// struct.
2023-02-10 17:29:49 +11:00
/// - You must ensure that only one thread has access to `chain` before you call this function. Only one
/// thread at a time may call this function. The thread `libra_gl_filter_chain_frame` is called from
/// must have its thread-local OpenGL context initialized with the same context used to create
/// the filter chain.
2023-01-21 16:31:29 +11:00
libra_error_t libra_gl_filter_chain_frame ( libra_gl_filter_chain_t * chain ,
size_t frame_count ,
struct libra_source_image_gl_t image ,
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_framebuffer_gl_t out ,
2023-01-21 16:31:29 +11:00
const float * mvp ,
const struct frame_gl_opt_t * opt ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-01-15 07:52:58 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
libra_error_t libra_gl_filter_chain_set_param ( libra_gl_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
libra_error_t libra_gl_filter_chain_get_param ( libra_gl_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Sets the number of active passes for this chain.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
libra_error_t libra_gl_filter_chain_set_active_pass_count ( libra_gl_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_OPENGL)
/// Gets the number of active passes for this chain.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
libra_error_t libra_gl_filter_chain_get_active_pass_count ( libra_gl_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_OPENGL)
2023-01-14 10:10:09 +11:00
/// Free a GL filter chain.
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
2023-01-14 10:10:09 +11:00
libra_error_t libra_gl_filter_chain_free ( libra_gl_filter_chain_t * chain ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - The handles provided in `vulkan` must be valid for the command buffers that
/// `libra_vk_filter_chain_frame` will write to. Namely, the VkDevice must have been
/// created with the `VK_KHR_dynamic_rendering` extension.
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
2023-02-11 19:46:42 +11:00
libra_error_t libra_vk_filter_chain_create ( libra_shader_preset_t * preset ,
struct libra_device_vk_t vulkan ,
2023-02-06 18:17:30 +11:00
const struct filter_chain_vk_opt_t * options ,
libra_vk_filter_chain_t * out ) ;
# endif
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Create the filter chain given the shader preset deferring and GPU-side initialization
/// to the caller. This function therefore requires no external synchronization of the device queue.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - The handles provided in `vulkan` must be valid for the command buffers that
/// `libra_vk_filter_chain_frame` will write to. Namely, the VkDevice must have been
/// created with the `VK_KHR_dynamic_rendering` extension.
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
///
/// The provided command buffer must be ready for recording and contain no prior commands.
/// The caller is responsible for ending the command buffer and immediately submitting it to a
/// graphics queue. The command buffer must be completely executed before calling `libra_vk_filter_chain_frame`.
libra_error_t libra_vk_filter_chain_create_deferred ( libra_shader_preset_t * preset ,
struct libra_device_vk_t vulkan ,
VkCommandBuffer command_buffer ,
const struct filter_chain_vk_opt_t * options ,
libra_vk_filter_chain_t * out ) ;
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_VULKAN)
/// Records rendering commands for a frame with the given parameters for the given filter chain
/// to the input command buffer.
///
2023-02-11 10:08:11 +11:00
/// * The input image must be in the `VK_SHADER_READ_ONLY_OPTIMAL` layout.
/// * The output image must be in `VK_COLOR_ATTACHMENT_OPTIMAL` layout.
///
/// librashader **will not** create a pipeline barrier for the final pass. The output image will
/// remain in `VK_COLOR_ATTACHMENT_OPTIMAL` after all shader passes. The caller must transition
/// the output image to the final layout.
2023-02-06 18:17:30 +11:00
///
/// ## Safety
/// - `libra_vk_filter_chain_frame` **must not be called within a RenderPass**.
/// - `command_buffer` must be a valid handle to a `VkCommandBuffer` that is ready for recording.
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or invalid, this
/// function will return an error.
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to 16 consecutive `float`
/// values for the model view projection matrix.
/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_vk_opt_t`
/// struct.
2023-02-10 17:29:49 +11:00
/// - You must ensure that only one thread has access to `chain` before you call this function. Only one
/// thread at a time may call this function.
2023-02-06 18:17:30 +11:00
libra_error_t libra_vk_filter_chain_frame ( libra_vk_filter_chain_t * chain ,
VkCommandBuffer command_buffer ,
size_t frame_count ,
2023-02-09 13:21:40 +11:00
struct libra_source_image_vk_t image ,
2023-02-06 18:17:30 +11:00
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_image_vk_t out ,
2023-02-06 18:17:30 +11:00
const float * mvp ,
const struct frame_vk_opt_t * opt ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
libra_error_t libra_vk_filter_chain_set_param ( libra_vk_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
/// - `param_name` must be either null or a null terminated string.
libra_error_t libra_vk_filter_chain_get_param ( libra_vk_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Sets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
libra_error_t libra_vk_filter_chain_set_active_pass_count ( libra_vk_filter_chain_t * chain ,
uint32_t value ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Gets the number of active passes for this chain.
///
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
libra_error_t libra_vk_filter_chain_get_active_pass_count ( libra_vk_filter_chain_t * chain ,
uint32_t * out ) ;
# endif
# if defined(LIBRA_RUNTIME_VULKAN)
/// Free a Vulkan filter chain.
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
libra_error_t libra_vk_filter_chain_free ( libra_vk_filter_chain_t * chain ) ;
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
2023-01-27 11:05:48 +11:00
/// - `device` must not be null.
2023-01-14 10:10:09 +11:00
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
2023-01-21 16:31:29 +11:00
libra_error_t libra_d3d11_filter_chain_create ( libra_shader_preset_t * preset ,
2023-02-11 10:08:11 +11:00
ID3D11Device * device ,
2023-02-11 19:46:42 +11:00
const struct filter_chain_d3d11_opt_t * options ,
2023-01-21 16:31:29 +11:00
libra_d3d11_filter_chain_t * out ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 10:32:10 +11:00
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Create the filter chain given the shader preset, deferring and GPU-side initialization
/// to the caller. This function is therefore requires no external synchronization of the
/// immediate context, as long as the immediate context is not used as the input context,
/// nor of the device, as long as the device is not single-threaded only.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `device` must not be null.
/// - `device_context` not be null.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
///
/// The provided context must either be immediate, or immediately submitted after this function
/// returns, **before drawing frames**, or lookup textures will fail to load and the filter chain
/// will be in an invalid state.
///
/// If the context is deferred, it must be ready for command recording, and have no prior commands
/// recorded. No commands shall be recorded after, the caller must immediately call [`FinishCommandList`](https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-finishcommandlist)
/// and execute the command list on the immediate context after this function returns.
///
/// If the context is immediate, then access to the immediate context requires external synchronization.
libra_error_t libra_d3d11_filter_chain_create_deferred ( libra_shader_preset_t * preset ,
ID3D11Device * device ,
ID3D11DeviceContext * device_context ,
const struct filter_chain_d3d11_opt_t * options ,
libra_d3d11_filter_chain_t * out ) ;
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Draw a frame with the given parameters for the given filter chain.
///
2023-02-11 10:08:11 +11:00
/// If `device_context` is null, then commands are recorded onto the immediate context. Otherwise,
/// it will record commands onto the provided context. If the context is deferred, librashader
/// will not finalize command lists. The context must otherwise be associated with the `ID3D11Device`
///
2023-01-14 10:10:09 +11:00
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or invalid, this
2023-01-14 10:10:09 +11:00
/// function will return an error.
2023-01-21 16:31:29 +11:00
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to 16 consecutive `float`
2023-01-14 10:10:09 +11:00
/// values for the model view projection matrix.
2023-01-21 16:31:29 +11:00
/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_gl_opt_t`
2023-01-14 10:10:09 +11:00
/// struct.
2023-01-27 11:05:48 +11:00
/// - `out` must not be null.
/// - `image.handle` must not be null.
2023-02-11 10:08:11 +11:00
/// - If `device_context` is null, commands will be recorded onto the immediate context of the `ID3D11Device`
/// this filter chain was created with. The context must otherwise be associated with the `ID3D11Device`
/// the filter chain was created with.
2023-02-10 17:29:49 +11:00
/// - You must ensure that only one thread has access to `chain` before you call this function. Only one
/// thread at a time may call this function.
2023-01-21 16:31:29 +11:00
libra_error_t libra_d3d11_filter_chain_frame ( libra_d3d11_filter_chain_t * chain ,
2023-02-11 10:08:11 +11:00
ID3D11DeviceContext * device_context ,
2023-01-21 16:31:29 +11:00
size_t frame_count ,
struct libra_source_image_d3d11_t image ,
struct libra_viewport_t viewport ,
2023-02-11 10:08:11 +11:00
ID3D11RenderTargetView * out ,
2023-01-21 16:31:29 +11:00
const float * mvp ,
2023-02-11 19:46:42 +11:00
const struct frame_d3d11_opt_t * options ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-04 11:55:27 +11:00
2023-01-15 07:52:58 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
2023-01-21 16:31:29 +11:00
libra_error_t libra_d3d11_filter_chain_set_param ( libra_d3d11_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
2023-01-21 16:31:29 +11:00
libra_error_t libra_d3d11_filter_chain_get_param ( libra_d3d11_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Sets the number of active passes for this chain.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
libra_error_t libra_d3d11_filter_chain_set_active_pass_count ( libra_d3d11_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
# if defined(LIBRA_RUNTIME_D3D11)
/// Gets the number of active passes for this chain.
///
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
libra_error_t libra_d3d11_filter_chain_get_active_pass_count ( libra_d3d11_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-01-14 08:10:54 +11:00
# if defined(LIBRA_RUNTIME_D3D11)
2023-01-14 10:10:09 +11:00
/// Free a D3D11 filter chain.
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
2023-01-14 10:10:09 +11:00
libra_error_t libra_d3d11_filter_chain_free ( libra_d3d11_filter_chain_t * chain ) ;
2023-01-14 08:05:13 +11:00
# endif
2022-12-05 15:54:47 +11:00
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-14 10:10:09 +11:00
/// Create the filter chain given the shader preset.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
2023-02-06 18:17:30 +11:00
/// - `device` must not be null.
2023-01-14 10:10:09 +11:00
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
2023-02-06 18:17:30 +11:00
libra_error_t libra_d3d12_filter_chain_create ( libra_shader_preset_t * preset ,
2023-02-11 10:08:11 +11:00
ID3D12Device * device ,
2023-02-11 19:46:42 +11:00
const struct filter_chain_d3d12_opt_t * options ,
2023-02-06 18:17:30 +11:00
libra_d3d12_filter_chain_t * out ) ;
2023-01-14 09:59:22 +11:00
# endif
2023-02-11 19:46:42 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// Create the filter chain given the shader preset deferring and GPU-side initialization
/// to the caller. This function therefore requires no external synchronization of the device queue.
///
/// The shader preset is immediately invalidated and must be recreated after
/// the filter chain is created.
///
/// ## Safety:
/// - `preset` must be either null, or valid and aligned.
/// - `options` must be either null, or valid and aligned.
/// - `device` must not be null.
/// - `out` must be aligned, but may be null, invalid, or uninitialized.
/// - `cmd` must not be null.
///
/// The provided command list must be ready for recording and contain no prior commands.
/// The caller is responsible for ending the command list and immediately submitting it to a
/// graphics queue. The command list must be completely executed before calling `libra_d3d12_filter_chain_frame`.
libra_error_t libra_d3d12_filter_chain_create_deferred ( libra_shader_preset_t * preset ,
ID3D12Device * device ,
ID3D12GraphicsCommandList * command_list ,
const struct filter_chain_d3d12_opt_t * options ,
libra_d3d12_filter_chain_t * out ) ;
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-21 16:31:29 +11:00
/// Records rendering commands for a frame with the given parameters for the given filter chain
2023-02-06 18:17:30 +11:00
/// to the input command list.
2023-01-14 10:10:09 +11:00
///
2023-02-11 10:08:11 +11:00
/// * The input image must be in the `D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE` resource state.
/// * The output image must be in `D3D12_RESOURCE_STATE_RENDER_TARGET` resource state.
///
/// librashader **will not** create a resource barrier for the final pass. The output image will
/// remain in `D3D12_RESOURCE_STATE_RENDER_TARGET` after all shader passes. The caller must transition
/// the output image to the final resource state.
///
2023-01-14 10:10:09 +11:00
/// ## Safety
2023-01-21 16:31:29 +11:00
/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or invalid, this
2023-01-14 10:10:09 +11:00
/// function will return an error.
2023-01-21 16:31:29 +11:00
/// - `mvp` may be null, or if it is not null, must be an aligned pointer to 16 consecutive `float`
2023-01-14 10:10:09 +11:00
/// values for the model view projection matrix.
2023-02-06 18:17:30 +11:00
/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_gl_opt_t`
2023-01-14 10:10:09 +11:00
/// struct.
2023-02-06 18:17:30 +11:00
/// - `out` must be a descriptor handle to a render target view.
/// - `image.resource` must not be null.
2023-02-11 10:08:11 +11:00
/// - `command_list` must be a non-null pointer to a `ID3D12GraphicsCommandList` that is open,
/// and must be associated with the `ID3D12Device` this filter chain was created with.
2023-02-10 17:29:49 +11:00
/// - You must ensure that only one thread has access to `chain` before you call this function. Only one
/// thread at a time may call this function.
2023-02-06 18:17:30 +11:00
libra_error_t libra_d3d12_filter_chain_frame ( libra_d3d12_filter_chain_t * chain ,
2023-02-11 10:08:11 +11:00
ID3D12GraphicsCommandList * command_list ,
2023-02-06 18:17:30 +11:00
size_t frame_count ,
struct libra_source_image_d3d12_t image ,
struct libra_viewport_t viewport ,
2023-02-09 13:21:40 +11:00
struct libra_output_image_d3d12_t out ,
2023-02-06 18:17:30 +11:00
const float * mvp ,
2023-02-10 15:36:09 +11:00
const struct frame_d3d12_opt_t * options ) ;
2023-01-14 09:59:22 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Sets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-02-06 18:17:30 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
2023-02-06 18:17:30 +11:00
libra_error_t libra_d3d12_filter_chain_set_param ( libra_d3d12_filter_chain_t * chain ,
const char * param_name ,
float value ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Gets a parameter for the filter chain.
///
/// If the parameter does not exist, returns an error.
/// ## Safety
2023-02-06 18:17:30 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
2023-01-15 07:52:58 +11:00
/// - `param_name` must be either null or a null terminated string.
2023-02-06 18:17:30 +11:00
libra_error_t libra_d3d12_filter_chain_get_param ( libra_d3d12_filter_chain_t * chain ,
const char * param_name ,
float * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Sets the number of active passes for this chain.
///
/// ## Safety
2023-02-06 18:17:30 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
libra_error_t libra_d3d12_filter_chain_set_active_pass_count ( libra_d3d12_filter_chain_t * chain ,
uint32_t value ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
2023-01-15 07:52:58 +11:00
/// Gets the number of active passes for this chain.
///
/// ## Safety
2023-02-06 18:17:30 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
libra_error_t libra_d3d12_filter_chain_get_active_pass_count ( libra_d3d12_filter_chain_t * chain ,
uint32_t * out ) ;
2023-01-15 07:52:58 +11:00
# endif
2023-02-06 18:17:30 +11:00
# if defined(LIBRA_RUNTIME_D3D12)
/// Free a D3D12 filter chain.
2023-01-14 10:10:09 +11:00
///
/// The resulting value in `chain` then becomes null.
/// ## Safety
2023-02-06 18:17:30 +11:00
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
libra_error_t libra_d3d12_filter_chain_free ( libra_d3d12_filter_chain_t * chain ) ;
2023-01-14 09:59:22 +11:00
# endif
2023-02-12 07:37:21 +11:00
/// Get the ABI version of the loaded instance.
LIBRASHADER_ABI_VERSION libra_instance_abi_version ( void ) ;
/// Get the API version of the loaded instance.
LIBRASHADER_API_VERSION libra_instance_api_version ( void ) ;
2022-12-04 10:32:10 +11:00
# ifdef __cplusplus
2023-01-21 16:31:29 +11:00
} // extern "C"
# endif // __cplusplus
2022-12-04 10:32:10 +11:00
# endif /* __LIBRASHADER_H__ */