i965: use pack/unpackDouble lowering
[mesa.git] / src / gallium / drivers / svga / svga_context.c
index f8622b96f45b1cc3a8f873baa578e2624b37d471..32dc209b6192136cd305d8c3d4040b82c898ca68 100644 (file)
@@ -31,6 +31,7 @@
 #include "util/u_memory.h"
 #include "util/u_bitmask.h"
 #include "util/u_upload_mgr.h"
+#include "os/os_time.h"
 
 #include "svga_context.h"
 #include "svga_screen.h"
@@ -46,7 +47,6 @@
 #include "svga_winsys.h"
 
 #define CONST0_UPLOAD_DEFAULT_SIZE 65536
-#define CONST0_UPLOAD_ALIGNMENT 256
 
 DEBUG_GET_ONCE_BOOL_OPTION(no_swtnl, "SVGA_NO_SWTNL", FALSE)
 DEBUG_GET_ONCE_BOOL_OPTION(force_swtnl, "SVGA_FORCE_SWTNL", FALSE);
@@ -61,7 +61,7 @@ static void svga_destroy( struct pipe_context *pipe )
    unsigned shader, i;
 
    /* free any alternate rasterizer states used for point sprite */
-   for (i = 0; i < Elements(svga->rasterizer_no_cull); i++) {
+   for (i = 0; i < ARRAY_SIZE(svga->rasterizer_no_cull); i++) {
       if (svga->rasterizer_no_cull[i]) {
          pipe->delete_rasterizer_state(pipe, svga->rasterizer_no_cull[i]);
       }
@@ -78,7 +78,7 @@ static void svga_destroy( struct pipe_context *pipe )
    pipe_resource_reference(&svga->polygon_stipple.texture, NULL);
 
    /* free HW constant buffers */
-   for (shader = 0; shader < Elements(svga->state.hw_draw.constbuf); shader++) {
+   for (shader = 0; shader < ARRAY_SIZE(svga->state.hw_draw.constbuf); shader++) {
       pipe_resource_reference(&svga->state.hw_draw.constbuf[shader], NULL);
    }
 
@@ -116,7 +116,7 @@ static void svga_destroy( struct pipe_context *pipe )
 
    /* free user's constant buffers */
    for (shader = 0; shader < PIPE_SHADER_TYPES; ++shader) {
-      for (i = 0; i < Elements(svga->curr.constbufs[shader]); ++i) {
+      for (i = 0; i < ARRAY_SIZE(svga->curr.constbufs[shader]); ++i) {
          pipe_resource_reference(&svga->curr.constbufs[shader][i].buffer, NULL);
       }
    }
@@ -134,7 +134,7 @@ struct pipe_context *svga_context_create(struct pipe_screen *screen,
    enum pipe_error ret;
 
    svga = CALLOC_STRUCT(svga_context);
-   if (svga == NULL)
+   if (!svga)
       goto cleanup;
 
    LIST_INITHEAD(&svga->dirty_buffers);
@@ -220,8 +220,8 @@ struct pipe_context *svga_context_create(struct pipe_screen *screen,
 
    svga->const0_upload = u_upload_create(&svga->pipe,
                                          CONST0_UPLOAD_DEFAULT_SIZE,
-                                         CONST0_UPLOAD_ALIGNMENT,
-                                         PIPE_BIND_CONSTANT_BUFFER);
+                                         PIPE_BIND_CONSTANT_BUFFER,
+                                         PIPE_USAGE_STREAM);
    if (!svga->const0_upload)
       goto cleanup;
 
@@ -247,6 +247,7 @@ struct pipe_context *svga_context_create(struct pipe_screen *screen,
           sizeof(svga->state.hw_draw.default_constbuf_size));
    memset(svga->state.hw_draw.enabled_constbufs, 0,
           sizeof(svga->state.hw_draw.enabled_constbufs));
+   svga->state.hw_draw.ib = NULL;
 
    /* Create a no-operation blend state which we will bind whenever the
     * requested blend state is impossible (e.g. due to having an integer
@@ -300,6 +301,7 @@ void svga_context_flush( struct svga_context *svga,
 {
    struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
    struct pipe_fence_handle *fence = NULL;
+   uint64_t t0;
 
    svga->curr.nr_fbs = 0;
 
@@ -308,9 +310,14 @@ void svga_context_flush( struct svga_context *svga,
     */
    svga_context_flush_buffers(svga);
 
+   svga->hud.command_buffer_size +=
+      svga->swc->get_command_buffer_size(svga->swc);
+
    /* Flush pending commands to hardware:
     */
+   t0 = os_time_get();
    svga->swc->flush(svga->swc, &fence);
+   svga->hud.flush_time += (os_time_get() - t0);
 
    svga->hud.num_flushes++;
 
@@ -340,7 +347,7 @@ void svga_context_flush( struct svga_context *svga,
                                           PIPE_TIMEOUT_INFINITE);
    }
 
-   if(pfence)
+   if (pfence)
       svgascreen->sws->fence_reference(svgascreen->sws, pfence, fence);
 
    svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL);