static struct radeon_winsys_ctx *radeon_drm_ctx_create(struct radeon_winsys *ws)
{
- /* No context support here. Just return the winsys pointer
- * as the "context". */
- return (struct radeon_winsys_ctx*)ws;
+ struct radeon_ctx *ctx = CALLOC_STRUCT(radeon_ctx);
+ if (!ctx)
+ return NULL;
+
+ ctx->ws = (struct radeon_drm_winsys*)ws;
+ ctx->gpu_reset_counter = radeon_drm_get_gpu_reset_counter(ctx->ws);
+ return (struct radeon_winsys_ctx*)ctx;
}
static void radeon_drm_ctx_destroy(struct radeon_winsys_ctx *ctx)
{
- /* No context support here. */
+ FREE(ctx);
+}
+
+static enum pipe_reset_status
+radeon_drm_ctx_query_reset_status(struct radeon_winsys_ctx *rctx)
+{
+ struct radeon_ctx *ctx = (struct radeon_ctx*)rctx;
+
+ unsigned latest = radeon_drm_get_gpu_reset_counter(ctx->ws);
+
+ if (ctx->gpu_reset_counter == latest)
+ return PIPE_NO_RESET;
+
+ ctx->gpu_reset_counter = latest;
+ return PIPE_UNKNOWN_CONTEXT_RESET;
}
static bool radeon_init_cs_context(struct radeon_cs_context *csc,
void *flush_ctx,
bool stop_exec_on_failure)
{
- struct radeon_drm_winsys *ws = (struct radeon_drm_winsys*)ctx;
+ struct radeon_drm_winsys *ws = ((struct radeon_ctx*)ctx)->ws;
struct radeon_drm_cs *cs;
cs = CALLOC_STRUCT(radeon_drm_cs);
{
ws->base.ctx_create = radeon_drm_ctx_create;
ws->base.ctx_destroy = radeon_drm_ctx_destroy;
+ ws->base.ctx_query_reset_status = radeon_drm_ctx_query_reset_status;
ws->base.cs_create = radeon_drm_cs_create;
ws->base.cs_destroy = radeon_drm_cs_destroy;
ws->base.cs_add_buffer = radeon_drm_cs_add_buffer;
ws->info.drm_minor >= 38;
ws->info.si_TA_CS_BC_BASE_ADDR_allowed = ws->info.drm_minor >= 48;
ws->info.has_bo_metadata = false;
- ws->info.has_gpu_reset_status_query = false;
+ ws->info.has_gpu_reset_status_query = ws->info.drm_minor >= 43;
ws->info.has_gpu_reset_counter_query = ws->info.drm_minor >= 43;
ws->info.has_eqaa_surface_allocator = false;
ws->info.has_format_bc1_through_bc7 = ws->info.drm_minor >= 31;
return false;
}
+uint32_t radeon_drm_get_gpu_reset_counter(struct radeon_drm_winsys *ws)
+{
+ uint64_t retval = 0;
+
+ if (!ws->info.has_gpu_reset_status_query)
+ return 0;
+
+ radeon_get_drm_value(ws->fd, RADEON_INFO_GPU_RESET_COUNTER,
+ "gpu-reset-counter", (uint32_t*)&retval);
+ return retval;
+}
+
static uint64_t radeon_query_value(struct radeon_winsys *rws,
enum radeon_value_id value)
{