Skip to contentSkip to conversation

nvc0: ARB_(multi_)draw_indirect support

PATCH New Ilia Mirkin 2 participants 4 messages Jul 10, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover nvc0: ARB_(multi_)draw_indirect support

The main patches are from Christoph. Unfortunately they're a little beyond my understanding of all the vertex-related details, but they generally seemed fine. I'm just going to push these unless someone steps up to review them.

Christoph Bumiller (2):
nvc0: add support for indirect drawing
nvc0: fix translate path for PRIM_RESTART_WITH_DRAW_ARRAYS

Ilia Mirkin (1):
nouveau: check if a fence has already been signalled

 docs/GL3.txt                                       |  5 +-
 docs/relnotes/10.3.html                            |  1 +
 src/gallium/drivers/nouveau/nouveau_fence.c        |  3 +
 src/gallium/drivers/nouveau/nouveau_screen.c       |  6 +-
 src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h     |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_screen.c     |  2 +
 src/gallium/drivers/nouveau/nvc0/mme/com9097.mme   | 75 ++++++++++++++++++
 src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h | 56 ++++++++++++++
 src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h     |  6 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c     | 13 +++-
 src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c        | 90 ++++++++++++++++------
 .../drivers/nouveau/nvc0/nvc0_vbo_translate.c      | 41 ++++++----
 12 files changed, 254 insertions(+), 46 deletions(-)
Signature · 1 line
1.8.5.5
#1 lore raw

PATCH 1/3 nouveau: check if a fence has already been signalled

nouveau_fence_update does real work unconditionally. Avoid doing that if the fence we're checking on has already been signalled.

---
 src/gallium/drivers/nouveau/nouveau_fence.c | 3 +++
 1 file changed, 3 insertions(+)
src/gallium/drivers/nouveau/nouveau_fence.c +3 -0
index c686710..a9448a4 100644
@@ -174,6 +174,9 @@ nouveau_fence_signalled(struct nouveau_fence *fence)
 {
    struct nouveau_screen *screen = fence->screen;
 
+   if (fence->state == NOUVEAU_FENCE_STATE_SIGNALLED)
+      return TRUE;
+
    if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED)
       nouveau_fence_update(screen, FALSE);
 
Signature · 1 line
1.8.5.5

A message that is not in the archive (sent off-list or not yet received): 1404964745-31949-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

#3 lore raw

PATCH 2/3 nvc0: add support for indirect drawing

From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>

---
 docs/GL3.txt                                       |  5 +-
 docs/relnotes/10.3.html                            |  1 +
 src/gallium/drivers/nouveau/nouveau_screen.c       |  6 +-
 src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h     |  2 +-
 src/gallium/drivers/nouveau/nv50/nv50_screen.c     |  2 +
 src/gallium/drivers/nouveau/nvc0/mme/com9097.mme   | 75 ++++++++++++++++++
 src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h | 56 ++++++++++++++
 src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h     |  6 ++
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c     | 13 +++-
 src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c        | 90 ++++++++++++++++------
 10 files changed, 223 insertions(+), 33 deletions(-)
docs/GL3.txt +2 -3
index 296e14c..8f41df0 100644
@@ -98,7 +98,7 @@ GL 4.0:
 
   GLSL 4.0                                             not started
   GL_ARB_draw_buffers_blend                            DONE (i965, nv50, nvc0, r600, radeonsi, softpipe)
-  GL_ARB_draw_indirect                                 DONE (i965)
+  GL_ARB_draw_indirect                                 DONE (i965, nvc0)
   GL_ARB_gpu_shader5                                   started
   - 'precise' qualifier                                DONE
   - Dynamically uniform sampler array indices          started (Chris)
@@ -123,7 +123,6 @@ GL 4.0:
   GL_ARB_transform_feedback2                           DONE (i965, nv50, nvc0, r600, radeonsi)
   GL_ARB_transform_feedback3                           DONE (i965, nv50, nvc0, r600, radeonsi)
 
-
 GL 4.1:
 
   GLSL 4.1                                             not started
@@ -165,7 +164,7 @@ GL 4.3:
   GL_ARB_framebuffer_no_attachments                    not started
   GL_ARB_internalformat_query2                         not started
   GL_ARB_invalidate_subdata                            DONE (all drivers)
