draw: allow pt paths to run without a vbuf render stage
authorKeith Whitwell <keith@tungstengraphics.com>
Wed, 16 Apr 2008 11:55:47 +0000 (12:55 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Wed, 16 Apr 2008 11:55:47 +0000 (12:55 +0100)
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c

index 895224c9527184d073ff17c8d13b21d1906bd015..c0125c906fe1ded78b6104cdd8cead7443a77732 100644 (file)
@@ -54,10 +54,9 @@ draw_pt_arrays(struct draw_context *draw,
    struct draw_pt_middle_end *middle = NULL;
    unsigned opt = 0;
 
-   if (!draw->render)
-      return FALSE;
-   /*debug_printf("XXXXXXXXXX needs_pipeline = %d\n", pipeline);*/
-
+   if (!draw->render) {
+      opt |= PT_PIPELINE;
+   }
 
    if (draw_need_pipeline(draw, prim)) {
       opt |= PT_PIPELINE;
index 52be4a64aa63eb61ac6c74abb1f111f0769b3c6f..a66e8b0ba22ca10794fa9c5ea7b2a16ab0e9204a 100644 (file)
@@ -61,88 +61,89 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
    fpme->prim = prim;
    fpme->opt = opt;
 
-   ok = draw->render->set_primitive(draw->render, prim);
-   if (!ok) {
-      assert(0);
-      return;
-   }
+   if (!(opt & PT_PIPELINE)) {
+      ok = draw->render->set_primitive(draw->render, prim);
+      if (!ok) {
+        assert(0);
+        return;
+      }
 
-   /* Must do this after set_primitive() above:
-    */
-   vinfo = draw->render->get_vertex_info(draw->render);
+      /* Must do this after set_primitive() above:
+       */
+      vinfo = draw->render->get_vertex_info(draw->render);
 
 
-   /* In passthrough mode, need to translate from vertex shader
-    * outputs to hw vertices.
-    */
-   dst_offset = 0;
-   for (i = 0; i < vinfo->num_attribs; i++) {
-      unsigned emit_sz = 0;
-      unsigned src_buffer = 0;
-      unsigned output_format;
-      unsigned src_offset = (sizeof(struct vertex_header) + 
-                            vinfo->src_index[i] * 4 * sizeof(float) );
+      /* In passthrough mode, need to translate from vertex shader
+       * outputs to hw vertices.
+       */
+      dst_offset = 0;
+      for (i = 0; i < vinfo->num_attribs; i++) {
+        unsigned emit_sz = 0;
+        unsigned src_buffer = 0;
+        unsigned output_format;
+        unsigned src_offset = (sizeof(struct vertex_header) + 
+                               vinfo->src_index[i] * 4 * sizeof(float) );
 
 
          
-      switch (vinfo->emit[i]) {
-      case EMIT_4F:
-         output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-        emit_sz = 4 * sizeof(float);
-         break;
-      case EMIT_3F:
-         output_format = PIPE_FORMAT_R32G32B32_FLOAT;
-        emit_sz = 3 * sizeof(float);
-         break;
-      case EMIT_2F:
-         output_format = PIPE_FORMAT_R32G32_FLOAT;
-        emit_sz = 2 * sizeof(float);
-         break;
-      case EMIT_1F:
-         output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-         break;
-      case EMIT_1F_PSIZE:
-         output_format = PIPE_FORMAT_R32_FLOAT;
-        emit_sz = 1 * sizeof(float);
-         src_buffer = 1;
-        src_offset = 0;
-         break;
-      case EMIT_4UB:
-         output_format = PIPE_FORMAT_B8G8R8A8_UNORM;
-        emit_sz = 4 * sizeof(ubyte);
-      default:
-         assert(0);
-         output_format = PIPE_FORMAT_NONE;
-        emit_sz = 0;
-         break;
-      }
+        switch (vinfo->emit[i]) {
+        case EMIT_4F:
+           output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+           emit_sz = 4 * sizeof(float);
+           break;
+        case EMIT_3F:
+           output_format = PIPE_FORMAT_R32G32B32_FLOAT;
+           emit_sz = 3 * sizeof(float);
+           break;
+        case EMIT_2F:
+           output_format = PIPE_FORMAT_R32G32_FLOAT;
+           emit_sz = 2 * sizeof(float);
+           break;
+        case EMIT_1F:
+           output_format = PIPE_FORMAT_R32_FLOAT;
+           emit_sz = 1 * sizeof(float);
+           break;
+        case EMIT_1F_PSIZE:
+           output_format = PIPE_FORMAT_R32_FLOAT;
+           emit_sz = 1 * sizeof(float);
+           src_buffer = 1;
+           src_offset = 0;
+           break;
+        case EMIT_4UB:
+           output_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+           emit_sz = 4 * sizeof(ubyte);
+        default:
+           assert(0);
+           output_format = PIPE_FORMAT_NONE;
+           emit_sz = 0;
+           break;
+        }
       
-      hw_key.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
-      hw_key.element[i].input_buffer = src_buffer;
-      hw_key.element[i].input_offset = src_offset;
-      hw_key.element[i].output_format = output_format;
-      hw_key.element[i].output_offset = dst_offset;
+        hw_key.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+        hw_key.element[i].input_buffer = src_buffer;
+        hw_key.element[i].input_offset = src_offset;
+        hw_key.element[i].output_format = output_format;
+        hw_key.element[i].output_offset = dst_offset;
 
-      dst_offset += emit_sz;
-   }
+        dst_offset += emit_sz;
+      }
 
-   hw_key.nr_elements = vinfo->num_attribs;
-   hw_key.output_stride = vinfo->size * 4;
+      hw_key.nr_elements = vinfo->num_attribs;
+      hw_key.output_stride = vinfo->size * 4;
 
-   /* Don't bother with caching at this stage:
-    */
-   if (!fpme->translate ||
-       memcmp(&fpme->translate->key, &hw_key, sizeof(hw_key)) != 0) 
-   {
-      if (fpme->translate)
-        fpme->translate->release(fpme->translate);
+      /* Don't bother with caching at this stage:
+       */
+      if (!fpme->translate ||
+         memcmp(&fpme->translate->key, &hw_key, sizeof(hw_key)) != 0) 
+      {
+        if (fpme->translate)
+           fpme->translate->release(fpme->translate);
 
-      fpme->translate = translate_generic_create( &hw_key );
+        fpme->translate = translate_generic_create( &hw_key );
+      }
    }
 
 
-
    //fpme->pipeline_vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float);
    fpme->pipeline_vertex_size = MAX_VERTEX_ALLOCATION;
 }