draw: add shader buffer interfaces.
authorDave Airlie <airlied@redhat.com>
Wed, 26 Jun 2019 05:56:32 +0000 (15:56 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 7 Jul 2019 06:24:09 +0000 (16:24 +1000)
This adds the interface to add mapped shader buffers,
and sets up the jit linkage for them.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/draw/draw_context.c
src/gallium/auxiliary/draw/draw_context.h
src/gallium/auxiliary/draw/draw_private.h
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c

index f8c69585e6aabe8ff7b3c5dc9f0caf7d38175e4f..74436f98016e689212050135e44aee92fa49cac5 100644 (file)
@@ -464,6 +464,32 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
    }
 }
 
+void
+draw_set_mapped_shader_buffer(struct draw_context *draw,
+                              enum pipe_shader_type shader_type,
+                              unsigned slot,
+                              const void *buffer,
+                              unsigned size )
+{
+   debug_assert(shader_type == PIPE_SHADER_VERTEX ||
+                shader_type == PIPE_SHADER_GEOMETRY);
+   debug_assert(slot < PIPE_MAX_SHADER_BUFFERS);
+
+   draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
+
+   switch (shader_type) {
+   case PIPE_SHADER_VERTEX:
+      draw->pt.user.vs_ssbos[slot] = buffer;
+      draw->pt.user.vs_ssbos_size[slot] = size;
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      draw->pt.user.gs_ssbos[slot] = buffer;
+      draw->pt.user.gs_ssbos_size[slot] = size;
+      break;
+   default:
+      assert(0 && "invalid shader type in draw_set_mapped_shader_buffer");
+   }
+}
 
 /**
  * Tells the draw module to draw points with triangles if their size
index d8a1470e901cf93d490139921d9adbbacebdd661..868d0195a02b0d4d4afc6859da838f2469858d80 100644 (file)
@@ -254,6 +254,13 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
                                 const void *buffer,
                                 unsigned size);
 
+void
+draw_set_mapped_shader_buffer(struct draw_context *draw,
+                              enum pipe_shader_type shader_type,
+                              unsigned slot,
+                              const void *buffer,
+                              unsigned size);
+
 void
 draw_set_mapped_so_targets(struct draw_context *draw,
                            int num_targets,
index 06ad7372a745c457950c673c848cd697c079eff6..0b236912bef2594c5eea7d6581bf6366c61c18c9 100644 (file)
@@ -205,7 +205,13 @@ struct draw_context
          unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
          const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS];
          unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
-         
+
+         /** shader buffers (for vertex/geometry shader) */
+         const void *vs_ssbos[PIPE_MAX_SHADER_BUFFERS];
+         unsigned vs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
+         const void *gs_ssbos[PIPE_MAX_SHADER_BUFFERS];
+         unsigned gs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
+
          /* pointer to planes */
          float (*planes)[DRAW_TOTAL_CLIP_PLANES][4]; 
       } user;
index 9f4f887dff064dd3911dacda1cfa7e676ea24912..b96a5c9931594c0d5bd1343169e0d99c854c9a04 100644 (file)
@@ -297,6 +297,15 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
          llvm->jit_context.vs_constants[i] = fake_const_buf;
       }
    }
+   for (i = 0; i < ARRAY_SIZE(llvm->jit_context.vs_ssbos); ++i) {
+      int num_ssbos = draw->pt.user.vs_ssbos_size[i];
+      llvm->jit_context.vs_ssbos[i] = draw->pt.user.vs_ssbos[i];
+      llvm->jit_context.num_vs_ssbos[i] = num_ssbos;
+      if (num_ssbos == 0) {
+         llvm->jit_context.vs_ssbos[i] = (const uint32_t *)fake_const_buf;
+      }
+   }
+
    for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) {
       int num_consts =
          draw->pt.user.gs_constants_size[i] / (sizeof(float) * 4);
@@ -306,6 +315,14 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
          llvm->gs_jit_context.constants[i] = fake_const_buf;
       }
    }
+   for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.ssbos); ++i) {
+      int num_ssbos = draw->pt.user.gs_ssbos_size[i];
+      llvm->gs_jit_context.ssbos[i] = draw->pt.user.gs_ssbos[i];
+      llvm->gs_jit_context.num_ssbos[i] = num_ssbos;
+      if (num_ssbos == 0) {
+         llvm->gs_jit_context.ssbos[i] = (const uint32_t *)fake_const_buf;
+      }
+   }
 
    llvm->jit_context.planes =
       (float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0];