-  GL_ARB_multi_draw_indirect                           DONE (i965)
+  GL_ARB_multi_draw_indirect                           DONE (i965, nvc0)
   GL_ARB_program_interface_query                       not started
   GL_ARB_robust_buffer_access_behavior                 not started
   GL_ARB_shader_image_size                             not started
docs/relnotes/10.3.html +1 -0
index 2e718fc..7d4f533 100644
@@ -56,6 +56,7 @@ Note: some of the new features are only available with certain drivers.
 <li>GL_ARB_seamless_cubemap_per_texture on i965, llvmpipe, nvc0, r600, radeonsi, softpipe</li>
 <li>GL_ARB_fragment_layer_viewport on nv50, nvc0, llvmpipe, r600</li>
 <li>GL_AMD_vertex_shader_viewport_index on i965/gen7+, r600</li>
+<li>GL_ARB_(multi_)draw_indirect on nvc0</li>
 </ul>
 
 
src/gallium/drivers/nouveau/nouveau_screen.c +4 -2
index 9d71bf7..517978d 100644
@@ -194,12 +194,14 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
 	screen->lowmem_bindings = PIPE_BIND_GLOBAL; /* gallium limit */
 	screen->vidmem_bindings =
 		PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL |
-		PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT | PIPE_BIND_CURSOR |
+		PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT |
+		PIPE_BIND_CURSOR |
 		PIPE_BIND_SAMPLER_VIEW |
 		PIPE_BIND_SHADER_RESOURCE | PIPE_BIND_COMPUTE_RESOURCE |
 		PIPE_BIND_GLOBAL;
 	screen->sysmem_bindings =
-		PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT;
+		PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT |
+		PIPE_BIND_COMMAND_ARGS_BUFFER;
 
 	memset(&mm_config, 0, sizeof(mm_config));
 
src/gallium/drivers/nouveau/nv50/nv50_3d.xml.h +1 -1
index cc3a382..7523fdc 100644
@@ -479,7 +479,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define NV50_3D_WATCHDOG_TIMER					0x00000de4
 
-#define NV50_3D_UNK0DE8						0x00000de8
+#define NV50_3D_PRIM_RESTART_WITH_DRAW_ARRAYS			0x00000de8
 
 #define NV50_3D_UNK0DEC						0x00000dec
 
src/gallium/drivers/nouveau/nv50/nv50_screen.c +2 -0
index 17d8fa3..fd63819 100644
@@ -437,6 +437,8 @@ nv50_screen_init_hwctx(struct nv50_screen *screen)
    PUSH_DATA (push, NV50_3D_MULTISAMPLE_MODE_MS1);
    BEGIN_NV04(push, NV50_3D(MULTISAMPLE_CTRL), 1);
    PUSH_DATA (push, 0);
+   BEGIN_NV04(push, NV50_3D(PRIM_RESTART_WITH_DRAW_ARRAYS), 1);
+   PUSH_DATA (push, 1);
    BEGIN_NV04(push, NV50_3D(LINE_LAST_PIXEL), 1);
    PUSH_DATA (push, 0);
    BEGIN_NV04(push, NV50_3D(BLEND_SEPARATE_ALPHA), 1);
src/gallium/drivers/nouveau/nvc0/mme/com9097.mme +75 -0

78 lines not on this page · raw message

src/gallium/drivers/nouveau/nvc0/mme/com9097.mme.h +56 -0

59 lines not on this page · raw message

src/gallium/drivers/nouveau/nvc0/nvc0_3d.xml.h +6 -0
index 9e3c56b..94b447b 100644
@@ -338,6 +338,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define NVC0_3D_WATCHDOG_TIMER					0x00000de4
 
+#define NVC0_3D_PRIM_RESTART_WITH_DRAW_ARRAYS			0x00000de8
+
 #define NVC0_3D_WINDOW_OFFSET_X					0x00000df8
 
 #define NVC0_3D_WINDOW_OFFSET_Y					0x00000dfc
@@ -1347,5 +1349,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define NVC0_3D_MACRO_TEP_SELECT				0x00003830
 
