[PATCH vkd3d 2/3] vkd3d: Allow writing log output via a custom callback.

Giovanni Mascellani gmascellani at codeweavers.com
Thu Jun 2 10:15:15 CDT 2022


Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>

Il 02/06/22 02:01, Zebediah Figura ha scritto:
> When using PE vkd3d through Wine, debug output may be swallowed by writing to
> Win32 stderr. Avoid this by providing a way to hook up vkd3d log output to Wine
> output.
> 
> Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
> ---
>   include/vkd3d.h         | 17 +++++++++++++++++
>   libs/vkd3d/vkd3d.map    |  1 +
>   libs/vkd3d/vkd3d_main.c |  6 ++++++
>   3 files changed, 24 insertions(+)
> 
> diff --git a/include/vkd3d.h b/include/vkd3d.h
> index bce3c6e4b..f3c3fdc68 100644
> --- a/include/vkd3d.h
> +++ b/include/vkd3d.h
> @@ -212,6 +212,20 @@ VKD3D_API HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED
>   VKD3D_API HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZE_T data_size,
>           REFIID iid, void **deserializer);
>   
> +/**
> + * Set a callback to be called when vkd3d outputs debug logging.
> + *
> + * If NULL, or if this function has not been called, libvkd3d will print all
> + * enabled log output to stderr.
> + *
> + * Calling this function will also set the log callback for libvkd3d-shader.
> + *
> + * \param callback Callback function to set.
> + *
> + * \since 1.4
> + */
> +VKD3D_API void vkd3d_set_log_callback(PFN_vkd3d_log callback);
> +
>   #endif  /* VKD3D_NO_PROTOTYPES */
>   
>   /*
> @@ -255,6 +269,9 @@ typedef HRESULT (*PFN_vkd3d_serialize_versioned_root_signature)(const D3D12_VERS
>   typedef HRESULT (*PFN_vkd3d_create_versioned_root_signature_deserializer)(const void *data, SIZE_T data_size,
>           REFIID iid, void **deserializer);
>   
> +/** Type of vkd3d_set_log_callback(). \since 1.4 */
> +typedef void (*PFN_vkd3d_set_log_callback)(PFN_vkd3d_log callback);
> +
>   #ifdef __cplusplus
>   }
>   #endif  /* __cplusplus */
> diff --git a/libs/vkd3d/vkd3d.map b/libs/vkd3d/vkd3d.map
> index 6f1f37611..441b2e35b 100644
> --- a/libs/vkd3d/vkd3d.map
> +++ b/libs/vkd3d/vkd3d.map
> @@ -22,6 +22,7 @@ global:
>       vkd3d_resource_incref;
>       vkd3d_serialize_root_signature;
>       vkd3d_serialize_versioned_root_signature;
> +    vkd3d_set_log_callback;
>   
>   local: *;
>   };
> diff --git a/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/vkd3d_main.c
> index 21d998bf9..88301fbb3 100644
> --- a/libs/vkd3d/vkd3d_main.c
> +++ b/libs/vkd3d/vkd3d_main.c
> @@ -510,3 +510,9 @@ HRESULT vkd3d_serialize_versioned_root_signature(const D3D12_VERSIONED_ROOT_SIGN
>       }
>       return hr;
>   }
> +
> +void vkd3d_set_log_callback(PFN_vkd3d_log callback)
> +{
> +    vkd3d_shader_set_log_callback(callback);
> +    vkd3d_dbg_set_log_callback(callback);
> +}



More information about the wine-devel mailing list