radeon/winsys: add cs_check_space
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Fri, 6 May 2016 17:34:25 +0000 (12:34 -0500)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 1 Jun 2016 20:52:18 +0000 (22:52 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c
src/gallium/winsys/radeon/drm/radeon_drm_cs.c

index 792bacb549995d17af149f31131db8ebfa63531a..e8e429abc11bcbcf090d18f3cbc467aec6c46eeb 100644 (file)
@@ -673,6 +673,15 @@ struct radeon_winsys {
      */
     boolean (*cs_validate)(struct radeon_winsys_cs *cs);
 
+    /**
+     * Check whether the given number of dwords is available in the IB.
+     * Optionally chain a new chunk of the IB if necessary and supported.
+     *
+     * \param cs        A command stream.
+     * \param dw        Number of CS dwords requested by the caller.
+     */
+    bool (*cs_check_space)(struct radeon_winsys_cs *cs, unsigned dw);
+
     /**
      * Return TRUE if there is enough memory in VRAM and GTT for the buffers
      * added so far.
index c8ce34de34d8e379e9db5b7d6ae1ca107f928b09..639ffb5ce7cab1a5f5fc696f434679a6d578b3c9 100644 (file)
@@ -603,6 +603,12 @@ static boolean amdgpu_cs_validate(struct radeon_winsys_cs *rcs)
    return TRUE;
 }
 
+static bool amdgpu_cs_check_space(struct radeon_winsys_cs *rcs, unsigned dw)
+{
+   assert(rcs->cdw <= rcs->max_dw);
+   return rcs->max_dw - rcs->cdw >= dw;
+}
+
 static boolean amdgpu_cs_memory_below_limit(struct radeon_winsys_cs *rcs, uint64_t vram, uint64_t gtt)
 {
    struct amdgpu_cs *cs = amdgpu_cs(rcs);
@@ -941,6 +947,7 @@ void amdgpu_cs_init_functions(struct amdgpu_winsys *ws)
    ws->base.cs_add_buffer = amdgpu_cs_add_buffer;
    ws->base.cs_lookup_buffer = amdgpu_cs_lookup_buffer;
    ws->base.cs_validate = amdgpu_cs_validate;
+   ws->base.cs_check_space = amdgpu_cs_check_space;
    ws->base.cs_memory_below_limit = amdgpu_cs_memory_below_limit;
    ws->base.cs_query_memory_usage = amdgpu_cs_query_memory_usage;
    ws->base.cs_get_buffer_list = amdgpu_cs_get_buffer_list;
index acf16f2bfbb15df1f938a3b49c7eddd47ce46ff2..a6ca37744dc4b927f6be9ec7eaf18fdddd985968 100644 (file)
@@ -383,6 +383,12 @@ static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs)
     return status;
 }
 
+static bool radeon_drm_cs_check_space(struct radeon_winsys_cs *rcs, unsigned dw)
+{
+   assert(rcs->cdw <= rcs->max_dw);
+   return rcs->max_dw - rcs->cdw >= dw;
+}
+
 static boolean radeon_drm_cs_memory_below_limit(struct radeon_winsys_cs *rcs, uint64_t vram, uint64_t gtt)
 {
     struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
@@ -677,6 +683,7 @@ void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
     ws->base.cs_add_buffer = radeon_drm_cs_add_buffer;
     ws->base.cs_lookup_buffer = radeon_drm_cs_lookup_buffer;
     ws->base.cs_validate = radeon_drm_cs_validate;
+    ws->base.cs_check_space = radeon_drm_cs_check_space;
     ws->base.cs_memory_below_limit = radeon_drm_cs_memory_below_limit;
     ws->base.cs_query_memory_usage = radeon_drm_cs_query_memory_usage;
     ws->base.cs_get_buffer_list = radeon_drm_cs_get_buffer_list;