radeonsi: Use dummy pixel shader if compilation of the real shader failed
[mesa.git] / src / gallium / drivers / svga / svga_state_vdecl.c
index 47eab1a9739eadcbf171c7bc71978c1ba57cee8b..a33eda3836605ed6b99b911d31d176df6b3edad2 100644 (file)
 #include "svga_tgsi.h"
 #include "svga_screen.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, unsigned dirty)
 {
    const struct pipe_vertex_element *ve = svga->curr.velems->velem;
-   SVGA3dVertexDecl decl;
    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, 
+   /* specify number of vertex element declarations to come */
+   svga_hwtnl_reset_vdecl( svga->hwtnl,
                            svga->curr.velems->count );
 
    /**
@@ -74,16 +70,15 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
    for (i = 0; i < svga->curr.velems->count; i++) {
       const struct pipe_vertex_buffer *vb =
          &svga->curr.vb[ve[i].vertex_buffer_index];
-      struct svga_buffer *buffer;
+      const struct svga_buffer *buffer;
       unsigned int offset = vb->buffer_offset + ve[i].src_offset;
-      unsigned tmp_neg_bias = 0;
 
       if (!vb->buffer)
          continue;
 
       buffer = svga_buffer(vb->buffer);
       if (buffer->uploaded.start > offset) {
-         tmp_neg_bias = buffer->uploaded.start - offset;
+         unsigned tmp_neg_bias = buffer->uploaded.start - offset;
          if (vb->stride)
             tmp_neg_bias = (tmp_neg_bias + vb->stride - 1) / vb->stride;
          neg_bias = MAX2(neg_bias, tmp_neg_bias);
@@ -94,17 +89,18 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
       const struct pipe_vertex_buffer *vb =
          &svga->curr.vb[ve[i].vertex_buffer_index];
       unsigned usage, index;
-      struct svga_buffer *buffer;
+      const struct svga_buffer *buffer;
+      SVGA3dVertexDecl decl;
 
       if (!vb->buffer)
          continue;
 
-      buffer= svga_buffer(vb->buffer);
+      buffer = svga_buffer(vb->buffer);
       svga_generate_vdecl_semantics( i, &usage, &index );
 
       /* SVGA_NEW_VELEMENT
        */
-      decl.identity.type = svga->state.sw.ve_format[i];
+      decl.identity.type = svga->curr.velems->decl_type[i];
       decl.identity.method = SVGA3D_DECLMETHOD_DEFAULT;
       decl.identity.usage = usage;
       decl.identity.usageIndex = index;
@@ -127,24 +123,24 @@ static int emit_hw_vs_vdecl( struct svga_context *svga,
                         vb->buffer );
    }
 
-   svga_hwtnl_set_index_bias( svga->hwtnl, -neg_bias );
-   return 0;
+   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, unsigned 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 +151,3 @@ struct svga_tracked_state svga_hw_vdecl =
      SVGA_NEW_VS ),
    emit_hw_vdecl
 };
-
-
-
-
-
-