iris: Build for gen12
[mesa.git] / src / gallium / drivers / softpipe / sp_prim_vbuf.c
index bb5ebcc7aee570e07e40569c31b2605e72e39779..12734314bf0158a4fee7b0c102322125319e8a9f 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2007 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -60,7 +60,7 @@ struct softpipe_vbuf_render
    struct softpipe_context *softpipe;
    struct setup_context *setup;
 
-   uint prim;
+   enum pipe_prim_type prim;
    uint vertex_size;
    uint nr_vertices;
    uint vertex_buffer_size;
@@ -133,7 +133,7 @@ sp_vbuf_unmap_vertices(struct vbuf_render *vbr,
 
 
 static void
-sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
+sp_vbuf_set_primitive(struct vbuf_render *vbr, enum pipe_prim_type prim)
 {
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
    struct setup_context *setup_ctx = cvbr->setup;
@@ -145,7 +145,7 @@ sp_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
 }
 
 
-static INLINE cptrf4 get_vert( const void *vertex_buffer,
+static inline cptrf4 get_vert( const void *vertex_buffer,
                                int index,
                                int stride )
 {
@@ -161,7 +161,7 @@ sp_vbuf_draw_elements(struct vbuf_render *vbr, const ushort *indices, uint nr)
 {
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
    struct softpipe_context *softpipe = cvbr->softpipe;
-   const unsigned stride = softpipe->vertex_info_vbuf.size * sizeof(float);
+   const unsigned stride = softpipe->vertex_info.size * sizeof(float);
    const void *vertex_buffer = cvbr->vertex_buffer;
    struct setup_context *setup = cvbr->setup;
    const boolean flatshade_first = softpipe->rasterizer->flatshade_first;
@@ -358,7 +358,7 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
    struct softpipe_context *softpipe = cvbr->softpipe;
    struct setup_context *setup = cvbr->setup;
-   const unsigned stride = softpipe->vertex_info_vbuf.size * sizeof(float);
+   const unsigned stride = softpipe->vertex_info.size * sizeof(float);
    const void *vertex_buffer =
       (void *) get_vert(cvbr->vertex_buffer, start, stride);
    const boolean flatshade_first = softpipe->rasterizer->flatshade_first;
@@ -587,17 +587,45 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
    }
 }
 
+/*
+ * FIXME: it is unclear if primitives_storage_needed (which is generally
+ * the same as pipe query num_primitives_generated) should increase
+ * if SO is disabled for d3d10, but for GL we definitely need to
+ * increase num_primitives_generated and this is only called for active
+ * SO. If it must not increase for d3d10 need to disambiguate the counters
+ * in the driver and do some work for getting correct values, if it should
+ * increase too should call this from outside streamout code.
+ */
+static void
+sp_vbuf_so_info(struct vbuf_render *vbr, uint stream, uint primitives, uint prim_generated)
+{
+   struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
+   struct softpipe_context *softpipe = cvbr->softpipe;
+
+   softpipe->so_stats[stream].num_primitives_written += primitives;
+   softpipe->so_stats[stream].primitives_storage_needed += prim_generated;
+}
+
 static void
-sp_vbuf_so_info(struct vbuf_render *vbr, uint primitives, uint vertices,
-                uint prim_generated)
+sp_vbuf_pipeline_statistics(
+   struct vbuf_render *vbr, 
+   const struct pipe_query_data_pipeline_statistics *stats)
 {
    struct softpipe_vbuf_render *cvbr = softpipe_vbuf_render(vbr);
    struct softpipe_context *softpipe = cvbr->softpipe;
 
-   softpipe->so_stats.num_primitives_written += primitives;
-   softpipe->so_stats.primitives_storage_needed =
-      vertices * 4 /*sizeof(float|int32)*/ * 4 /*x,y,z,w*/;
-   softpipe->num_primitives_generated += prim_generated;
+   softpipe->pipeline_statistics.ia_vertices +=
+      stats->ia_vertices;
+   softpipe->pipeline_statistics.ia_primitives +=
+      stats->ia_primitives;
+   softpipe->pipeline_statistics.vs_invocations +=
+      stats->vs_invocations;
+   softpipe->pipeline_statistics.gs_invocations +=
+      stats->gs_invocations;
+   softpipe->pipeline_statistics.gs_primitives +=
+      stats->gs_primitives;
+   softpipe->pipeline_statistics.c_invocations +=
+      stats->c_invocations;
 }
 
 
@@ -634,6 +662,7 @@ sp_create_vbuf_backend(struct softpipe_context *sp)
    cvbr->base.draw_arrays = sp_vbuf_draw_arrays;
    cvbr->base.release_vertices = sp_vbuf_release_vertices;
    cvbr->base.set_stream_output_info = sp_vbuf_so_info;
+   cvbr->base.pipeline_statistics = sp_vbuf_pipeline_statistics;
    cvbr->base.destroy = sp_vbuf_destroy;
 
    cvbr->softpipe = sp;