+#define NVC0_3D_MACRO_DRAW_ARRAYS_INDIRECT			0x00003838
+
+#define NVC0_3D_MACRO_DRAW_ELEMENTS_INDIRECT			0x00003840
+
 
 #endif /* NVC0_3D_XML */
src/gallium/drivers/nouveau/nvc0/nvc0_screen.c +9 -4
index dc9b143..3f444a4 100644
@@ -158,6 +158,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
+   case PIPE_CAP_DRAW_INDIRECT:
    case PIPE_CAP_USER_CONSTANT_BUFFERS:
    case PIPE_CAP_USER_INDEX_BUFFERS:
    case PIPE_CAP_USER_VERTEX_BUFFERS:
@@ -183,7 +184,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_TGSI_VS_LAYER_VIEWPORT:
    case PIPE_CAP_FAKE_SW_MSAA:
    case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
-   case PIPE_CAP_DRAW_INDIRECT:
       return 0;
    }
 
@@ -405,6 +405,8 @@ nvc0_graph_set_macro(struct nvc0_screen *screen, uint32_t m, unsigned pos,
 
    size /= 4;
 
+   assert((pos + size) <= 0x800);
+
    BEGIN_NVC0(push, SUBC_3D(NVC0_GRAPH_MACRO_ID), 2);
    PUSH_DATA (push, (m - 0x3800) / 8);
    PUSH_DATA (push, pos);
@@ -433,8 +435,6 @@ nvc0_magic_3d_init(struct nouveau_pushbuf *push, uint16_t obj_class)
    PUSH_DATA (push, (3 << 16) | 3);
    BEGIN_NVC0(push, SUBC_3D(0x1794), 1);
    PUSH_DATA (push, (2 << 16) | 2);
-   BEGIN_NVC0(push, SUBC_3D(0x0de8), 1);
-   PUSH_DATA (push, 1);
 
    if (obj_class < GM107_3D_CLASS) {
       BEGIN_NVC0(push, SUBC_3D(0x12ac), 1);
@@ -609,7 +609,8 @@ nvc0_screen_create(struct nouveau_device *dev)
    push->rsvd_kick = 5;
 
    screen->base.vidmem_bindings |= PIPE_BIND_CONSTANT_BUFFER |
-      PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
+      PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER |
+      PIPE_BIND_COMMAND_ARGS_BUFFER;
    screen->base.sysmem_bindings |=
       PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER;
 
@@ -768,6 +769,8 @@ nvc0_screen_create(struct nouveau_device *dev)
    PUSH_DATA (push, 1);
    BEGIN_NVC0(push, NVC0_3D(LINE_LAST_PIXEL), 1);
    PUSH_DATA (push, 0);
+   BEGIN_NVC0(push, NVC0_3D(PRIM_RESTART_WITH_DRAW_ARRAYS), 1);
+   PUSH_DATA (push, 1);
    BEGIN_NVC0(push, NVC0_3D(BLEND_SEPARATE_ALPHA), 1);
    PUSH_DATA (push, 1);
    BEGIN_NVC0(push, NVC0_3D(BLEND_ENABLE_COMMON), 1);
@@ -954,6 +957,8 @@ nvc0_screen_create(struct nouveau_device *dev)
    MK_MACRO(NVC0_3D_MACRO_GP_SELECT, mme9097_gp_select);
    MK_MACRO(NVC0_3D_MACRO_POLYGON_MODE_FRONT, mme9097_poly_mode_front);
    MK_MACRO(NVC0_3D_MACRO_POLYGON_MODE_BACK, mme9097_poly_mode_back);
+   MK_MACRO(NVC0_3D_MACRO_DRAW_ARRAYS_INDIRECT, mme9097_draw_arrays_indirect);
+   MK_MACRO(NVC0_3D_MACRO_DRAW_ELEMENTS_INDIRECT, mme9097_draw_elts_indirect);
 
    BEGIN_NVC0(push, NVC0_3D(RASTERIZE_ENABLE), 1);
    PUSH_DATA (push, 1);
src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c +67 -23

121 lines not on this page · raw message

Signature · 1 line
1.8.5.5
#4 lore raw

PATCH 3/3 nvc0: fix translate path for PRIM_RESTART_WITH_DRAW_ARRAYS

In reply to a message not in the archive

From: Christoph Bumiller <e0425955-oe7qfRrRQffzPE21tAIdciO7C/[email protected]>

---
 .../drivers/nouveau/nvc0/nvc0_vbo_translate.c      | 41 +++++++++++++++-------
 1 file changed, 28 insertions(+), 13 deletions(-)
src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c +28 -13
index fc578f2..f180087 100644
@@ -253,7 +253,7 @@ disp_vertices_i08(struct push_context *ctx, unsigned start, unsigned count)
       }
       if (count) {
          BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1);
-         PUSH_DATA (push, ctx->restart_index);
+         PUSH_DATA (push, 0xffffffff);
          ++elts;
          ctx->dest += ctx->vertex_size;
          ++pos;
@@ -309,7 +309,7 @@ disp_vertices_i16(struct push_context *ctx, unsigned start, unsigned count)
       }
       if (count) {
          BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1);
