lima/streamparser: Add findings introduced with gl_PointSize
[mesa.git] / src / gallium / drivers / llvmpipe / lp_rast.c
index 678ef0bd0bf5532efaa5c0288eae00b1fd4ead33..ef783ea6fb1b6782590c33d7159784d954444c4a 100644 (file)
@@ -32,8 +32,9 @@
 #include "util/u_surface.h"
 #include "util/u_pack_color.h"
 #include "util/u_string.h"
+#include "util/u_thread.h"
 
-#include "os/os_time.h"
+#include "util/os_time.h"
 
 #include "lp_scene_queue.h"
 #include "lp_context.h"
@@ -106,7 +107,7 @@ lp_rast_tile_begin(struct lp_rasterizer_task *task,
                     task->scene->fb.height - y * TILE_SIZE : TILE_SIZE;
 
    task->thread_data.vis_counter = 0;
-   task->ps_invocations = 0;
+   task->thread_data.ps_invocations = 0;
 
    for (i = 0; i < task->scene->fb.nr_cbufs; i++) {
       if (task->scene->fb.cbufs[i]) {
@@ -445,10 +446,6 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
     * allocated 4x4 blocks hence need to filter them out here.
     */
    if ((x % TILE_SIZE) < task->width && (y % TILE_SIZE) < task->height) {
-      /* not very accurate would need a popcount on the mask */
-      /* always count this not worth bothering? */
-      task->ps_invocations += 1 * variant->ps_inv_multiplier;
-
       /* Propagate non-interpolated raster state. */
       task->thread_data.raster_state.viewport_index = inputs->viewport_index;
 
@@ -486,10 +483,11 @@ lp_rast_begin_query(struct lp_rasterizer_task *task,
    switch (pq->type) {
    case PIPE_QUERY_OCCLUSION_COUNTER:
    case PIPE_QUERY_OCCLUSION_PREDICATE:
+   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
       pq->start[task->thread_index] = task->thread_data.vis_counter;
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
-      pq->start[task->thread_index] = task->ps_invocations;
+      pq->start[task->thread_index] = task->thread_data.ps_invocations;
       break;
    default:
       assert(0);
@@ -512,6 +510,7 @@ lp_rast_end_query(struct lp_rasterizer_task *task,
    switch (pq->type) {
    case PIPE_QUERY_OCCLUSION_COUNTER:
    case PIPE_QUERY_OCCLUSION_PREDICATE:
+   case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
       pq->end[task->thread_index] +=
          task->thread_data.vis_counter - pq->start[task->thread_index];
       pq->start[task->thread_index] = 0;
@@ -521,7 +520,7 @@ lp_rast_end_query(struct lp_rasterizer_task *task,
       break;
    case PIPE_QUERY_PIPELINE_STATISTICS:
       pq->end[task->thread_index] +=
-         task->ps_invocations - pq->start[task->thread_index];
+         task->thread_data.ps_invocations - pq->start[task->thread_index];
       pq->start[task->thread_index] = 0;
       break;
    default:
@@ -629,7 +628,7 @@ rasterize_bin(struct lp_rasterizer_task *task,
 
    lp_rast_tile_end(task);
 
-
+#ifdef DEBUG
    /* Debug/Perf flags:
     */
    if (bin->head->count == 1) {
@@ -638,6 +637,7 @@ rasterize_bin(struct lp_rasterizer_task *task,
       else if (bin->head->cmd[0] == LP_RAST_OP_SHADE_TILE)
          LP_COUNT(nr_pure_shade_64);
    }
+#endif
 }
 
 
@@ -676,7 +676,7 @@ rasterize_scene(struct lp_rasterizer_task *task,
 #endif
 #endif
 
-   if (!task->rast->no_rast && !scene->discard) {
+   if (!task->rast->no_rast) {
       /* loop over scene bins, rasterize each */
       {
          struct cmd_bin *bin;
@@ -790,8 +790,8 @@ thread_function(void *init_data)
    char thread_name[16];
    unsigned fpstate;
 
-   util_snprintf(thread_name, sizeof thread_name, "llvmpipe-%u", task->thread_index);
-   pipe_thread_setname(thread_name);
+   snprintf(thread_name, sizeof thread_name, "llvmpipe-%u", task->thread_index);
+   u_thread_setname(thread_name);
 
    /* Make sure that denorms are treated like zeros. This is 
     * the behavior required by D3D10. OpenGL doesn't care.
@@ -820,7 +820,7 @@ thread_function(void *init_data)
       /* Wait for all threads to get here so that threads[1+] don't
        * get a null rast->curr_scene pointer.
        */
-      pipe_barrier_wait( &rast->barrier );
+      util_barrier_wait( &rast->barrier );
 
       /* do work */
       if (debug)
@@ -830,7 +830,7 @@ thread_function(void *init_data)
                       rast->curr_scene);
       
       /* wait for all threads to finish with this scene */
-      pipe_barrier_wait( &rast->barrier );
+      util_barrier_wait( &rast->barrier );
 
       /* XXX: shouldn't be necessary:
        */
@@ -865,8 +865,12 @@ create_rast_threads(struct lp_rasterizer *rast)
    for (i = 0; i < rast->num_threads; i++) {
       pipe_semaphore_init(&rast->tasks[i].work_ready, 0);
       pipe_semaphore_init(&rast->tasks[i].work_done, 0);
-      rast->threads[i] = pipe_thread_create(thread_function,
+      rast->threads[i] = u_thread_create(thread_function,
                                             (void *) &rast->tasks[i]);
+      if (!rast->threads[i]) {
+         rast->num_threads = i; /* previous thread is max */
+         break;
+      }
    }
 }
 
@@ -912,7 +916,7 @@ lp_rast_create( unsigned num_threads )
 
    /* for synchronizing rasterization threads */
    if (rast->num_threads > 0) {
-      pipe_barrier_init( &rast->barrier, rast->num_threads );
+      util_barrier_init( &rast->barrier, rast->num_threads );
    }
 
    memset(lp_dummy_tile, 0, sizeof lp_dummy_tile);
@@ -971,7 +975,7 @@ void lp_rast_destroy( struct lp_rasterizer *rast )
 
    /* for synchronizing rasterization threads */
    if (rast->num_threads > 0) {
-      pipe_barrier_destroy( &rast->barrier );
+      util_barrier_destroy( &rast->barrier );
    }
 
    lp_scene_queue_destroy(rast->full_scenes);