capi: const qualify chain in _filter_chain_get_param and _filter_chain_get_active_pass_count"

This reverts commit 98d8d91c66.
This commit is contained in:
chyyran 2024-09-13 17:22:51 -04:00 committed by Ronny Chan
parent 7abd679bd7
commit e4eed34c10
10 changed files with 44 additions and 42 deletions

View file

@ -34,7 +34,7 @@ The following changes are applicable if `LIBRA_RUNTIME_VULKAN` is defined.
* The `image` and `out` parameters of `libra_vk_filter_chain_frame` has changed from `libra_source_image_vk_t` and `libra_output_image_vk_t`, to `libra_image_vk_t`.
* In `libra_vk_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_vk_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_vk_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_vk_filter_chain_set_param` from any thread [^1].
## `LIBRA_RUNTIME_OPENGL` changes
@ -49,7 +49,7 @@ The following changes are applicable if `LIBRA_RUNTIME_METAL` is defined.
* The `fbo` field previously in `libra_output_image_gl_t` is no longer necessary. librashader will now internally manage a framebuffer object to write to the provided texture.
* In `libra_gl_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_gl_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_gl_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_gl_filter_chain_set_param` from any thread [^1].
## `LIBRA_RUNTIME_D3D11` changes
@ -60,7 +60,7 @@ The following changes are applicable if `LIBRA_RUNTIME_D3D11` is defined.
* The `libra_source_image_d3d11_t` struct has been removed.
* In `libra_d3d11_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_d3d11_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_d3d11_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_d3d11_filter_chain_set_param` from any thread [^1].
## `LIBRA_RUNTIME_D3D12` changes
@ -71,7 +71,7 @@ The following changes are applicable if `LIBRA_RUNTIME_D3D12` is defined.
* You should now pass what was previously `.width` and `.height` of `libra_viewport_t` to these new fields in `libra_output_image_d3d12_t`.
* In `libra_d3d12_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_d3d12_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_d3d12_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_d3d12_filter_chain_set_param` from any thread [^1].
## `LIBRA_RUNTIME_D3D9` changes
@ -79,7 +79,7 @@ The following changes are applicable if `LIBRA_RUNTIME_D3D9` is defined.
* In `libra_d3d9_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_d3d9_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_d3d9_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_d3d9_filter_chain_set_param` from any thread [^1].
## `LIBRA_RUNTIME_METAL` changes
@ -87,7 +87,7 @@ The following changes are applicable if `LIBRA_RUNTIME_METAL` is defined.
* In `libra_mtl_filter_chain_frame`, the position of the `viewport` parameter has moved to after the `out` parameter, and its type has changed from `libra_viewport_t` to `libra_viewport_t *`, which is allowed to be `NULL`.
See [`libra_viewport_t` changes](#libra_viewport_t-changes) for more details.
* The `chain` parameter of `libra_mtl_filter_chain_get_param` has been made `const` [^1].
* The `chain` parameter of `libra_mtl_filter_chain_get_param` has been made `const`.
* It is always thread safe to call `libra_mtl_filter_chain_set_param` from any thread [^1].
## `libra_viewport_t` changes

View file

@ -515,7 +515,7 @@ typedef libra_error_t (*PFN_libra_preset_set_param)(libra_shader_preset_t *prese
/// Function pointer definition for
///libra_preset_get_param
typedef libra_error_t (*PFN_libra_preset_get_param)(libra_shader_preset_t *preset,
typedef libra_error_t (*PFN_libra_preset_get_param)(const libra_shader_preset_t *preset,
const char *name,
float *value);
@ -525,7 +525,7 @@ 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,
typedef libra_error_t (*PFN_libra_preset_get_runtime_params)(const libra_shader_preset_t *preset,
struct libra_preset_param_list_t *out);
/// Function pointer definition for
@ -659,7 +659,7 @@ typedef libra_error_t (*PFN_libra_gl_filter_chain_set_active_pass_count)(libra_g
#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,
typedef libra_error_t (*PFN_libra_gl_filter_chain_get_active_pass_count)(const libra_gl_filter_chain_t *chain,
uint32_t *out);
#endif
@ -1125,7 +1125,9 @@ libra_error_t libra_preset_set_param(libra_shader_preset_t *preset, const char *
/// - `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(const libra_shader_preset_t *preset,
const char *name,
float *value);
/// Pretty print the shader preset.
///
@ -1143,7 +1145,7 @@ libra_error_t libra_preset_print(libra_shader_preset_t *preset);
/// cause undefined behaviour when later freed.
/// - 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,
libra_error_t libra_preset_get_runtime_params(const libra_shader_preset_t *preset,
struct libra_preset_param_list_t *out);
/// Free the runtime parameters.
@ -1261,7 +1263,7 @@ libra_error_t libra_gl_filter_chain_set_active_pass_count(libra_gl_filter_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,
libra_error_t libra_gl_filter_chain_get_active_pass_count(const libra_gl_filter_chain_t *chain,
uint32_t *out);
#endif

View file

@ -178,7 +178,7 @@ libra_error_t __librashader__noop_preset_set_param(
}
libra_error_t __librashader__noop_preset_get_param(
libra_shader_preset_t *preset, const char *name, float *value) {
const libra_shader_preset_t *preset, const char *name, float *value) {
return NULL;
}
@ -186,7 +186,7 @@ libra_error_t __librashader__noop_preset_print(libra_shader_preset_t *preset) {
return NULL;
}
libra_error_t __librashader__noop_preset_get_runtime_params(
libra_shader_preset_t *preset, struct libra_preset_param_list_t *out) {
const libra_shader_preset_t *preset, struct libra_preset_param_list_t *out) {
return NULL;
}
libra_error_t __librashader__noop_preset_free_runtime_params(
@ -221,7 +221,7 @@ libra_error_t __librashader__noop_gl_filter_chain_set_param(
}
libra_error_t __librashader__noop_gl_filter_chain_get_param(
libra_gl_filter_chain_t *chain, const char *param_name, float *out) {
const libra_gl_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -231,7 +231,7 @@ libra_error_t __librashader__noop_gl_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_gl_filter_chain_get_active_pass_count(
libra_gl_filter_chain_t *chain, uint32_t *out) {
const libra_gl_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
@ -271,7 +271,7 @@ libra_error_t __librashader__noop_vk_filter_chain_set_param(
}
libra_error_t __librashader__noop_vk_filter_chain_get_param(
libra_vk_filter_chain_t *chain, const char *param_name, float *out) {
const libra_vk_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -281,7 +281,7 @@ libra_error_t __librashader__noop_vk_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_vk_filter_chain_get_active_pass_count(
libra_vk_filter_chain_t *chain, uint32_t *out) {
const libra_vk_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
@ -323,7 +323,7 @@ libra_error_t __librashader__noop_d3d11_filter_chain_set_param(
}
libra_error_t __librashader__noop_d3d11_filter_chain_get_param(
libra_d3d11_filter_chain_t *chain, const char *param_name, float *out) {
const libra_d3d11_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -333,7 +333,7 @@ libra_error_t __librashader__noop_d3d11_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_d3d11_filter_chain_get_active_pass_count(
libra_d3d11_filter_chain_t *chain, uint32_t *out) {
const libra_d3d11_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
@ -375,7 +375,7 @@ libra_error_t __librashader__noop_d3d12_filter_chain_set_param(
}
libra_error_t __librashader__noop_d3d12_filter_chain_get_param(
libra_d3d12_filter_chain_t *chain, const char *param_name, float *out) {
const libra_d3d12_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -385,7 +385,7 @@ libra_error_t __librashader__noop_d3d12_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_d3d12_filter_chain_get_active_pass_count(
libra_d3d12_filter_chain_t *chain, uint32_t *out) {
const libra_d3d12_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
@ -418,7 +418,7 @@ libra_error_t __librashader__noop_d3d9_filter_chain_set_param(
}
libra_error_t __librashader__noop_d3d9_filter_chain_get_param(
libra_d3d9_filter_chain_t *chain, const char *param_name, float *out) {
const libra_d3d9_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -428,7 +428,7 @@ libra_error_t __librashader__noop_d3d9_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_d3d9_filter_chain_get_active_pass_count(
libra_d3d9_filter_chain_t *chain, uint32_t *out) {
const libra_d3d9_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif
@ -470,7 +470,7 @@ libra_error_t __librashader__noop_mtl_filter_chain_set_param(
}
libra_error_t __librashader__noop_mtl_filter_chain_get_param(
libra_mtl_filter_chain_t *chain, const char *param_name, float *out) {
const libra_mtl_filter_chain_t *chain, const char *param_name, float *out) {
return NULL;
}
@ -480,7 +480,7 @@ libra_error_t __librashader__noop_mtl_filter_chain_set_active_pass_count(
}
libra_error_t __librashader__noop_mtl_filter_chain_get_active_pass_count(
libra_mtl_filter_chain_t *chain, uint32_t *out) {
const libra_mtl_filter_chain_t *chain, uint32_t *out) {
return NULL;
}
#endif

View file

@ -157,7 +157,7 @@ extern_fn! {
/// - `name` must be null or a valid and aligned pointer to a string.
/// - `value` may be a pointer to a uninitialized `float`.
fn libra_preset_get_param(
preset: *mut libra_shader_preset_t,
preset: *const libra_shader_preset_t,
name: *const c_char,
value: *mut MaybeUninit<f32>
) |name, preset| {
@ -195,7 +195,7 @@ extern_fn! {
/// - It is safe to call `libra_preset_get_runtime_params` multiple times, however
/// the output struct must only be freed once per call.
fn libra_preset_get_runtime_params(
preset: *mut libra_shader_preset_t,
preset: *const libra_shader_preset_t,
out: *mut MaybeUninit<libra_preset_param_list_t>
) |preset| {
assert_some_ptr!(preset);

View file

@ -298,7 +298,7 @@ extern_fn! {
/// - `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.
fn libra_d3d11_filter_chain_get_param(
chain: *mut libra_d3d11_filter_chain_t,
chain: *const libra_d3d11_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -337,7 +337,7 @@ extern_fn! {
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d11_filter_chain_t`.
fn libra_d3d11_filter_chain_get_active_pass_count(
chain: *mut libra_d3d11_filter_chain_t,
chain: *const libra_d3d11_filter_chain_t,
out: *mut MaybeUninit<u32>
) |chain| {
assert_some_ptr!(chain);

View file

@ -335,7 +335,7 @@ extern_fn! {
/// - `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.
fn libra_d3d12_filter_chain_get_param(
chain: *mut libra_d3d12_filter_chain_t,
chain: *const libra_d3d12_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -374,7 +374,7 @@ extern_fn! {
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_d3d12_filter_chain_t`.
fn libra_d3d12_filter_chain_get_active_pass_count(
chain: *mut libra_d3d12_filter_chain_t,
chain: *const libra_d3d12_filter_chain_t,
out: *mut MaybeUninit<u32>
) |chain| {
assert_some_ptr!(chain);

View file

@ -217,7 +217,7 @@ extern_fn! {
/// - `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,
chain: *const libra_d3d9_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -256,7 +256,7 @@ extern_fn! {
/// ## 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,
chain: *const libra_d3d9_filter_chain_t,
out: *mut MaybeUninit<u32>
) |chain| {
assert_some_ptr!(chain);

View file

@ -255,7 +255,7 @@ extern_fn! {
/// - `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.
fn libra_gl_filter_chain_get_param(
chain: *mut libra_gl_filter_chain_t,
chain: *const libra_gl_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -294,10 +294,10 @@ extern_fn! {
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_gl_filter_chain_t`.
fn libra_gl_filter_chain_get_active_pass_count(
chain: *mut libra_gl_filter_chain_t,
chain: *const libra_gl_filter_chain_t,
out: *mut MaybeUninit<u32>
) mut |chain| {
assert_some_ptr!(mut chain);
) |chain| {
assert_some_ptr!(chain);
let value = chain.parameters().passes_enabled();
unsafe {
out.write(MaybeUninit::new(value as u32))

View file

@ -276,7 +276,7 @@ extern_fn! {
/// - `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.
fn libra_mtl_filter_chain_get_param(
chain: *mut libra_mtl_filter_chain_t,
chain: *const libra_mtl_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -315,7 +315,7 @@ extern_fn! {
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_mtl_filter_chain_t`.
fn libra_mtl_filter_chain_get_active_pass_count(
chain: *mut libra_mtl_filter_chain_t,
chain: *const libra_mtl_filter_chain_t,
out: *mut MaybeUninit<u32>
) |chain| {
assert_some_ptr!(chain);

View file

@ -357,7 +357,7 @@ extern_fn! {
/// - `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.
fn libra_vk_filter_chain_get_param(
chain: *mut libra_vk_filter_chain_t,
chain: *const libra_vk_filter_chain_t,
param_name: *const c_char,
out: *mut MaybeUninit<f32>
) |chain| {
@ -396,7 +396,7 @@ extern_fn! {
/// ## Safety
/// - `chain` must be either null or a valid and aligned pointer to an initialized `libra_vk_filter_chain_t`.
fn libra_vk_filter_chain_get_active_pass_count(
chain: *mut libra_vk_filter_chain_t,
chain: *const libra_vk_filter_chain_t,
out: *mut MaybeUninit<u32>
) |chain| {
assert_some_ptr!(chain);