gallium: add PIPE_SHADER_CAP_GLSL_16BIT_TEMPS for LowerPrecisionTemporaries
[mesa.git] / src / gallium / drivers / svga / svga_state_vdecl.c
index 47eab1a9739eadcbf171c7bc71978c1ba57cee8b..a49bcd0a2630ff631969cc53cf8b4953f7241d07 100644 (file)
 #include "svga_draw.h"
 #include "svga_tgsi.h"
 #include "svga_screen.h"
+#include "svga_shader.h"
 #include "svga_resource_buffer.h"
-
 #include "svga_hw_reg.h"
 
 
-/***********************************************************************
- */
-
 
-static int emit_hw_vs_vdecl( struct svga_context *svga,
-                             unsigned dirty )
+static enum pipe_error
+emit_hw_vs_vdecl(struct svga_context *svga, uint64_t dirty)
 {
    const struct pipe_vertex_element *ve = svga->curr.velems->velem;
-   SVGA3dVertexDecl decl;
+   SVGA3dVertexDecl decls[SVGA3D_INPUTREG_MAX];
+   unsigned buffer_indexes[SVGA3D_INPUTREG_MAX];
    unsigned i;
    unsigned neg_bias = 0;
 
    assert(svga->curr.velems->count >=
           svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]);
 
-   svga_hwtnl_reset_vdecl( svga->hwtnl, 
-                           svga->curr.velems->count );
-
    /**
     * We can't set the VDECL offset to something negative, so we
     * must calculate a common negative additional index bias, and modify
@@ -78,10 +73,10 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
       unsigned int offset = vb->buffer_offset + ve[i].src_offset;
       unsigned tmp_neg_bias = 0;
 
-      if (!vb->buffer)
+      if (!vb->buffer.resource)
          continue;
 
-      buffer = svga_buffer(vb->buffer);
+      buffer = svga_buffer(vb->buffer.resource);
       if (buffer->uploaded.start > offset) {
          tmp_neg_bias = buffer->uploaded.start - offset;
          if (vb->stride)
@@ -96,55 +91,63 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
       unsigned usage, index;
       struct svga_buffer *buffer;
 
-      if (!vb->buffer)
+      if (!vb->buffer.resource)
          continue;
 
-      buffer= svga_buffer(vb->buffer);
+      buffer = svga_buffer(vb->buffer.resource);
       svga_generate_vdecl_semantics( i, &usage, &index );
 
       /* SVGA_NEW_VELEMENT
        */
-      decl.identity.type = svga->state.sw.ve_format[i];
-      decl.identity.method = SVGA3D_DECLMETHOD_DEFAULT;
-      decl.identity.usage = usage;
-      decl.identity.usageIndex = index;
-      decl.array.stride = vb->stride;
+      decls[i].identity.type = svga->curr.velems->decl_type[i];
+      decls[i].identity.method = SVGA3D_DECLMETHOD_DEFAULT;
+      decls[i].identity.usage = usage;
+      decls[i].identity.usageIndex = index;
+      decls[i].array.stride = vb->stride;
 
       /* Compensate for partially uploaded vbo, and
        * for the negative index bias.
        */
-      decl.array.offset = (vb->buffer_offset
+      decls[i].array.offset = (vb->buffer_offset
                            + ve[i].src_offset
                           + neg_bias * vb->stride
                           - buffer->uploaded.start);
 
-      assert(decl.array.offset >= 0);
+      assert(decls[i].array.offset >= 0);
 
-      svga_hwtnl_vdecl( svga->hwtnl,
-                        i,
-                        &decl,
-                        buffer->uploaded.buffer ? buffer->uploaded.buffer :
-                        vb->buffer );
+      buffer_indexes[i] = ve[i].vertex_buffer_index;
+
+      assert(!buffer->uploaded.buffer);
    }
 
-   svga_hwtnl_set_index_bias( svga->hwtnl, -neg_bias );
-   return 0;
+   svga_hwtnl_vertex_decls(svga->hwtnl,
+                           svga->curr.velems->count,
+                           decls,
+                           buffer_indexes,
+                           svga->curr.velems->id);
+
+   svga_hwtnl_vertex_buffers(svga->hwtnl,
+                             svga->curr.num_vertex_buffers,
+                             svga->curr.vb);
+
+   svga_hwtnl_set_index_bias( svga->hwtnl, -(int) neg_bias );
+   return PIPE_OK;
 }
 
 
-static int emit_hw_vdecl( struct svga_context *svga,
-                          unsigned dirty )
+static enum pipe_error
+emit_hw_vdecl(struct svga_context *svga, uint64_t dirty)
 {
    /* SVGA_NEW_NEED_SWTNL
     */
    if (svga->state.sw.need_swtnl)
-      return 0; /* Do not emit during swtnl */
+      return PIPE_OK; /* Do not emit during swtnl */
 
    return emit_hw_vs_vdecl( svga, dirty );
 }
 
 
-struct svga_tracked_state svga_hw_vdecl = 
+struct svga_tracked_state svga_hw_vdecl =
 {
    "hw vertex decl state (hwtnl version)",
    ( SVGA_NEW_NEED_SWTNL |
@@ -155,9 +158,3 @@ struct svga_tracked_state svga_hw_vdecl =
      SVGA_NEW_VS ),
    emit_hw_vdecl
 };
-
-
-
-
-
-