[Mesa-dev] [PATCH v2 1/6] gallium: add pipe_context::set_device_reset_callback
Nicolai Hähnle
nhaehnle at gmail.com
Tue Oct 4 08:11:19 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/docs/source/context.rst | 15 +++++++++++++++
src/gallium/include/pipe/p_context.h | 8 ++++++++
src/gallium/include/pipe/p_state.h | 19 +++++++++++++++++++
3 files changed, 42 insertions(+)
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 13dd606..e190cef 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -685,10 +685,25 @@ be used to bind a number of sampler views to it.
Mipmap generation
^^^^^^^^^^^^^^^^^
If PIPE_CAP_GENERATE_MIPMAP is true, ``generate_mipmap`` can be used
to generate mipmaps for the specified texture resource.
It replaces texel image levels base_level+1 through
last_level for layers range from first_layer through last_layer.
It returns TRUE if mipmap generation succeeds, otherwise it
returns FALSE. Mipmap generation may fail when it is not supported
for particular texture types or formats.
+
+Device resets
+^^^^^^^^^^^^^
+
+The state tracker can query or request notifications of when the GPU
+is reset for whatever reason (application error, driver error). When
+a GPU reset happens, the context becomes unusable and all related state
+should be considered lost and undefined. Despite that, context
+notifications are single-shot, i.e. subsequent calls to
+``get_device_reset_status`` will return PIPE_NO_RESET.
+
+* ``get_device_reset_status`` queries whether a device reset has happened
+ since the last call or since the last notification by callback.
+* ``set_device_reset_callback`` sets a callback which will be called when
+ a device reset is detected. The callback is only called synchronously.
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index f5841d7..b97aad5 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -40,20 +40,21 @@ extern "C" {
struct pipe_blend_color;
struct pipe_blend_state;
struct pipe_blit_info;
struct pipe_box;
struct pipe_clip_state;
struct pipe_constant_buffer;
struct pipe_debug_callback;
struct pipe_depth_stencil_alpha_state;
+struct pipe_device_reset_callback;
struct pipe_draw_info;
struct pipe_grid_info;
struct pipe_fence_handle;
struct pipe_framebuffer_state;
struct pipe_image_view;
struct pipe_index_buffer;
struct pipe_query;
struct pipe_poly_stipple;
struct pipe_rasterizer_state;
struct pipe_resolve_info;
@@ -684,20 +685,27 @@ struct pipe_context {
*/
void (*invalidate_resource)(struct pipe_context *ctx,
struct pipe_resource *resource);
/**
* Return information about unexpected device resets.
*/
enum pipe_reset_status (*get_device_reset_status)(struct pipe_context *ctx);
/**
+ * Sets the reset status callback. If the pointer is null, then no callback
+ * is set, otherwise a copy of the data should be made.
+ */
+ void (*set_device_reset_callback)(struct pipe_context *ctx,
+ const struct pipe_device_reset_callback *cb);
+
+ /**
* Dump driver-specific debug information into a stream. This is
* used by debugging tools.
*
* \param ctx pipe context
* \param stream where the output should be written to
* \param flags a mask of PIPE_DUMP_* flags
*/
void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream,
unsigned flags);
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 415ea85..46df196 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -824,20 +824,39 @@ struct pipe_debug_callback
*/
void (*debug_message)(void *data,
unsigned *id,
enum pipe_debug_type type,
const char *fmt,
va_list args);
void *data;
};
/**
+ * Structure that contains a callback for device reset messages from the driver
+ * back to the state tracker.
+ *
+ * The callback must not be called from driver-created threads.
+ */
+struct pipe_device_reset_callback
+{
+ /**
+ * Callback for the driver to report when a device reset is detected.
+ *
+ * \param data user-supplied data pointer
+ * \param status PIPE_*_RESET
+ */
+ void (*reset)(void *data, enum pipe_reset_status status);
+
+ void *data;
+};
+
+/**
* Information about memory usage. All sizes are in kilobytes.
*/
struct pipe_memory_info
{
unsigned total_device_memory; /**< size of device memory, e.g. VRAM */
unsigned avail_device_memory; /**< free device memory at the moment */
unsigned total_staging_memory; /**< size of staging memory, e.g. GART */
unsigned avail_staging_memory; /**< free staging memory at the moment */
unsigned device_memory_evicted; /**< size of memory evicted (monotonic counter) */
unsigned nr_device_memory_evictions; /**< # of evictions (monotonic counter) */
--
2.7.4
More information about the mesa-dev
mailing list