diff --git a/Cargo.lock b/Cargo.lock index 0d51b40..3f52b69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1473,6 +1473,7 @@ dependencies = [ "librashader-runtime", "librashader-runtime-d3d11", "librashader-runtime-d3d12", + "librashader-runtime-d3d9", "librashader-runtime-gl", "librashader-runtime-mtl", "librashader-runtime-vk", @@ -1647,7 +1648,7 @@ dependencies = [ [[package]] name = "librashader-runtime-d3d9" -version = "0.2.4" +version = "0.2.6" dependencies = [ "array-concat", "bytemuck", diff --git a/include/librashader.h b/include/librashader.h index 3e5b405..5ed0bb3 100644 --- a/include/librashader.h +++ b/include/librashader.h @@ -23,6 +23,7 @@ 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. */ + #ifndef __LIBRASHADER_H__ #define __LIBRASHADER_H__ @@ -39,6 +40,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12) #include #endif +#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9) +#include +#endif #if defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__) #import #endif @@ -46,53 +50,54 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #endif + /// Error codes for librashader error types. enum LIBRA_ERRNO #ifdef __cplusplus - : int32_t -#endif // __cplusplus -{ - 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, + : int32_t +#endif // __cplusplus + { + 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, }; #ifndef __cplusplus typedef int32_t LIBRA_ERRNO; -#endif // __cplusplus +#endif // __cplusplus /// An enum representing orientation for use in preset contexts. enum LIBRA_PRESET_CTX_ORIENTATION #ifdef __cplusplus - : uint32_t -#endif // __cplusplus -{ - LIBRA_PRESET_CTX_ORIENTATION_VERTICAL = 0, - LIBRA_PRESET_CTX_ORIENTATION_HORIZONTAL, + : uint32_t +#endif // __cplusplus + { + LIBRA_PRESET_CTX_ORIENTATION_VERTICAL = 0, + LIBRA_PRESET_CTX_ORIENTATION_HORIZONTAL, }; #ifndef __cplusplus typedef uint32_t LIBRA_PRESET_CTX_ORIENTATION; -#endif // __cplusplus +#endif // __cplusplus enum LIBRA_PRESET_CTX_RUNTIME #ifdef __cplusplus - : uint32_t -#endif // __cplusplus -{ - LIBRA_PRESET_CTX_RUNTIME_NONE = 0, - LIBRA_PRESET_CTX_RUNTIME_GL_CORE, - LIBRA_PRESET_CTX_RUNTIME_VULKAN, - LIBRA_PRESET_CTX_RUNTIME_D3D11, - LIBRA_PRESET_CTX_RUNTIME_D3D12, - LIBRA_PRESET_CTX_RUNTIME_METAL, + : uint32_t +#endif // __cplusplus + { + LIBRA_PRESET_CTX_RUNTIME_NONE = 0, + LIBRA_PRESET_CTX_RUNTIME_GL_CORE, + LIBRA_PRESET_CTX_RUNTIME_VULKAN, + LIBRA_PRESET_CTX_RUNTIME_D3D11, + LIBRA_PRESET_CTX_RUNTIME_D3D12, + LIBRA_PRESET_CTX_RUNTIME_METAL, }; #ifndef __cplusplus typedef uint32_t LIBRA_PRESET_CTX_RUNTIME; -#endif // __cplusplus +#endif // __cplusplus /// Opaque struct for a Direct3D 11 filter chain. typedef struct _filter_chain_d3d11 _filter_chain_d3d11; @@ -100,6 +105,9 @@ typedef struct _filter_chain_d3d11 _filter_chain_d3d11; /// Opaque struct for a Direct3D 12 filter chain. typedef struct _filter_chain_d3d12 _filter_chain_d3d12; +/// Opaque struct for a Direct3D 9 filter chain. +typedef struct _filter_chain_d3d9 _filter_chain_d3d9; + /// Opaque struct for an OpenGL filter chain. typedef struct _filter_chain_gl _filter_chain_gl; @@ -129,35 +137,34 @@ typedef struct _preset_ctx *libra_preset_ctx_t; /// A preset parameter. typedef struct libra_preset_param_t { - /// 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; + /// 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; } libra_preset_param_t; /// A list of preset parameters. typedef struct libra_preset_param_list_t { - /// 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; + /// 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; } libra_preset_param_list_t; #if defined(LIBRA_RUNTIME_OPENGL) /// A GL function loader that librashader needs to be initialized with. -typedef const void *(*libra_gl_loader_t)(const char *); +typedef const void *(*libra_gl_loader_t)(const char*); #endif /// API version type alias. @@ -166,20 +173,19 @@ typedef size_t LIBRASHADER_API_VERSION; #if defined(LIBRA_RUNTIME_OPENGL) /// Options for filter chain creation. typedef struct filter_chain_gl_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// The GLSL version. Should be at least `330`. - uint16_t glsl_version; - /// Whether or not to use the Direct State Access APIs. Only available on - /// OpenGL 4.5+. Using the shader cache requires this option, so this option - /// will implicitly disables the shader cache if false. - bool use_dsa; - /// Whether or not to explicitly disable mipmap generation regardless of - /// shader preset settings. - bool force_no_mipmaps; - /// Disable the shader object cache. Shaders will be - /// recompiled rather than loaded from the cache. - bool disable_cache; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// The GLSL version. Should be at least `330`. + uint16_t glsl_version; + /// Whether or not to use the Direct State Access APIs. Only available on OpenGL 4.5+. + /// Using the shader cache requires this option, so this option will implicitly + /// disables the shader cache if false. + bool use_dsa; + /// Whether or not to explicitly disable mipmap generation regardless of shader preset settings. + bool force_no_mipmaps; + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + bool disable_cache; } filter_chain_gl_opt_t; #endif @@ -191,94 +197,93 @@ typedef struct _filter_chain_gl *libra_gl_filter_chain_t; #if defined(LIBRA_RUNTIME_OPENGL) /// OpenGL parameters for the source image. typedef struct libra_source_image_gl_t { - /// 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; - /// The height of the source image. - uint32_t height; + /// 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; + /// The height of the source image. + uint32_t height; } libra_source_image_gl_t; #endif /// Defines the output viewport for a rendered frame. typedef struct libra_viewport_t { - /// 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; + /// 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; } libra_viewport_t; #if defined(LIBRA_RUNTIME_OPENGL) /// OpenGL parameters for the output framebuffer. typedef struct libra_output_framebuffer_gl_t { - /// A framebuffer GLuint to the output framebuffer. - uint32_t fbo; - /// A texture GLuint to the logical buffer of the output framebuffer. - uint32_t texture; - /// The format of the output framebuffer. - uint32_t format; + /// A framebuffer GLuint to the output framebuffer. + uint32_t fbo; + /// A texture GLuint to the logical buffer of the output framebuffer. + uint32_t texture; + /// The format of the output framebuffer. + uint32_t format; } libra_output_framebuffer_gl_t; #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Options for each OpenGL shader frame. typedef struct frame_gl_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. - uint32_t rotation; - /// The total number of subframes ran. Default is 1. - uint32_t total_subframes; - /// The current sub frame. Default is 1. - uint32_t current_subframe; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; } frame_gl_opt_t; #endif #if defined(LIBRA_RUNTIME_VULKAN) /// Handles required to instantiate vulkan typedef struct libra_device_vk_t { - /// 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; + /// 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; } libra_device_vk_t; #endif #if defined(LIBRA_RUNTIME_VULKAN) /// Options for filter chain creation. typedef struct filter_chain_vk_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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 dynamic rendering over 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_dynamic_rendering; - /// Disable the shader object cache. Shaders will be - /// recompiled rather than loaded from the cache. - bool disable_cache; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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 dynamic rendering over 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_dynamic_rendering; + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + bool disable_cache; } filter_chain_vk_opt_t; #endif @@ -290,57 +295,57 @@ typedef struct _filter_chain_vk *libra_vk_filter_chain_t; #if defined(LIBRA_RUNTIME_VULKAN) /// Vulkan parameters for the source image. typedef struct libra_source_image_vk_t { - /// 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; - /// The height of the source image. - uint32_t height; + /// 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; + /// The height of the source image. + uint32_t height; } 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; + /// A raw `VkImage` handle to the output image. + VkImage handle; + /// The `VkFormat` of the output image. + VkFormat format; } libra_output_image_vk_t; #endif #if defined(LIBRA_RUNTIME_VULKAN) /// Options for each Vulkan shader frame. typedef struct frame_vk_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. - uint32_t rotation; - /// The total number of subframes ran. Default is 1. - uint32_t total_subframes; - /// The current sub frame. Default is 1. - uint32_t current_subframe; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; } frame_vk_opt_t; #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Options for Direct3D 11 filter chain creation. typedef struct filter_chain_d3d11_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// Whether or not to explicitly disable mipmap - /// generation regardless of shader preset settings. - bool force_no_mipmaps; - /// Disable the shader object cache. Shaders will be - /// recompiled rather than loaded from the cache. - bool disable_cache; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// Whether or not to explicitly disable mipmap + /// generation regardless of shader preset settings. + bool force_no_mipmaps; + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + bool disable_cache; } filter_chain_d3d11_opt_t; #endif @@ -352,48 +357,86 @@ typedef struct _filter_chain_d3d11 *libra_d3d11_filter_chain_t; #if (defined(_WIN32) && 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 - ID3D11ShaderResourceView *handle; - /// The width of the source image. - uint32_t width; - /// The height of the source image. - uint32_t height; + /// A shader resource view into the source image + ID3D11ShaderResourceView * handle; + /// The width of the source image. + uint32_t width; + /// The height of the source image. + uint32_t height; } libra_source_image_d3d11_t; #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Options for each Direct3D 11 shader frame. typedef struct frame_d3d11_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. - uint32_t rotation; - /// The total number of subframes ran. Default is 1. - uint32_t total_subframes; - /// The current sub frame. Default is 1. - uint32_t current_subframe; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; } frame_d3d11_opt_t; #endif +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Options for Direct3D 11 filter chain creation. +typedef struct filter_chain_d3d9_opt_t { + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// Whether or not to explicitly disable mipmap + /// generation regardless of shader preset settings. + bool force_no_mipmaps; + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + bool disable_cache; +} filter_chain_d3d9_opt_t; +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// A handle to a Direct3D 11 filter chain. +typedef struct _filter_chain_d3d9 *libra_d3d9_filter_chain_t; +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Options for each Direct3D 11 shader frame. +typedef struct frame_d3d9_opt_t { + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; +} frame_d3d9_opt_t; +#endif + #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Options for Direct3D11 filter chain creation. typedef struct filter_chain_d3d12_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// Disable the shader object cache. Shaders will be - /// recompiled rather than loaded from the cache. - bool disable_cache; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + bool disable_cache; } filter_chain_d3d12_opt_t; #endif @@ -405,56 +448,55 @@ typedef struct _filter_chain_d3d12 *libra_d3d12_filter_chain_t; #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Direct3D 12 parameters for the source image. typedef struct libra_source_image_d3d12_t { - /// The resource containing the image. - ID3D12Resource *resource; - /// 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; + /// The resource containing the image. + ID3D12Resource * resource; + /// 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 #if (defined(_WIN32) && 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; + /// 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 #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Options for each Direct3D 12 shader frame. typedef struct frame_d3d12_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. - uint32_t rotation; - /// The total number of subframes ran. Default is 1. - uint32_t total_subframes; - /// The current sub frame. Default is 1. - uint32_t current_subframe; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; } frame_d3d12_opt_t; #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Options for filter chain creation. typedef struct filter_chain_mtl_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// Whether or not to explicitly disable mipmap generation regardless of - /// shader preset settings. - bool force_no_mipmaps; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// Whether or not to explicitly disable mipmap generation regardless of shader preset settings. + bool force_no_mipmaps; } filter_chain_mtl_opt_t; #endif @@ -465,19 +507,19 @@ typedef struct _filter_chain_mtl *libra_mtl_filter_chain_t; #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Options for each Metal shader frame. typedef struct frame_mtl_opt_t { - /// The librashader API version. - LIBRASHADER_API_VERSION version; - /// 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; - /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. - uint32_t rotation; - /// The total number of subframes ran. Default is 1. - uint32_t total_subframes; - /// The current sub frame. Default is 1. - uint32_t current_subframe; + /// The librashader API version. + LIBRASHADER_API_VERSION version; + /// 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; + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + uint32_t rotation; + /// The total number of subframes ran. Default is 1. + uint32_t total_subframes; + /// The current sub frame. Default is 1. + uint32_t current_subframe; } frame_mtl_opt_t; #endif @@ -490,101 +532,102 @@ typedef LIBRASHADER_ABI_VERSION (*PFN_libra_instance_abi_version)(void); typedef LIBRASHADER_API_VERSION (*PFN_libra_instance_api_version)(void); /// Function pointer definition for -/// libra_preset_create -typedef libra_error_t (*PFN_libra_preset_create)(const char *filename, - libra_shader_preset_t *out); +///libra_preset_create +typedef libra_error_t (*PFN_libra_preset_create)(const char *filename, libra_shader_preset_t *out); /// Function pointer definition for -/// libra_preset_free +///libra_preset_free typedef libra_error_t (*PFN_libra_preset_free)(libra_shader_preset_t *preset); /// Function pointer definition for -/// libra_preset_set_param -typedef libra_error_t (*PFN_libra_preset_set_param)( - libra_shader_preset_t *preset, const char *name, float value); +///libra_preset_set_param +typedef libra_error_t (*PFN_libra_preset_set_param)(libra_shader_preset_t *preset, + const char *name, + float value); /// Function pointer definition for -/// libra_preset_get_param -typedef libra_error_t (*PFN_libra_preset_get_param)( - libra_shader_preset_t *preset, const char *name, float *value); +///libra_preset_get_param +typedef libra_error_t (*PFN_libra_preset_get_param)(libra_shader_preset_t *preset, + const char *name, + float *value); /// Function pointer definition for -/// libra_preset_print +///libra_preset_print typedef libra_error_t (*PFN_libra_preset_print)(libra_shader_preset_t *preset); /// Function pointer definition for -/// 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); +///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); /// Function pointer definition for -/// libra_preset_free_runtime_params -typedef libra_error_t (*PFN_libra_preset_free_runtime_params)( - struct libra_preset_param_list_t preset); +///libra_preset_free_runtime_params +typedef libra_error_t (*PFN_libra_preset_free_runtime_params)(struct libra_preset_param_list_t preset); /// Function pointer definition for -/// libra_preset_create_with_context -typedef libra_error_t (*PFN_libra_preset_create_with_context)( - const char *filename, libra_preset_ctx_t *context, - libra_shader_preset_t *out); +///libra_preset_create_with_context +typedef libra_error_t (*PFN_libra_preset_create_with_context)(const char *filename, + libra_preset_ctx_t *context, + libra_shader_preset_t *out); /// Function pointer definition for -/// libra_preset_ctx_create +///libra_preset_ctx_create typedef libra_error_t (*PFN_libra_preset_ctx_create)(libra_preset_ctx_t *out); /// Function pointer definition for -/// libra_preset_ctx_free +///libra_preset_ctx_free typedef libra_error_t (*PFN_libra_preset_ctx_free)(libra_preset_ctx_t *context); /// Function pointer definition for -/// libra_preset_ctx_set_core_name -typedef libra_error_t (*PFN_libra_preset_ctx_set_core_name)( - libra_preset_ctx_t *context, const char *name); +///libra_preset_ctx_set_core_name +typedef libra_error_t (*PFN_libra_preset_ctx_set_core_name)(libra_preset_ctx_t *context, + const char *name); /// Function pointer definition for -/// libra_preset_ctx_set_content_dir -typedef libra_error_t (*PFN_libra_preset_ctx_set_content_dir)( - libra_preset_ctx_t *context, const char *name); +///libra_preset_ctx_set_content_dir +typedef libra_error_t (*PFN_libra_preset_ctx_set_content_dir)(libra_preset_ctx_t *context, + const char *name); /// Function pointer definition for -/// libra_preset_ctx_set_param -typedef libra_error_t (*PFN_libra_preset_ctx_set_param)( - libra_preset_ctx_t *context, const char *name, const char *value); +///libra_preset_ctx_set_param +typedef libra_error_t (*PFN_libra_preset_ctx_set_param)(libra_preset_ctx_t *context, + const char *name, + const char *value); /// Function pointer definition for -/// libra_preset_ctx_set_core_rotation -typedef libra_error_t (*PFN_libra_preset_ctx_set_core_rotation)( - libra_preset_ctx_t *context, uint32_t value); +///libra_preset_ctx_set_core_rotation +typedef libra_error_t (*PFN_libra_preset_ctx_set_core_rotation)(libra_preset_ctx_t *context, + uint32_t value); /// Function pointer definition for -/// libra_preset_ctx_set_user_rotation -typedef libra_error_t (*PFN_libra_preset_ctx_set_user_rotation)( - libra_preset_ctx_t *context, uint32_t value); +///libra_preset_ctx_set_user_rotation +typedef libra_error_t (*PFN_libra_preset_ctx_set_user_rotation)(libra_preset_ctx_t *context, + uint32_t value); /// Function pointer definition for -/// libra_preset_ctx_set_screen_orientation -typedef libra_error_t (*PFN_libra_preset_ctx_set_screen_orientation)( - libra_preset_ctx_t *context, uint32_t value); +///libra_preset_ctx_set_screen_orientation +typedef libra_error_t (*PFN_libra_preset_ctx_set_screen_orientation)(libra_preset_ctx_t *context, + uint32_t value); /// Function pointer definition for -/// libra_preset_ctx_set_allow_rotation -typedef libra_error_t (*PFN_libra_preset_ctx_set_allow_rotation)( - libra_preset_ctx_t *context, bool value); +///libra_preset_ctx_set_allow_rotation +typedef libra_error_t (*PFN_libra_preset_ctx_set_allow_rotation)(libra_preset_ctx_t *context, + bool value); /// Function pointer definition for -/// libra_preset_ctx_set_view_aspect_orientation -typedef libra_error_t (*PFN_libra_preset_ctx_set_view_aspect_orientation)( - libra_preset_ctx_t *context, LIBRA_PRESET_CTX_ORIENTATION value); +///libra_preset_ctx_set_view_aspect_orientation +typedef libra_error_t (*PFN_libra_preset_ctx_set_view_aspect_orientation)(libra_preset_ctx_t *context, + LIBRA_PRESET_CTX_ORIENTATION value); /// Function pointer definition for -/// libra_preset_ctx_set_core_aspect_orientation -typedef libra_error_t (*PFN_libra_preset_ctx_set_core_aspect_orientation)( - libra_preset_ctx_t *context, LIBRA_PRESET_CTX_ORIENTATION value); +///libra_preset_ctx_set_core_aspect_orientation +typedef libra_error_t (*PFN_libra_preset_ctx_set_core_aspect_orientation)(libra_preset_ctx_t *context, + LIBRA_PRESET_CTX_ORIENTATION value); /// Function pointer definition for -/// libra_preset_ctx_set_runtime -typedef libra_error_t (*PFN_libra_preset_ctx_set_runtime)( - libra_preset_ctx_t *context, LIBRA_PRESET_CTX_RUNTIME value); +///libra_preset_ctx_set_runtime +typedef libra_error_t (*PFN_libra_preset_ctx_set_runtime)(libra_preset_ctx_t *context, + LIBRA_PRESET_CTX_RUNTIME value); /// Function pointer definition for libra_error_errno typedef LIBRA_ERRNO (*PFN_libra_error_errno)(libra_error_t error); @@ -603,314 +646,393 @@ typedef int32_t (*PFN_libra_error_free_string)(char **out); #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// libra_gl_init_context +///libra_gl_init_context typedef libra_error_t (*PFN_libra_gl_init_context)(libra_gl_loader_t loader); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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); +///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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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, - struct libra_output_framebuffer_gl_t out, const float *mvp, - const struct frame_gl_opt_t *opt); +///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, + struct libra_output_framebuffer_gl_t out, + const float *mvp, + const struct frame_gl_opt_t *opt); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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); +///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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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); +///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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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); +///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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// 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); +///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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Function pointer definition for -/// libra_gl_filter_chain_free -typedef libra_error_t (*PFN_libra_gl_filter_chain_free)( - libra_gl_filter_chain_t *chain); +///libra_gl_filter_chain_free +typedef libra_error_t (*PFN_libra_gl_filter_chain_free)(libra_gl_filter_chain_t *chain); #endif #if defined(LIBRA_RUNTIME_VULKAN) /// Function pointer definition for -/// libra_vk_filter_chain_create -typedef libra_error_t (*PFN_libra_vk_filter_chain_create)( - libra_shader_preset_t *preset, struct libra_device_vk_t vulkan, - const struct filter_chain_vk_opt_t *options, libra_vk_filter_chain_t *out); +///libra_vk_filter_chain_create +typedef libra_error_t (*PFN_libra_vk_filter_chain_create)(libra_shader_preset_t *preset, + struct libra_device_vk_t vulkan, + const struct filter_chain_vk_opt_t *options, + libra_vk_filter_chain_t *out); #endif #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); +///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 #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, struct libra_source_image_vk_t image, - struct libra_viewport_t viewport, struct libra_output_image_vk_t out, - const float *mvp, const struct frame_vk_opt_t *opt); +///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, + struct libra_source_image_vk_t image, + struct libra_viewport_t viewport, + struct libra_output_image_vk_t out, + 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); +///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); +///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); +///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); +///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); +///libra_vk_filter_chain_free +typedef libra_error_t (*PFN_libra_vk_filter_chain_free)(libra_vk_filter_chain_t *chain); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// libra_d3d11_filter_chain_create -typedef libra_error_t (*PFN_libra_d3d11_filter_chain_create)( - libra_shader_preset_t *preset, ID3D11Device *device, - const struct filter_chain_d3d11_opt_t *options, - libra_d3d11_filter_chain_t *out); +///libra_d3d11_filter_chain_create +typedef libra_error_t (*PFN_libra_d3d11_filter_chain_create)(libra_shader_preset_t *preset, + ID3D11Device * device, + const struct filter_chain_d3d11_opt_t *options, + libra_d3d11_filter_chain_t *out); #endif #if (defined(_WIN32) && 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); +///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 #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// libra_d3d11_filter_chain_frame -typedef libra_error_t (*PFN_libra_d3d11_filter_chain_frame)( - libra_d3d11_filter_chain_t *chain, ID3D11DeviceContext *device_context, - size_t frame_count, struct libra_source_image_d3d11_t image, - struct libra_viewport_t viewport, ID3D11RenderTargetView *out, - const float *mvp, const struct frame_d3d11_opt_t *options); +///libra_d3d11_filter_chain_frame +typedef libra_error_t (*PFN_libra_d3d11_filter_chain_frame)(libra_d3d11_filter_chain_t *chain, + ID3D11DeviceContext * device_context, + size_t frame_count, + struct libra_source_image_d3d11_t image, + struct libra_viewport_t viewport, + ID3D11RenderTargetView * out, + const float *mvp, + const struct frame_d3d11_opt_t *options); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Function pointer definition for -/// libra_d3d11_filter_chain_free -typedef libra_error_t (*PFN_libra_d3d11_filter_chain_free)( - libra_d3d11_filter_chain_t *chain); +///libra_d3d11_filter_chain_free +typedef libra_error_t (*PFN_libra_d3d11_filter_chain_free)(libra_d3d11_filter_chain_t *chain); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_create +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_create)(libra_shader_preset_t *preset, + IDirect3DDevice9 * device, + const struct filter_chain_d3d9_opt_t *options, + libra_d3d9_filter_chain_t *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_frame +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_frame)(libra_d3d9_filter_chain_t *chain, + size_t frame_count, + IDirect3DTexture9 * image, + struct libra_viewport_t viewport, + IDirect3DSurface9 * out, + const float *mvp, + const struct frame_d3d9_opt_t *options); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_set_param +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_set_param)(libra_d3d9_filter_chain_t *chain, + const char *param_name, + float value); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_get_param +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_get_param)(libra_d3d9_filter_chain_t *chain, + const char *param_name, + float *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_set_active_pass_count +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_set_active_pass_count)(libra_d3d9_filter_chain_t *chain, + uint32_t value); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_get_active_pass_count +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_get_active_pass_count)(libra_d3d9_filter_chain_t *chain, + uint32_t *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Function pointer definition for +///libra_d3d9_filter_chain_free +typedef libra_error_t (*PFN_libra_d3d9_filter_chain_free)(libra_d3d9_filter_chain_t *chain); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// libra_d3d12_filter_chain_create -typedef libra_error_t (*PFN_libra_d3d12_filter_chain_create)( - libra_shader_preset_t *preset, ID3D12Device *device, - const struct filter_chain_d3d12_opt_t *options, - libra_d3d12_filter_chain_t *out); +///libra_d3d12_filter_chain_create +typedef libra_error_t (*PFN_libra_d3d12_filter_chain_create)(libra_shader_preset_t *preset, + ID3D12Device * device, + const struct filter_chain_d3d12_opt_t *options, + libra_d3d12_filter_chain_t *out); #endif #if (defined(_WIN32) && 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); +///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 #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// libra_d3d12_filter_chain_frame -typedef libra_error_t (*PFN_libra_d3d12_filter_chain_frame)( - libra_d3d12_filter_chain_t *chain, ID3D12GraphicsCommandList *command_list, - size_t frame_count, struct libra_source_image_d3d12_t image, - struct libra_viewport_t viewport, struct libra_output_image_d3d12_t out, - const float *mvp, const struct frame_d3d12_opt_t *options); +///libra_d3d12_filter_chain_frame +typedef libra_error_t (*PFN_libra_d3d12_filter_chain_frame)(libra_d3d12_filter_chain_t *chain, + ID3D12GraphicsCommandList * command_list, + size_t frame_count, + struct libra_source_image_d3d12_t image, + struct libra_viewport_t viewport, + struct libra_output_image_d3d12_t out, + const float *mvp, + const struct frame_d3d12_opt_t *options); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// 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); +///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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Function pointer definition for -/// libra_d3d12_filter_chain_free -typedef libra_error_t (*PFN_libra_d3d12_filter_chain_free)( - libra_d3d12_filter_chain_t *chain); +///libra_d3d12_filter_chain_free +typedef libra_error_t (*PFN_libra_d3d12_filter_chain_free)(libra_d3d12_filter_chain_t *chain); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_create -typedef libra_error_t (*PFN_libra_mtl_filter_chain_create)( - libra_shader_preset_t *preset, id queue, - const struct filter_chain_mtl_opt_t *options, - libra_mtl_filter_chain_t *out); +///libra_mtl_filter_chain_create +typedef libra_error_t (*PFN_libra_mtl_filter_chain_create)(libra_shader_preset_t *preset, + id queue, + const struct filter_chain_mtl_opt_t *options, + libra_mtl_filter_chain_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_create_deferred -typedef libra_error_t (*PFN_libra_mtl_filter_chain_create_deferred)( - libra_shader_preset_t *preset, id queue, - id command_buffer, - const struct filter_chain_mtl_opt_t *options, - libra_mtl_filter_chain_t *out); +///libra_mtl_filter_chain_create_deferred +typedef libra_error_t (*PFN_libra_mtl_filter_chain_create_deferred)(libra_shader_preset_t *preset, + id queue, + id command_buffer, + const struct filter_chain_mtl_opt_t *options, + libra_mtl_filter_chain_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_frame -typedef libra_error_t (*PFN_libra_mtl_filter_chain_frame)( - libra_mtl_filter_chain_t *chain, id command_buffer, - size_t frame_count, id image, struct libra_viewport_t viewport, - id output, const float *mvp, const struct frame_mtl_opt_t *opt); +///libra_mtl_filter_chain_frame +typedef libra_error_t (*PFN_libra_mtl_filter_chain_frame)(libra_mtl_filter_chain_t *chain, + id command_buffer, + size_t frame_count, + id image, + struct libra_viewport_t viewport, + id output, + const float *mvp, + const struct frame_mtl_opt_t *opt); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_set_param -typedef libra_error_t (*PFN_libra_mtl_filter_chain_set_param)( - libra_mtl_filter_chain_t *chain, const char *param_name, float value); +///libra_mtl_filter_chain_set_param +typedef libra_error_t (*PFN_libra_mtl_filter_chain_set_param)(libra_mtl_filter_chain_t *chain, + const char *param_name, + float value); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_get_param -typedef libra_error_t (*PFN_libra_mtl_filter_chain_get_param)( - libra_mtl_filter_chain_t *chain, const char *param_name, float *out); +///libra_mtl_filter_chain_get_param +typedef libra_error_t (*PFN_libra_mtl_filter_chain_get_param)(libra_mtl_filter_chain_t *chain, + const char *param_name, + float *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_set_active_pass_count -typedef libra_error_t (*PFN_libra_mtl_filter_chain_set_active_pass_count)( - libra_mtl_filter_chain_t *chain, uint32_t value); +///libra_mtl_filter_chain_set_active_pass_count +typedef libra_error_t (*PFN_libra_mtl_filter_chain_set_active_pass_count)(libra_mtl_filter_chain_t *chain, + uint32_t value); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_get_active_pass_count -typedef libra_error_t (*PFN_libra_mtl_filter_chain_get_active_pass_count)( - libra_mtl_filter_chain_t *chain, uint32_t *out); +///libra_mtl_filter_chain_get_active_pass_count +typedef libra_error_t (*PFN_libra_mtl_filter_chain_get_active_pass_count)(libra_mtl_filter_chain_t *chain, + uint32_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// Function pointer definition for -/// libra_mtl_filter_chain_free -typedef libra_error_t (*PFN_libra_mtl_filter_chain_free)( - libra_mtl_filter_chain_t *chain); +///libra_mtl_filter_chain_free +typedef libra_error_t (*PFN_libra_mtl_filter_chain_free)(libra_mtl_filter_chain_t *chain); #endif /// The current version of the librashader API. @@ -943,7 +1065,7 @@ typedef libra_error_t (*PFN_libra_mtl_filter_chain_free)( #ifdef __cplusplus extern "C" { -#endif // __cplusplus +#endif // __cplusplus /// Get the error code corresponding to this error object. /// @@ -953,51 +1075,44 @@ LIBRA_ERRNO libra_error_errno(libra_error_t error); /// Print the error message. /// -/// If `error` is null, this function does nothing and returns 1. Otherwise, -/// this function returns 0. +/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0. /// ## Safety /// - `error` must be a valid and initialized instance of `libra_error_t`. int32_t libra_error_print(libra_error_t error); /// Frees any internal state kept by the error. /// -/// If `error` is null, this function does nothing and returns 1. Otherwise, -/// this function returns 0. The resulting error object becomes null. +/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0. +/// The resulting error object becomes null. /// ## Safety -/// - `error` must be null or a pointer to a valid and initialized instance of -/// `libra_error_t`. +/// - `error` must be null or a pointer to a valid and initialized instance of `libra_error_t`. int32_t libra_error_free(libra_error_t *error); /// Writes the error message into `out` /// -/// If `error` is null, this function does nothing and returns 1. Otherwise, -/// this function returns 0. +/// If `error` is null, this function does nothing and returns 1. Otherwise, this function returns 0. /// ## Safety /// - `error` must be a valid and initialized instance of `libra_error_t`. -/// - `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); +/// - `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); /// Frees an error string previously allocated by `libra_error_write`. /// /// After freeing, the pointer will be set to null. /// ## Safety -/// - 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. +/// - 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. int32_t libra_error_free_string(char **out); /// Load a preset. /// /// ## Safety -/// - `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`. +/// - `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`. /// ## Returns -/// - If any parameters are null, `out` is unchanged, and this function returns -/// `LIBRA_ERR_INVALID_PARAMETER`. +/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`. libra_error_t libra_preset_create(const char *filename, libra_shader_preset_t *out); @@ -1006,27 +1121,22 @@ libra_error_t libra_preset_create(const char *filename, /// The wildcard context is immediately invalidated and must be recreated after /// the preset is created. /// -/// Path information variables `PRESET_DIR` and `PRESET` will automatically be -/// filled in. +/// Path information variables `PRESET_DIR` and `PRESET` will automatically be filled in. /// ## Safety -/// - `filename` must be either null or a valid, aligned pointer to a string -/// path to the shader preset. -/// - `context` must be either null or a valid, aligned pointer to a -/// initialized `libra_preset_ctx_t`. +/// - `filename` must be either null or a valid, aligned pointer to a string path to the shader preset. +/// - `context` must be either null or a valid, aligned pointer to a initialized `libra_preset_ctx_t`. /// - `context` is invalidated after this function returns. -/// - `out` must be either null, or an aligned pointer to an uninitialized or -/// invalid `libra_shader_preset_t`. +/// - `out` must be either null, or an aligned pointer to an uninitialized or invalid `libra_shader_preset_t`. /// ## Returns -/// - If any parameters are null, `out` is unchanged, and this function returns -/// `LIBRA_ERR_INVALID_PARAMETER`. +/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`. libra_error_t libra_preset_create_with_context(const char *filename, libra_preset_ctx_t *context, libra_shader_preset_t *out); /// Free the preset. /// -/// If `preset` is null, this function does nothing. The resulting value in -/// `preset` then becomes null. +/// If `preset` is null, this function does nothing. The resulting value in `preset` then becomes +/// null. /// /// ## Safety /// - `preset` must be a valid and aligned pointer to a `libra_shader_preset_t`. @@ -1035,11 +1145,9 @@ libra_error_t libra_preset_free(libra_shader_preset_t *preset); /// Set the value of the parameter in the preset. /// /// ## Safety -/// - `preset` must be null or a valid and aligned pointer to a -/// `libra_shader_preset_t`. +/// - `preset` must be null or a valid and aligned pointer to a `libra_shader_preset_t`. /// - `name` must be null or a valid and aligned pointer to a string. -libra_error_t libra_preset_set_param(libra_shader_preset_t *preset, - const char *name, float value); +libra_error_t libra_preset_set_param(libra_shader_preset_t *preset, const char *name, float value); /// Get the value of the parameter as set in the preset. /// @@ -1047,31 +1155,26 @@ libra_error_t libra_preset_set_param(libra_shader_preset_t *preset, /// - `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`. -libra_error_t libra_preset_get_param(libra_shader_preset_t *preset, - const char *name, float *value); +libra_error_t libra_preset_get_param(libra_shader_preset_t *preset, const char *name, float *value); /// Pretty print the shader preset. /// /// ## Safety -/// - `preset` must be null or a valid and aligned pointer to a -/// `libra_shader_preset_t`. +/// - `preset` must be null or a valid and aligned pointer to a `libra_shader_preset_t`. libra_error_t libra_preset_print(libra_shader_preset_t *preset); /// Get a list of runtime parameters. /// /// ## Safety -/// - `preset` must be null or a valid and aligned pointer to a -/// `libra_shader_preset_t`. +/// - `preset` must be null or a valid and aligned pointer to a `libra_shader_preset_t`. /// - `out` must be an aligned pointer to a `libra_preset_parameter_list_t`. -/// - The output struct should be treated as immutable. Mutating any struct -/// fields +/// - The output struct should be treated as immutable. Mutating any struct fields /// in the returned struct may at best cause memory leaks, and at worse /// cause undefined behaviour when later freed. -/// - It is safe to call `libra_preset_get_runtime_params` multiple times, -/// however +/// - It is safe to call `libra_preset_get_runtime_params` multiple times, however /// the output struct must only be freed once per call. -libra_error_t libra_preset_get_runtime_params( - libra_shader_preset_t *preset, struct libra_preset_param_list_t *out); +libra_error_t libra_preset_get_runtime_params(libra_shader_preset_t *preset, + struct libra_preset_param_list_t *out); /// Free the runtime parameters. /// @@ -1081,23 +1184,18 @@ libra_error_t libra_preset_get_runtime_params( /// contained within the input `libra_preset_param_list_t`. /// /// ## Safety -/// - 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`. +/// - 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 +/// - Accessing any data pointed to via the input `libra_preset_param_list_t` after it /// has been freed is a use-after-free and is immediate undefined behaviour. /// -/// - 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); +/// - 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); #if defined(LIBRA_RUNTIME_OPENGL) /// Initialize the OpenGL Context for librashader. @@ -1106,12 +1204,10 @@ libra_error_t libra_preset_free_runtime_params( /// unless for whatever reason you switch OpenGL loaders mid-flight. /// /// ## Safety -/// Attempting to create a filter chain will fail if the GL context is not -/// initialized. +/// Attempting to create a filter chain will fail if the GL context is not initialized. /// -/// Reinitializing the OpenGL context with a different loader immediately -/// invalidates previous filter chain objects, and drawing with them causes -/// immediate undefined behaviour. +/// Reinitializing the OpenGL context with a different loader immediately invalidates previous filter +/// chain objects, and drawing with them causes immediate undefined behaviour. libra_error_t libra_gl_init_context(libra_gl_loader_t loader); #endif @@ -1125,35 +1221,32 @@ libra_error_t libra_gl_init_context(libra_gl_loader_t loader); /// - `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. -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); +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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// Draw a frame with the given parameters for the given filter chain. /// /// ## Safety -/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or -/// invalid, this +/// - `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` +/// - `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_gl_opt_t` +/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_gl_opt_t` /// struct. -/// - 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. -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, - struct libra_output_framebuffer_gl_t out, const float *mvp, - const struct frame_gl_opt_t *opt); +/// - 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. +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, + struct libra_output_framebuffer_gl_t out, + const float *mvp, + const struct frame_gl_opt_t *opt); #endif #if defined(LIBRA_RUNTIME_OPENGL) @@ -1161,8 +1254,7 @@ libra_error_t libra_gl_filter_chain_frame( /// /// 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_gl_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`. /// - `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, @@ -1174,8 +1266,7 @@ libra_error_t libra_gl_filter_chain_set_param(libra_gl_filter_chain_t *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_gl_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`. /// - `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, @@ -1186,20 +1277,18 @@ libra_error_t libra_gl_filter_chain_get_param(libra_gl_filter_chain_t *chain, /// 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_gl_filter_chain_t`. -libra_error_t libra_gl_filter_chain_set_active_pass_count( - libra_gl_filter_chain_t *chain, uint32_t value); +/// - `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); #endif #if defined(LIBRA_RUNTIME_OPENGL) /// 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_gl_filter_chain_t`. -libra_error_t libra_gl_filter_chain_get_active_pass_count( - libra_gl_filter_chain_t *chain, uint32_t *out); +/// - `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); #endif #if defined(LIBRA_RUNTIME_OPENGL) @@ -1207,8 +1296,7 @@ libra_error_t libra_gl_filter_chain_get_active_pass_count( /// /// The resulting value in `chain` then becomes null. /// ## Safety -/// - `chain` must be either null or a valid and aligned pointer to an -/// initialized `libra_gl_filter_chain_t`. +/// - `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_free(libra_gl_filter_chain_t *chain); #endif @@ -1219,76 +1307,72 @@ libra_error_t libra_gl_filter_chain_free(libra_gl_filter_chain_t *chain); /// the filter chain is created. /// /// ## Safety: -/// - The handles provided in `vulkan` must be valid for the command buffers -/// that +/// - The handles provided in `vulkan` must be valid for the command buffers that /// `libra_vk_filter_chain_frame` will write to. /// 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. -libra_error_t libra_vk_filter_chain_create( - libra_shader_preset_t *preset, struct libra_device_vk_t vulkan, - const struct filter_chain_vk_opt_t *options, libra_vk_filter_chain_t *out); +libra_error_t libra_vk_filter_chain_create(libra_shader_preset_t *preset, + struct libra_device_vk_t vulkan, + const struct filter_chain_vk_opt_t *options, + libra_vk_filter_chain_t *out); #endif #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. +/// 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 +/// - The handles provided in `vulkan` must be valid for the command buffers that /// `libra_vk_filter_chain_frame` will write to. /// - `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); +/// 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 #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. +/// Records rendering commands for a frame with the given parameters for the given filter chain +/// to the input command buffer. /// /// * 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. +/// 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. /// /// ## 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 +/// - `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` +/// - `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` +/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_vk_opt_t` /// struct. -/// - You must ensure that only one thread has access to `chain` before you call -/// this function. Only one +/// - 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. -libra_error_t libra_vk_filter_chain_frame( - libra_vk_filter_chain_t *chain, VkCommandBuffer command_buffer, - size_t frame_count, struct libra_source_image_vk_t image, - struct libra_viewport_t viewport, struct libra_output_image_vk_t out, - const float *mvp, const struct frame_vk_opt_t *opt); +libra_error_t libra_vk_filter_chain_frame(libra_vk_filter_chain_t *chain, + VkCommandBuffer command_buffer, + size_t frame_count, + struct libra_source_image_vk_t image, + struct libra_viewport_t viewport, + struct libra_output_image_vk_t out, + const float *mvp, + const struct frame_vk_opt_t *opt); #endif #if defined(LIBRA_RUNTIME_VULKAN) @@ -1296,8 +1380,7 @@ libra_error_t libra_vk_filter_chain_frame( /// /// 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`. +/// - `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, @@ -1309,8 +1392,7 @@ libra_error_t libra_vk_filter_chain_set_param(libra_vk_filter_chain_t *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`. +/// - `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, @@ -1321,20 +1403,18 @@ libra_error_t libra_vk_filter_chain_get_param(libra_vk_filter_chain_t *chain, /// 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); +/// - `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); +/// - `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) @@ -1342,8 +1422,7 @@ libra_error_t libra_vk_filter_chain_get_active_pass_count( /// /// 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`. +/// - `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 @@ -1358,18 +1437,17 @@ libra_error_t libra_vk_filter_chain_free(libra_vk_filter_chain_t *chain); /// - `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. -libra_error_t libra_d3d11_filter_chain_create( - libra_shader_preset_t *preset, ID3D11Device *device, - const struct filter_chain_d3d11_opt_t *options, - libra_d3d11_filter_chain_t *out); +libra_error_t libra_d3d11_filter_chain_create(libra_shader_preset_t *preset, + ID3D11Device * device, + const struct filter_chain_d3d11_opt_t *options, + libra_d3d11_filter_chain_t *out); #endif #if (defined(_WIN32) && 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. +/// 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. @@ -1381,58 +1459,51 @@ libra_error_t libra_d3d11_filter_chain_create( /// - `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. +/// 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 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); +/// 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 #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// Draw a frame with the given parameters for the given filter chain. /// -/// 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` +/// 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` /// /// ## Safety -/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or -/// invalid, this +/// - `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` +/// - `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_d3d11_opt_t` +/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_d3d11_opt_t` /// struct. /// - `out` must not be null. /// - `image.handle` must not be null. -/// - 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. -/// - You must ensure that only one thread has access to `chain` before you call -/// this function. Only one +/// - 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. +/// - 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. -libra_error_t libra_d3d11_filter_chain_frame( - libra_d3d11_filter_chain_t *chain, ID3D11DeviceContext *device_context, - size_t frame_count, struct libra_source_image_d3d11_t image, - struct libra_viewport_t viewport, ID3D11RenderTargetView *out, - const float *mvp, const struct frame_d3d11_opt_t *options); +libra_error_t libra_d3d11_filter_chain_frame(libra_d3d11_filter_chain_t *chain, + ID3D11DeviceContext * device_context, + size_t frame_count, + struct libra_source_image_d3d11_t image, + struct libra_viewport_t viewport, + ID3D11RenderTargetView * out, + const float *mvp, + const struct frame_d3d11_opt_t *options); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) @@ -1440,11 +1511,11 @@ libra_error_t libra_d3d11_filter_chain_frame( /// /// 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_d3d11_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. -libra_error_t libra_d3d11_filter_chain_set_param( - libra_d3d11_filter_chain_t *chain, const char *param_name, float value); +libra_error_t libra_d3d11_filter_chain_set_param(libra_d3d11_filter_chain_t *chain, + const char *param_name, + float value); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) @@ -1452,31 +1523,29 @@ libra_error_t libra_d3d11_filter_chain_set_param( /// /// 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_d3d11_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. -libra_error_t libra_d3d11_filter_chain_get_param( - libra_d3d11_filter_chain_t *chain, const char *param_name, float *out); +libra_error_t libra_d3d11_filter_chain_get_param(libra_d3d11_filter_chain_t *chain, + const char *param_name, + float *out); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// 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_d3d11_filter_chain_t`. -libra_error_t libra_d3d11_filter_chain_set_active_pass_count( - libra_d3d11_filter_chain_t *chain, uint32_t value); +/// - `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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) /// 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_d3d11_filter_chain_t`. -libra_error_t libra_d3d11_filter_chain_get_active_pass_count( - libra_d3d11_filter_chain_t *chain, uint32_t *out); +/// - `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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D11)) @@ -1484,11 +1553,108 @@ libra_error_t libra_d3d11_filter_chain_get_active_pass_count( /// /// The resulting value in `chain` then becomes null. /// ## Safety -/// - `chain` must be either null or a valid and aligned pointer to an -/// initialized `libra_d3d11_filter_chain_t`. +/// - `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_free(libra_d3d11_filter_chain_t *chain); #endif +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// 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. +/// - `device` must not be null. +/// - `out` must be aligned, but may be null, invalid, or uninitialized. +libra_error_t libra_d3d9_filter_chain_create(libra_shader_preset_t *preset, + IDirect3DDevice9 * device, + const struct filter_chain_d3d9_opt_t *options, + libra_d3d9_filter_chain_t *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Draw a frame with the given parameters for the given filter chain. +/// +/// 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 `Id3d9Device` +/// +/// ## Safety +/// - `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_d3d9_opt_t` +/// struct. +/// - `out` must not be null. +/// - `image.handle` must not be null. +/// - If `device_context` is null, commands will be recorded onto the immediate context of the `Id3d9Device` +/// this filter chain was created with. The context must otherwise be associated with the `Id3d9Device` +/// the filter chain was created with. +/// - 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. +libra_error_t libra_d3d9_filter_chain_frame(libra_d3d9_filter_chain_t *chain, + size_t frame_count, + IDirect3DTexture9 * image, + struct libra_viewport_t viewport, + IDirect3DSurface9 * out, + const float *mvp, + const struct frame_d3d9_opt_t *options); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// 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_d3d9_filter_chain_t`. +/// - `param_name` must be either null or a null terminated string. +libra_error_t libra_d3d9_filter_chain_set_param(libra_d3d9_filter_chain_t *chain, + const char *param_name, + float value); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// 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_d3d9_filter_chain_t`. +/// - `param_name` must be either null or a null terminated string. +libra_error_t libra_d3d9_filter_chain_get_param(libra_d3d9_filter_chain_t *chain, + const char *param_name, + float *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// 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_d3d9_filter_chain_t`. +libra_error_t libra_d3d9_filter_chain_set_active_pass_count(libra_d3d9_filter_chain_t *chain, + uint32_t value); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// 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_d3d9_filter_chain_t`. +libra_error_t libra_d3d9_filter_chain_get_active_pass_count(libra_d3d9_filter_chain_t *chain, + uint32_t *out); +#endif + +#if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9)) +/// Free a d3d9 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_d3d9_filter_chain_t`. +libra_error_t libra_d3d9_filter_chain_free(libra_d3d9_filter_chain_t *chain); +#endif + #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// Create the filter chain given the shader preset. /// @@ -1500,16 +1666,15 @@ libra_error_t libra_d3d11_filter_chain_free(libra_d3d11_filter_chain_t *chain); /// - `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. -libra_error_t libra_d3d12_filter_chain_create( - libra_shader_preset_t *preset, ID3D12Device *device, - const struct filter_chain_d3d12_opt_t *options, - libra_d3d12_filter_chain_t *out); +libra_error_t libra_d3d12_filter_chain_create(libra_shader_preset_t *preset, + ID3D12Device * device, + const struct filter_chain_d3d12_opt_t *options, + libra_d3d12_filter_chain_t *out); #endif #if (defined(_WIN32) && 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. +/// 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. @@ -1521,55 +1686,48 @@ libra_error_t libra_d3d12_filter_chain_create( /// - `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); +/// 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 #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) -/// Records rendering commands for a frame with the given parameters for the -/// given filter chain to the input command list. +/// Records rendering commands for a frame with the given parameters for the given filter chain +/// to the input command list. /// -/// * 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. +/// * 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. +/// 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. /// /// ## Safety -/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or -/// invalid, this +/// - `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` +/// - `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_d3d12_opt_t` +/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_d3d12_opt_t` /// struct. /// - `out` must be a descriptor handle to a render target view. /// - `image.resource` must not be null. -/// - `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. -/// - You must ensure that only one thread has access to `chain` before you call -/// this function. Only one +/// - `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. +/// - 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. -libra_error_t libra_d3d12_filter_chain_frame( - libra_d3d12_filter_chain_t *chain, ID3D12GraphicsCommandList *command_list, - size_t frame_count, struct libra_source_image_d3d12_t image, - struct libra_viewport_t viewport, struct libra_output_image_d3d12_t out, - const float *mvp, const struct frame_d3d12_opt_t *options); +libra_error_t libra_d3d12_filter_chain_frame(libra_d3d12_filter_chain_t *chain, + ID3D12GraphicsCommandList * command_list, + size_t frame_count, + struct libra_source_image_d3d12_t image, + struct libra_viewport_t viewport, + struct libra_output_image_d3d12_t out, + const float *mvp, + const struct frame_d3d12_opt_t *options); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) @@ -1577,11 +1735,11 @@ libra_error_t libra_d3d12_filter_chain_frame( /// /// 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_d3d12_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. -libra_error_t libra_d3d12_filter_chain_set_param( - libra_d3d12_filter_chain_t *chain, const char *param_name, float value); +libra_error_t libra_d3d12_filter_chain_set_param(libra_d3d12_filter_chain_t *chain, + const char *param_name, + float value); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) @@ -1589,31 +1747,29 @@ libra_error_t libra_d3d12_filter_chain_set_param( /// /// 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_d3d12_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. -libra_error_t libra_d3d12_filter_chain_get_param( - libra_d3d12_filter_chain_t *chain, const char *param_name, float *out); +libra_error_t libra_d3d12_filter_chain_get_param(libra_d3d12_filter_chain_t *chain, + const char *param_name, + float *out); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// 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_d3d12_filter_chain_t`. -libra_error_t libra_d3d12_filter_chain_set_active_pass_count( - libra_d3d12_filter_chain_t *chain, uint32_t value); +/// - `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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) /// 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_d3d12_filter_chain_t`. -libra_error_t libra_d3d12_filter_chain_get_active_pass_count( - libra_d3d12_filter_chain_t *chain, uint32_t *out); +/// - `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); #endif #if (defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12)) @@ -1621,8 +1777,7 @@ libra_error_t libra_d3d12_filter_chain_get_active_pass_count( /// /// The resulting value in `chain` then becomes null. /// ## Safety -/// - `chain` must be either null or a valid and aligned pointer to an -/// initialized `libra_d3d12_filter_chain_t`. +/// - `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); #endif @@ -1639,16 +1794,15 @@ libra_error_t libra_d3d12_filter_chain_free(libra_d3d12_filter_chain_t *chain); /// - `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. -libra_error_t libra_mtl_filter_chain_create( - libra_shader_preset_t *preset, id queue, - const struct filter_chain_mtl_opt_t *options, - libra_mtl_filter_chain_t *out); +libra_error_t libra_mtl_filter_chain_create(libra_shader_preset_t *preset, + id queue, + const struct filter_chain_mtl_opt_t *options, + libra_mtl_filter_chain_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) -/// 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. +/// 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. @@ -1657,46 +1811,43 @@ libra_error_t libra_mtl_filter_chain_create( /// - `queue` must be valid for the command buffers /// that `libra_mtl_filter_chain_frame` will write to. /// - `queue` must be a reference to a `id`. -/// - `command_buffer` must be a valid reference to a `MTLCommandBuffer` that is -/// not already encoding. +/// - `command_buffer` must be a valid reference to a `MTLCommandBuffer` that is not already encoding. /// - `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_mtl_filter_chain_frame`. -libra_error_t libra_mtl_filter_chain_create_deferred( - libra_shader_preset_t *preset, id queue, - id command_buffer, - const struct filter_chain_mtl_opt_t *options, - libra_mtl_filter_chain_t *out); +/// 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_mtl_filter_chain_frame`. +libra_error_t libra_mtl_filter_chain_create_deferred(libra_shader_preset_t *preset, + id queue, + id command_buffer, + const struct filter_chain_mtl_opt_t *options, + libra_mtl_filter_chain_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) -/// Records rendering commands for a frame with the given parameters for the -/// given filter chain to the input command buffer. +/// Records rendering commands for a frame with the given parameters for the given filter chain +/// to the input command buffer. /// /// ## Safety -/// - `command_buffer` must be a valid reference to a `MTLCommandBuffer` that is -/// not already encoding. -/// - `chain` may be null, invalid, but not uninitialized. If `chain` is null or -/// invalid, this +/// - `command_buffer` must be a valid reference to a `MTLCommandBuffer` that is not already encoding. +/// - `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` +/// - `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_mtl_opt_t` +/// - `opt` may be null, or if it is not null, must be an aligned pointer to a valid `frame_mtl_opt_t` /// struct. -/// - You must ensure that only one thread has access to `chain` before you call -/// this function. Only one +/// - 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. -libra_error_t libra_mtl_filter_chain_frame( - libra_mtl_filter_chain_t *chain, id command_buffer, - size_t frame_count, id image, struct libra_viewport_t viewport, - id output, const float *mvp, const struct frame_mtl_opt_t *opt); +libra_error_t libra_mtl_filter_chain_frame(libra_mtl_filter_chain_t *chain, + id command_buffer, + size_t frame_count, + id image, + struct libra_viewport_t viewport, + id output, + const float *mvp, + const struct frame_mtl_opt_t *opt); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) @@ -1704,8 +1855,7 @@ libra_error_t libra_mtl_filter_chain_frame( /// /// 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_mtl_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. libra_error_t libra_mtl_filter_chain_set_param(libra_mtl_filter_chain_t *chain, const char *param_name, @@ -1717,8 +1867,7 @@ libra_error_t libra_mtl_filter_chain_set_param(libra_mtl_filter_chain_t *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_mtl_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`. /// - `param_name` must be either null or a null terminated string. libra_error_t libra_mtl_filter_chain_get_param(libra_mtl_filter_chain_t *chain, const char *param_name, @@ -1729,20 +1878,18 @@ libra_error_t libra_mtl_filter_chain_get_param(libra_mtl_filter_chain_t *chain, /// 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_mtl_filter_chain_t`. -libra_error_t libra_mtl_filter_chain_set_active_pass_count( - libra_mtl_filter_chain_t *chain, uint32_t value); +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`. +libra_error_t libra_mtl_filter_chain_set_active_pass_count(libra_mtl_filter_chain_t *chain, + uint32_t value); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) /// 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_mtl_filter_chain_t`. -libra_error_t libra_mtl_filter_chain_get_active_pass_count( - libra_mtl_filter_chain_t *chain, uint32_t *out); +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`. +libra_error_t libra_mtl_filter_chain_get_active_pass_count(libra_mtl_filter_chain_t *chain, + uint32_t *out); #endif #if (defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__)) @@ -1750,8 +1897,7 @@ libra_error_t libra_mtl_filter_chain_get_active_pass_count( /// /// The resulting value in `chain` then becomes null. /// ## Safety -/// - `chain` must be either null or a valid and aligned pointer to an -/// initialized `libra_mtl_filter_chain_t`. +/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`. libra_error_t libra_mtl_filter_chain_free(libra_mtl_filter_chain_t *chain); #endif @@ -1766,31 +1912,25 @@ LIBRASHADER_API_VERSION libra_instance_api_version(void); /// The C API does not allow directly setting certain variables /// /// - `PRESET_DIR` and `PRESET` are inferred on preset creation. -/// - `VID-DRV-SHADER-EXT` and `VID-DRV-PRESET-EXT` are always set to `slang` -/// and `slangp` for librashader. -/// - `VID-FINAL-ROT` is automatically calculated as the sum of `VID-USER-ROT` -/// and `CORE-REQ-ROT` if either are present. +/// - `VID-DRV-SHADER-EXT` and `VID-DRV-PRESET-EXT` are always set to `slang` and `slangp` for librashader. +/// - `VID-FINAL-ROT` is automatically calculated as the sum of `VID-USER-ROT` and `CORE-REQ-ROT` if either are present. /// -/// These automatically inferred variables, as well as all other variables can -/// be overridden with `libra_preset_ctx_set_param`, but the expected string -/// values must be provided. See -/// https://github.com/libretro/RetroArch/pull/15023 for a list of expected -/// string values. +/// These automatically inferred variables, as well as all other variables can be overridden with +/// `libra_preset_ctx_set_param`, but the expected string values must be provided. +/// See https://github.com/libretro/RetroArch/pull/15023 for a list of expected string values. /// -/// No variables can be removed once added to the context, however subsequent -/// calls to set the same variable will overwrite the expected variable. +/// No variables can be removed once added to the context, however subsequent calls to set the same +/// variable will overwrite the expected variable. /// ## Safety -/// - `out` must be either null, or an aligned pointer to an uninitialized or -/// invalid `libra_preset_ctx_t`. +/// - `out` must be either null, or an aligned pointer to an uninitialized or invalid `libra_preset_ctx_t`. /// ## Returns -/// - If any parameters are null, `out` is unchanged, and this function returns -/// `LIBRA_ERR_INVALID_PARAMETER`. +/// - If any parameters are null, `out` is unchanged, and this function returns `LIBRA_ERR_INVALID_PARAMETER`. libra_error_t libra_preset_ctx_create(libra_preset_ctx_t *out); /// Free the wildcard context. /// -/// If `context` is null, this function does nothing. The resulting value in -/// `context` then becomes null. +/// If `context` is null, this function does nothing. The resulting value in `context` then becomes +/// null. /// /// ## Safety /// - `context` must be a valid and aligned pointer to a `libra_preset_ctx_t` @@ -1799,33 +1939,29 @@ libra_error_t libra_preset_ctx_free(libra_preset_ctx_t *context); /// Set the core name (`CORE`) variable in the context /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. /// - `name` must be null or a valid and aligned pointer to a string. -libra_error_t libra_preset_ctx_set_core_name(libra_preset_ctx_t *context, - const char *name); +libra_error_t libra_preset_ctx_set_core_name(libra_preset_ctx_t *context, const char *name); /// Set the content directory (`CONTENT-DIR`) variable in the context. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. /// - `name` must be null or a valid and aligned pointer to a string. -libra_error_t libra_preset_ctx_set_content_dir(libra_preset_ctx_t *context, - const char *name); +libra_error_t libra_preset_ctx_set_content_dir(libra_preset_ctx_t *context, const char *name); /// Set a custom string variable in context. /// -/// If the path contains this variable when loading a preset, it will be -/// replaced with the provided contents. +/// If the path contains this variable when loading a preset, it will be replaced with the +/// provided contents. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. /// - `name` must be null or a valid and aligned pointer to a string. /// - `value` must be null or a valid and aligned pointer to a string. libra_error_t libra_preset_ctx_set_param(libra_preset_ctx_t *context, - const char *name, const char *value); + const char *name, + const char *value); /// Set the graphics runtime (`VID-DRV`) variable in the context. /// @@ -1835,16 +1971,14 @@ libra_error_t libra_preset_ctx_set_param(libra_preset_ctx_t *context, /// - GLCore /// - Direct3D11 /// - Direct3D12 -/// - Metal /// /// This will also set the appropriate video driver extensions. /// -/// For librashader, `VID-DRV-SHADER-EXT` and `VID-DRV-PRESET-EXT` are always -/// `slang` and `slangp`. To override this, use `libra_preset_ctx_set_param`. +/// For librashader, `VID-DRV-SHADER-EXT` and `VID-DRV-PRESET-EXT` are always `slang` and `slangp`. +/// To override this, use `libra_preset_ctx_set_param`. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. /// - `name` must be null or a valid and aligned pointer to a string. libra_error_t libra_preset_ctx_set_runtime(libra_preset_ctx_t *context, LIBRA_PRESET_CTX_RUNTIME value); @@ -1852,66 +1986,50 @@ libra_error_t libra_preset_ctx_set_runtime(libra_preset_ctx_t *context, /// Set the core requested rotation (`CORE-REQ-ROT`) variable in the context. /// /// Rotation is represented by quarter rotations around the unit circle. -/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = -/// 0deg. +/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = 0deg. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_core_rotation(libra_preset_ctx_t *context, - uint32_t value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_core_rotation(libra_preset_ctx_t *context, uint32_t value); /// Set the user rotation (`VID-USER-ROT`) variable in the context. /// /// Rotation is represented by quarter rotations around the unit circle. -/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = -/// 0deg. +/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = 0deg. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_user_rotation(libra_preset_ctx_t *context, - uint32_t value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_user_rotation(libra_preset_ctx_t *context, uint32_t value); /// Set the screen orientation (`SCREEN-ORIENT`) variable in the context. /// /// Orientation is represented by quarter rotations around the unit circle. -/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = -/// 0deg. +/// For example. `0` = 0deg, `1` = 90deg, `2` = 180deg, `3` = 270deg, `4` = 0deg. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_screen_orientation( - libra_preset_ctx_t *context, uint32_t value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_screen_orientation(libra_preset_ctx_t *context, uint32_t value); -/// Set whether or not to allow rotation (`VID-ALLOW-CORE-ROT`) variable in the -/// context. +/// Set whether or not to allow rotation (`VID-ALLOW-CORE-ROT`) variable in the context. /// /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_allow_rotation(libra_preset_ctx_t *context, - bool value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_allow_rotation(libra_preset_ctx_t *context, bool value); -/// Set the view aspect orientation (`VIEW-ASPECT-ORIENT`) variable in the -/// context. +/// Set the view aspect orientation (`VIEW-ASPECT-ORIENT`) variable in the context. /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_view_aspect_orientation( - libra_preset_ctx_t *context, LIBRA_PRESET_CTX_ORIENTATION value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_view_aspect_orientation(libra_preset_ctx_t *context, + LIBRA_PRESET_CTX_ORIENTATION value); -/// Set the core aspect orientation (`CORE-ASPECT-ORIENT`) variable in the -/// context. +/// Set the core aspect orientation (`CORE-ASPECT-ORIENT`) variable in the context. /// ## Safety -/// - `context` must be null or a valid and aligned pointer to a -/// `libra_preset_ctx_t`. -libra_error_t libra_preset_ctx_set_core_aspect_orientation( - libra_preset_ctx_t *context, LIBRA_PRESET_CTX_ORIENTATION value); +/// - `context` must be null or a valid and aligned pointer to a `libra_preset_ctx_t`. +libra_error_t libra_preset_ctx_set_core_aspect_orientation(libra_preset_ctx_t *context, + LIBRA_PRESET_CTX_ORIENTATION value); #ifdef __cplusplus -} // extern "C" -#endif // __cplusplus +} // extern "C" +#endif // __cplusplus #endif /* __LIBRASHADER_H__ */ diff --git a/include/librashader_ld.h b/include/librashader_ld.h index 59d7e16..dd9eaf0 100644 --- a/include/librashader_ld.h +++ b/include/librashader_ld.h @@ -393,6 +393,49 @@ libra_error_t __librashader__noop_d3d12_filter_chain_get_active_pass_count( } #endif +#if defined(LIBRA_RUNTIME_D3D9) +libra_error_t __librashader__noop_d3d9_filter_chain_create( + libra_shader_preset_t *preset, IDirect3DDevice9 *device, + const struct filter_chain_d3d9_opt_t *options, + libra_d3d9_filter_chain_t *out) { + *out = NULL; + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_frame( + libra_d3d9_filter_chain_t *chain, size_t frame_count, + IDirect3DTexture9 *image, struct libra_viewport_t viewport, + IDirect3DSurface9 * out, const float *mvp, + const struct frame_d3d9_opt_t *opt) { + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_free( + libra_d3d9_filter_chain_t *chain) { + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_set_param( + libra_d3d9_filter_chain_t *chain, const char *param_name, float value) { + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_get_param( + libra_d3d9_filter_chain_t *chain, const char *param_name, float *out) { + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_set_active_pass_count( + libra_d3d9_filter_chain_t *chain, uint32_t value) { + return NULL; +} + +libra_error_t __librashader__noop_d3d9_filter_chain_get_active_pass_count( + libra_d3d9_filter_chain_t *chain, uint32_t *out) { + return NULL; +} +#endif + #if defined(LIBRA_RUNTIME_METAL) libra_error_t __librashader__noop_mtl_filter_chain_create( libra_shader_preset_t *preset, id queue, @@ -1163,6 +1206,79 @@ typedef struct libra_instance_t { PFN_libra_d3d12_filter_chain_set_param d3d12_filter_chain_set_param; #endif +#if defined(LIBRA_RUNTIME_D3D9) + /// Create the filter chain given the shader preset. + /// + /// The shader preset is immediately invalidated and must be recreated after + /// the filter chain is created. + /// + /// If this function is not loaded, `out` will unconditionally be set to + /// null. If this function returns an error, the state of `out` is + /// unspecified. + /// + /// ## 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. + PFN_libra_d3d9_filter_chain_create d3d9_filter_chain_create; + + /// Draw a frame with the given parameters for the given filter chain. + /// + /// ## Safety + /// - `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_d3d9_opt_t` + /// struct. + PFN_libra_d3d9_filter_chain_frame d3d9_filter_chain_frame; + + /// Free a D3D9 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_d3d9_filter_chain_t`. + PFN_libra_d3d9_filter_chain_free d3d9_filter_chain_free; + + /// 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_d3d9_filter_chain_t`. + PFN_libra_d3d9_filter_chain_get_active_pass_count + d3d9_filter_chain_get_active_pass_count; + + /// 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_d3d9_filter_chain_t`. + PFN_libra_d3d9_filter_chain_set_active_pass_count + d3d9_filter_chain_set_active_pass_count; + + /// 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_d3d9_filter_chain_t`. + /// - `param_name` must be either null or a null terminated string. + PFN_libra_d3d9_filter_chain_get_param d3d9_filter_chain_get_param; + + /// 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_d3d9_filter_chain_t`. + /// - `param_name` must be either null or a null terminated string. + PFN_libra_d3d9_filter_chain_set_param d3d9_filter_chain_set_param; +#endif + #if defined(LIBRA_RUNTIME_METAL) /// Create the filter chain given the shader preset. /// @@ -1399,6 +1515,25 @@ libra_instance_t __librashader_make_null_instance(void) { __librashader__noop_d3d12_filter_chain_set_param; #endif +#if defined(LIBRA_RUNTIME_D3D9) + instance.d3d9_filter_chain_create = + __librashader__noop_d3d9_filter_chain_create; + instance.d3d9_filter_chain_create_deferred = + __librashader__noop_d3d9_filter_chain_create_deferred; + instance.d3d9_filter_chain_frame = + __librashader__noop_d3d9_filter_chain_frame; + instance.d3d9_filter_chain_free = + __librashader__noop_d3d9_filter_chain_free; + instance.d3d9_filter_chain_get_active_pass_count = + __librashader__noop_d3d9_filter_chain_get_active_pass_count; + instance.d3d9_filter_chain_set_active_pass_count = + __librashader__noop_d3d9_filter_chain_set_active_pass_count; + instance.d3d9_filter_chain_get_param = + __librashader__noop_d3d9_filter_chain_get_param; + instance.d3d9_filter_chain_set_param = + __librashader__noop_d3d9_filter_chain_set_param; +#endif + #if defined(LIBRA_RUNTIME_METAL) instance.mtl_filter_chain_create = __librashader__noop_mtl_filter_chain_create; @@ -1539,6 +1674,18 @@ libra_instance_t librashader_load_instance(void) { d3d12_filter_chain_set_active_pass_count); #endif +#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9) + _LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_create); + _LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_frame); + _LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_free); + _LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_get_param); + _LIBRASHADER_ASSIGN(librashader, instance, d3d9_filter_chain_set_param); + _LIBRASHADER_ASSIGN(librashader, instance, + d3d9_filter_chain_get_active_pass_count); + _LIBRASHADER_ASSIGN(librashader, instance, + d3d9_filter_chain_set_active_pass_count); +#endif + #if defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) _LIBRASHADER_ASSIGN(librashader, instance, mtl_filter_chain_create); _LIBRASHADER_ASSIGN(librashader, instance, diff --git a/librashader-capi/Cargo.toml b/librashader-capi/Cargo.toml index 25c885e..1e04d86 100644 --- a/librashader-capi/Cargo.toml +++ b/librashader-capi/Cargo.toml @@ -16,10 +16,12 @@ crate-type = [ "cdylib", "staticlib" ] [features] default = ["runtime-all" ] -runtime-all = ["runtime-opengl", "runtime-d3d11", "runtime-d3d12", "runtime-vulkan", "runtime-metal"] +runtime-all = ["runtime-opengl", "runtime-d3d9", "runtime-d3d11", "runtime-d3d12", "runtime-vulkan", "runtime-metal"] runtime-opengl = ["gl", "librashader/runtime-gl"] runtime-d3d11 = ["windows", "librashader/runtime-d3d11", "windows/Win32_Graphics_Direct3D11"] runtime-d3d12 = ["windows", "librashader/runtime-d3d12", "windows/Win32_Graphics_Direct3D12"] +runtime-d3d9 = ["windows", "librashader/runtime-d3d9", "windows/Win32_Graphics_Direct3D9"] + runtime-vulkan = ["ash", "librashader/runtime-vk"] runtime-metal = ["__cbindgen_internal_objc", "librashader/runtime-metal"] diff --git a/librashader-capi/cbindgen.toml b/librashader-capi/cbindgen.toml index 20387f1..05d9aa6 100644 --- a/librashader-capi/cbindgen.toml +++ b/librashader-capi/cbindgen.toml @@ -38,6 +38,9 @@ after_includes = """ #if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D12) #include #endif +#if defined(_WIN32) && defined(LIBRA_RUNTIME_D3D9) +#include +#endif #if defined(__APPLE__) && defined(LIBRA_RUNTIME_METAL) && defined(__OBJC__) #import #endif @@ -51,6 +54,7 @@ after_includes = """ "feature = runtime-vulkan" = "LIBRA_RUNTIME_VULKAN" "feature = runtime-d3d11" = "LIBRA_RUNTIME_D3D11" "feature = runtime-d3d12" = "LIBRA_RUNTIME_D3D12" +"feature = runtime-d3d9" = "LIBRA_RUNTIME_D3D9" "feature = runtime-metal" = "LIBRA_RUNTIME_METAL" "feature = __cbindgen_internal_objc" = "__OBJC__" @@ -137,6 +141,14 @@ include = [ "PFN_libra_d3d11_filter_chain_get_active_pass_count", "PFN_libra_d3d11_filter_chain_free", + # d3d11 + "PFN_libra_d3d9_filter_chain_create", + "PFN_libra_d3d9_filter_chain_frame", + "PFN_libra_d3d9_filter_chain_set_param", + "PFN_libra_d3d9_filter_chain_get_param", + "PFN_libra_d3d9_filter_chain_set_active_pass_count", + "PFN_libra_d3d9_filter_chain_get_active_pass_count", + "PFN_libra_d3d9_filter_chain_free", # d3d12 "PFN_libra_d3d12_filter_chain_create", @@ -176,6 +188,7 @@ exclude = [ "FilterChainVulkan" = "_filter_chain_vk" "FilterChainD3D11" = "_filter_chain_d3d11" "FilterChainD3D12" = "_filter_chain_d3d12" +"FilterChainD3D9" = "_filter_chain_d3d9" "FilterChainMetal" = "_filter_chain_mtl" # vulkan renames @@ -193,6 +206,11 @@ exclude = [ "ID3D11RenderTargetView" = "ID3D11RenderTargetView *" "ID3D11ShaderResourceView" = "ID3D11ShaderResourceView *" +# hack to get proper pointer indirection for COM pointers +"IDirect3DDevice9" = "IDirect3DDevice9 *" +"IDirect3DSurface9" = "IDirect3DSurface9 *" +"IDirect3DTexture9" = "IDirect3DTexture9 *" + # hack to force cbindgen to not generate option type for nullable ID3D11DeviceContext. "Option_ID3D11DeviceContext" = "ID3D11DeviceContext *" diff --git a/librashader-capi/src/ctypes.rs b/librashader-capi/src/ctypes.rs index 9bd7336..f6f29f0 100644 --- a/librashader-capi/src/ctypes.rs +++ b/librashader-capi/src/ctypes.rs @@ -90,6 +90,21 @@ use librashader::runtime::d3d12::FilterChain as FilterChainD3D12; ))] pub type libra_d3d12_filter_chain_t = Option>; +/// A handle to a Direct3D 9 filter chain. +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d9") +))] +use librashader::runtime::d3d9::FilterChain as FilterChainD3D9; + +/// A handle to a Direct3D 11 filter chain. +#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d9") +))] +pub type libra_d3d9_filter_chain_t = Option>; + #[cfg(feature = "runtime-vulkan")] use librashader::runtime::vk::FilterChain as FilterChainVulkan; /// A handle to a Vulkan filter chain. @@ -192,6 +207,8 @@ mod __cbindgen_opaque_forward_declarations { FilterChainD3D11; /// Opaque struct for a Direct3D 12 filter chain. FilterChainD3D12; + /// Opaque struct for a Direct3D 9 filter chain. + FilterChainD3D9; /// Opaque struct for a Vulkan filter chain. FilterChainVulkan; /// Opaque struct for a Metal filter chain. diff --git a/librashader-capi/src/error.rs b/librashader-capi/src/error.rs index bb5797d..3beb17a 100644 --- a/librashader-capi/src/error.rs +++ b/librashader-capi/src/error.rs @@ -37,6 +37,10 @@ pub enum LibrashaderError { #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))] #[error("There was an error in the D3D12 filter chain.")] D3D12FilterError(#[from] librashader::runtime::d3d12::error::FilterChainError), + #[cfg(all(target_os = "windows", feature = "runtime-d3d9"))] + #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))] + #[error("There was an error in the D3D9 filter chain.")] + D3D9FilterError(#[from] librashader::runtime::d3d9::error::FilterChainError), #[cfg(feature = "runtime-vulkan")] #[doc(cfg(feature = "runtime-vulkan"))] #[error("There was an error in the Vulkan filter chain.")] @@ -189,6 +193,8 @@ impl LibrashaderError { LibrashaderError::D3D11FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, #[cfg(all(target_os = "windows", feature = "runtime-d3d12"))] LibrashaderError::D3D12FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, + #[cfg(all(target_os = "windows", feature = "runtime-d3d9"))] + LibrashaderError::D3D9FilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, #[cfg(feature = "runtime-vulkan")] LibrashaderError::VulkanFilterError(_) => LIBRA_ERRNO::RUNTIME_ERROR, #[cfg(all(target_vendor = "apple", feature = "runtime-metal"))] diff --git a/librashader-capi/src/runtime/d3d9/filter_chain.rs b/librashader-capi/src/runtime/d3d9/filter_chain.rs new file mode 100644 index 0000000..8750e7d --- /dev/null +++ b/librashader-capi/src/runtime/d3d9/filter_chain.rs @@ -0,0 +1,259 @@ +use crate::ctypes::{ + config_struct, libra_d3d9_filter_chain_t, libra_shader_preset_t, libra_viewport_t, FromUninit, +}; +use crate::error::{assert_non_null, assert_some_ptr, LibrashaderError}; +use crate::ffi::extern_fn; +use librashader::runtime::d3d9::{FilterChain, FilterChainOptions, FrameOptions}; +use std::ffi::c_char; +use std::ffi::CStr; +use std::mem::{ManuallyDrop, MaybeUninit}; +use std::ptr::NonNull; +use std::slice; +use windows::Win32::Graphics::Direct3D9::{IDirect3DDevice9, IDirect3DSurface9, IDirect3DTexture9}; + +use crate::LIBRASHADER_API_VERSION; +use librashader::runtime::{FilterChainParameters, Viewport}; + +/// Options for Direct3D 11 filter chain creation. +#[repr(C)] +#[derive(Default, Debug, Clone)] +pub struct filter_chain_d3d9_opt_t { + /// The librashader API version. + pub version: LIBRASHADER_API_VERSION, + /// Whether or not to explicitly disable mipmap + /// generation regardless of shader preset settings. + pub force_no_mipmaps: bool, + /// Disable the shader object cache. Shaders will be + /// recompiled rather than loaded from the cache. + pub disable_cache: bool, +} + +config_struct! { + impl FilterChainOptions => filter_chain_d3d9_opt_t { + 0 => [force_no_mipmaps, disable_cache]; + } +} + +/// Options for each Direct3D 11 shader frame. +#[repr(C)] +#[derive(Default, Debug, Clone)] +pub struct frame_d3d9_opt_t { + /// The librashader API version. + pub version: LIBRASHADER_API_VERSION, + /// Whether or not to clear the history buffers. + pub clear_history: bool, + /// The direction of rendering. + /// -1 indicates that the frames are played in reverse order. + pub frame_direction: i32, + /// The rotation of the output. 0 = 0deg, 1 = 90deg, 2 = 180deg, 4 = 270deg. + pub rotation: u32, + /// The total number of subframes ran. Default is 1. + pub total_subframes: u32, + /// The current sub frame. Default is 1. + pub current_subframe: u32, +} + +config_struct! { + impl FrameOptions => frame_d3d9_opt_t { + 0 => [clear_history, frame_direction]; + 1 => [rotation, total_subframes, current_subframe] + } +} + +extern_fn! { + /// 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. + /// - `device` must not be null. + /// - `out` must be aligned, but may be null, invalid, or uninitialized. + fn libra_d3d9_filter_chain_create( + preset: *mut libra_shader_preset_t, + device: ManuallyDrop, + options: *const MaybeUninit, + out: *mut MaybeUninit + ) { + assert_non_null!(preset); + let preset = unsafe { + let preset_ptr = &mut *preset; + let preset = preset_ptr.take(); + Box::from_raw(preset.unwrap().as_ptr()) + }; + + let options = if options.is_null() { + None + } else { + Some(unsafe { options.read() }) + }; + + let options = options.map(FromUninit::from_uninit); + unsafe { + let chain = FilterChain::load_from_preset( + *preset, + &device, + options.as_ref(), + )?; + + out.write(MaybeUninit::new(NonNull::new(Box::into_raw(Box::new( + chain, + ))))) + } + } +} + +extern_fn! { + /// Draw a frame with the given parameters for the given filter chain. + /// + /// + /// ## Safety + /// - `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_d3d9_opt_t` + /// struct. + /// - `out` must not be null. + /// - `image` must not be null. + /// - 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. + nopanic fn libra_d3d9_filter_chain_frame( + chain: *mut libra_d3d9_filter_chain_t, + frame_count: usize, + image: ManuallyDrop, + viewport: libra_viewport_t, + out: ManuallyDrop, + mvp: *const f32, + options: *const MaybeUninit + ) mut |chain| { + assert_some_ptr!(mut chain); + + let mvp = if mvp.is_null() { + None + } else { + Some(<&[f32; 16]>::try_from(unsafe { slice::from_raw_parts(mvp, 16) }).unwrap()) + }; + + let options = if options.is_null() { + None + } else { + Some(unsafe { options.read() }) + }; + + let viewport = Viewport { + x: viewport.x, + y: viewport.y, + output: ManuallyDrop::into_inner(out.clone()), + mvp, + }; + + let options = options.map(FromUninit::from_uninit); + + + unsafe { + chain.frame(ManuallyDrop::into_inner(image.clone()), &viewport, frame_count, options.as_ref())?; + } + } +} + +extern_fn! { + /// 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_d3d9_filter_chain_t`. + /// - `param_name` must be either null or a null terminated string. + fn libra_d3d9_filter_chain_set_param( + chain: *mut libra_d3d9_filter_chain_t, + param_name: *const c_char, + value: f32 + ) mut |chain| { + assert_some_ptr!(mut chain); + assert_non_null!(param_name); + unsafe { + let name = CStr::from_ptr(param_name); + let name = name.to_str()?; + + if chain.set_parameter(name, value).is_none() { + return LibrashaderError::UnknownShaderParameter(param_name).export() + } + } + } +} + +extern_fn! { + /// 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_d3d9_filter_chain_t`. + /// - `param_name` must be either null or a null terminated string. + fn libra_d3d9_filter_chain_get_param( + chain: *mut libra_d3d9_filter_chain_t, + param_name: *const c_char, + out: *mut MaybeUninit + ) mut |chain| { + assert_some_ptr!(mut chain); + assert_non_null!(param_name); + unsafe { + let name = CStr::from_ptr(param_name); + let name = name.to_str()?; + + let Some(value) = chain.get_parameter(name) else { + return LibrashaderError::UnknownShaderParameter(param_name).export() + }; + + out.write(MaybeUninit::new(value)); + } + } +} + +extern_fn! { + /// 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_d3d9_filter_chain_t`. + fn libra_d3d9_filter_chain_set_active_pass_count( + chain: *mut libra_d3d9_filter_chain_t, + value: u32 + ) mut |chain| { + assert_some_ptr!(mut chain); + chain.set_enabled_pass_count(value as usize); + } +} + +extern_fn! { + /// 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_d3d9_filter_chain_t`. + fn libra_d3d9_filter_chain_get_active_pass_count( + chain: *mut libra_d3d9_filter_chain_t, + out: *mut MaybeUninit + ) mut |chain| { + assert_some_ptr!(mut chain); + unsafe { + let value = chain.get_enabled_pass_count(); + out.write(MaybeUninit::new(value as u32)) + } + } +} + +extern_fn! { + /// Free a d3d9 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_d3d9_filter_chain_t`. + fn libra_d3d9_filter_chain_free(chain: *mut libra_d3d9_filter_chain_t) { + assert_non_null!(chain); + unsafe { + let chain_ptr = &mut *chain; + let chain = chain_ptr.take(); + drop(Box::from_raw(chain.unwrap().as_ptr())) + }; + } +} diff --git a/librashader-capi/src/runtime/d3d9/mod.rs b/librashader-capi/src/runtime/d3d9/mod.rs new file mode 100644 index 0000000..1de4c4b --- /dev/null +++ b/librashader-capi/src/runtime/d3d9/mod.rs @@ -0,0 +1,5 @@ +//! C API for the librashader D3D9 Runtime (`libra_d3d9_*`). + +mod filter_chain; +pub use filter_chain::*; +const _: () = crate::assert_thread_safe::(); diff --git a/librashader-capi/src/runtime/mod.rs b/librashader-capi/src/runtime/mod.rs index 2eb2edc..5ec5506 100644 --- a/librashader-capi/src/runtime/mod.rs +++ b/librashader-capi/src/runtime/mod.rs @@ -14,6 +14,13 @@ pub mod vk; ))] pub mod d3d11; +#[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))] +#[cfg(any( + feature = "__cbindgen_internal", + all(target_os = "windows", feature = "runtime-d3d9") +))] +pub mod d3d9; + #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d12")))] #[cfg(any( feature = "__cbindgen_internal", diff --git a/librashader-common/src/d3d9.rs b/librashader-common/src/d3d9.rs index fdf38aa..1be70f9 100644 --- a/librashader-common/src/d3d9.rs +++ b/librashader-common/src/d3d9.rs @@ -44,7 +44,6 @@ impl From for ImageFormat { } } - impl From for Direct3D9::D3DTEXTUREADDRESS { fn from(value: WrapMode) -> Self { match value { diff --git a/librashader-runtime-d3d9/Cargo.toml b/librashader-runtime-d3d9/Cargo.toml index 158114e..1aacfdf 100644 --- a/librashader-runtime-d3d9/Cargo.toml +++ b/librashader-runtime-d3d9/Cargo.toml @@ -3,7 +3,7 @@ name = "librashader-runtime-d3d9" edition = "2021" license = "MPL-2.0 OR GPL-3.0-only" -version = "0.2.4" +version = "0.2.6" authors = ["Ronny Chan "] repository = "https://github.com/SnowflakePowered/librashader" readme = "../README.md" diff --git a/librashader-runtime-d3d9/src/d3dx.rs b/librashader-runtime-d3d9/src/d3dx.rs index 728b8ec..a7bfb0d 100644 --- a/librashader-runtime-d3d9/src/d3dx.rs +++ b/librashader-runtime-d3d9/src/d3dx.rs @@ -33,6 +33,8 @@ pub mod raw { } } +#[allow(dead_code)] +#[allow(non_snake_case)] #[inline] pub unsafe fn D3DXCompileShader( psrcdata: *const c_void, @@ -69,6 +71,8 @@ where #[repr(transparent)] #[derive(PartialEq, Eq, Debug, Clone)] pub struct ID3DXConstantTable(windows::core::IUnknown); + +#[allow(dead_code)] impl ID3DXConstantTable { #[allow(non_snake_case)] pub unsafe fn GetShaderConstantTable( @@ -370,6 +374,7 @@ pub struct D3DXCONSTANT_DESC { #[derive(PartialEq, Eq, Debug)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] +#[allow(dead_code)] pub enum D3DXREGISTER_SET { D3DXRS_BOOL = 0, D3DXRS_INT4 = 1, @@ -382,6 +387,7 @@ pub enum D3DXREGISTER_SET { #[derive(PartialEq, Eq, Debug)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] +#[allow(dead_code)] pub enum D3DXPARAMETER_CLASS { D3DXPC_SCALAR = 0, D3DXPC_VECTOR = 1, @@ -396,6 +402,7 @@ pub enum D3DXPARAMETER_CLASS { #[derive(Debug)] #[allow(non_camel_case_types)] #[allow(non_snake_case)] +#[allow(dead_code)] pub enum D3DXPARAMETER_TYPE { D3DXPT_VOID = 0, D3DXPT_BOOL = 1, diff --git a/librashader-runtime-d3d9/src/lib.rs b/librashader-runtime-d3d9/src/lib.rs index 2c58db3..45066a8 100644 --- a/librashader-runtime-d3d9/src/lib.rs +++ b/librashader-runtime-d3d9/src/lib.rs @@ -2,17 +2,17 @@ #![feature(type_alias_impl_trait)] #![feature(error_generic_member_access)] mod binding; +mod d3dx; mod draw_quad; +pub mod error; mod filter_chain; mod filter_pass; mod graphics_pipeline; mod luts; +pub mod options; mod samplers; mod texture; mod util; -mod d3dx; -pub mod error; -pub mod options; use librashader_runtime::impl_filter_chain_parameters; impl_filter_chain_parameters!(FilterChainD3D9); diff --git a/librashader-runtime-d3d9/src/texture.rs b/librashader-runtime-d3d9/src/texture.rs index 8f05a56..bbd2fad 100644 --- a/librashader-runtime-d3d9/src/texture.rs +++ b/librashader-runtime-d3d9/src/texture.rs @@ -8,7 +8,7 @@ use librashader_runtime::binding::TextureInput; use librashader_runtime::scaling::{ScaleFramebuffer, ViewportSize}; use windows::Win32::Graphics::Direct3D9::{ IDirect3DDevice9, IDirect3DSurface9, IDirect3DTexture9, D3DCLEAR_TARGET, D3DFORMAT, - D3DPOOL_DEFAULT, D3DTEXF_LINEAR, D3DUSAGE_DYNAMIC, D3DUSAGE_RENDERTARGET, + D3DPOOL_DEFAULT, D3DTEXF_LINEAR, D3DUSAGE_RENDERTARGET, }; /// An image view for use as a shader resource. diff --git a/librashader/Cargo.toml b/librashader/Cargo.toml index 5b74aa9..f4bde58 100644 --- a/librashader/Cargo.toml +++ b/librashader/Cargo.toml @@ -21,6 +21,7 @@ librashader-cache = { path = "../librashader-cache", version = "0.2.6" } librashader-runtime = { path = "../librashader-runtime", version = "0.2.6" } librashader-runtime-d3d11 = { path = "../librashader-runtime-d3d11", version = "0.2.6", optional = true } librashader-runtime-d3d12 = { path = "../librashader-runtime-d3d12", version = "0.2.6", optional = true } +librashader-runtime-d3d9 = { path = "../librashader-runtime-d3d9", version = "0.2.6", optional = true } librashader-runtime-gl = { path = "../librashader-runtime-gl", version = "0.2.6", optional = true } librashader-runtime-vk = { path = "../librashader-runtime-vk", version = "0.2.6", optional = true } librashader-runtime-mtl = { path = "../librashader-runtime-mtl", version = "0.2.6", optional = true } @@ -53,6 +54,8 @@ presets = [] runtime-gl = [ "runtime", "reflect-cross", "librashader-common/opengl", "librashader-runtime-gl" ] runtime-d3d11 = [ "runtime", "reflect-cross","librashader-common/d3d11", "librashader-runtime-d3d11", "windows/Win32_Graphics_Direct3D11" ] runtime-d3d12 = [ "runtime", "reflect-cross", "reflect-dxil", "librashader-common/d3d12", "librashader-runtime-d3d12", "windows/Win32_Graphics_Direct3D12" ] +runtime-d3d9 = [ "runtime", "reflect-cross", "librashader-common/d3d9", "librashader-runtime-d3d9", "windows/Win32_Graphics_Direct3D9" ] + runtime-vk = ["runtime", "reflect-cross", "librashader-common/vulkan", "librashader-runtime-vk", "ash" ] runtime-wgpu = [ "runtime", "reflect-naga", "librashader-common/wgpu", "librashader-runtime-wgpu", "wgpu", "wgpu-types" ] runtime-metal = [ "runtime", "reflect-naga", "reflect-cross", "librashader-common/metal", "librashader-runtime-mtl", "icrate", "objc2" ] diff --git a/librashader/src/lib.rs b/librashader/src/lib.rs index 198c18c..be2dc0a 100644 --- a/librashader/src/lib.rs +++ b/librashader/src/lib.rs @@ -24,6 +24,9 @@ //! The Vulkan runtime can use [`VK_KHR_dynamic_rendering`](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_dynamic_rendering.html) //! for improved performance, if the underlying hardware supports it. //! +//! Direct3D 9 support is experimental and is not guaranteed to work with all shaders. In particular, history and feedback is currently not supported. +//! Many shaders will also fail to compile due to missing or insufficient features in Direct3D 9. +//! //! wgpu support is not available in the librashader C API. //! //! | **API** | **Status** | **`librashader` feature** | @@ -31,6 +34,7 @@ //! | OpenGL 3.3+ | ✔ | `gl` | //! | OpenGL 4.6 | ✔ | `gl` | //! | Vulkan | ✔ | `vk` | +//! | Direct3D 9 | ⚠️ | `d3d9` | //! | Direct3D 11 | ✔ | `d3d11` | //! | Direct3D 12 | ✔ | `d3d12` | //! | wgpu | ✔ | `wgpu` | @@ -270,6 +274,19 @@ pub mod runtime { }; } + #[cfg(all(target_os = "windows", feature = "runtime-d3d9"))] + #[doc(cfg(all(target_os = "windows", feature = "runtime-d3d9")))] + /// Shader runtime for Direct3D 9. + pub mod d3d9 { + pub use librashader_runtime_d3d9::{ + error, + options::{ + FilterChainOptionsD3D9 as FilterChainOptions, FrameOptionsD3D9 as FrameOptions, + }, + FilterChainD3D9 as FilterChain, + }; + } + #[cfg(feature = "runtime-vk")] #[doc(cfg(feature = "runtime-vk"))] /// Shader runtime for Vulkan.