Zebediah Figura : vkd3d: Allow writing log output via a custom callback.

Alexandre Julliard julliard at winehq.org
Tue Jun 7 15:36:06 CDT 2022


Module: vkd3d
Branch: master
Commit: 46b12668098a26eabb57ae545de2ed85d2e9117e
URL:    https://source.winehq.org/git/vkd3d.git/?a=commit;h=46b12668098a26eabb57ae545de2ed85d2e9117e

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Wed Jun  1 19:01:01 2022 -0500

vkd3d: Allow writing log output via a custom callback.

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>
Signed-off-by: Giovanni Mascellani <gmascellani at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 bce3c6e4..f3c3fdc6 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 6f1f3761..441b2e35 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 21d998bf..88301fbb 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-cvs mailing list