-         PUSH_DATA (push, ctx->restart_index);
+         PUSH_DATA (push, 0xffffffff);
          ++elts;
          ctx->dest += ctx->vertex_size;
          ++pos;
@@ -365,7 +365,7 @@ disp_vertices_i32(struct push_context *ctx, unsigned start, unsigned count)
       }
       if (count) {
          BEGIN_NVC0(push, NVC0_3D(VB_ELEMENT_U32), 1);
-         PUSH_DATA (push, ctx->restart_index);
+         PUSH_DATA (push, 0xffffffff);
          ++elts;
          ctx->dest += ctx->vertex_size;
          ++pos;
@@ -381,6 +381,9 @@ disp_vertices_seq(struct push_context *ctx, unsigned start, unsigned count)
    struct translate *translate = ctx->translate;
    unsigned pos = 0;
 
+   /* XXX: This will read the data corresponding to the primitive restart index,
+    *  maybe we should avoid that ?
+    */
    translate->run(translate, start, count, 0, ctx->instance_id, ctx->dest);
    do {
       unsigned nr = count;
@@ -444,25 +447,37 @@ nvc0_push_vbo(struct nvc0_context *nvc0, const struct pipe_draw_info *info)
 
    nvc0_vertex_configure_translate(nvc0, info->index_bias);
 
+   if (nvc0->state.index_bias) {
+      /* this is already taken care of by translate */
+      IMMED_NVC0(ctx.push, NVC0_3D(VB_ELEMENT_BASE), 0);
+      nvc0->state.index_bias = 0;
+   }
+
    if (unlikely(ctx.edgeflag.enabled))
       nvc0_push_map_edgeflag(&ctx, nvc0, info->index_bias);
 
    ctx.prim_restart = info->primitive_restart;
    ctx.restart_index = info->restart_index;
 
+   if (info->primitive_restart) {
+      /* NOTE: I hope we won't ever need that last index (~0).
+       * If we do, we have to disable primitive restart here always and
+       * use END,BEGIN to restart. (XXX: would that affect PrimitiveID ?)
+       * We could also deactive PRIM_RESTART_WITH_DRAW_ARRAYS temporarily,
+       * and add manual restart to disp_vertices_seq.
+       */
+      BEGIN_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 2);
+      PUSH_DATA (ctx.push, 1);
+      PUSH_DATA (ctx.push, info->indexed ? 0xffffffff : info->restart_index);
+   } else
+   if (nvc0->state.prim_restart) {
+      IMMED_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 0);
+   }
+   nvc0->state.prim_restart = info->primitive_restart;
+
    if (info->indexed) {
       nvc0_push_map_idxbuf(&ctx, nvc0);
       index_size = nvc0->idxbuf.index_size;
-
-      if (info->primitive_restart) {
-         BEGIN_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 2);
-         PUSH_DATA (ctx.push, 1);
-         PUSH_DATA (ctx.push, info->restart_index);
-      } else
-      if (nvc0->state.prim_restart) {
-         IMMED_NVC0(ctx.push, NVC0_3D(PRIM_RESTART_ENABLE), 0);
-      }
-      nvc0->state.prim_restart = info->primitive_restart;
    } else {
       if (unlikely(info->count_from_stream_output)) {
          struct pipe_context *pipe = &nvc0->base.pipe;
Signature · 1 line
1.8.5.5