gallium: change set_constant_buffer to be UBO-friendly
[mesa.git] / src / gallium / state_trackers / xorg / xorg_renderer.c
index e5def3e2edd5a5b7e2b12d850674e6a00eafe2d7..e28e06a9261f026737af6a72ba56e8321dea1ae2 100644 (file)
@@ -8,9 +8,9 @@
 #include "util/u_math.h"
 #include "util/u_memory.h"
 #include "util/u_sampler.h"
-#include "util/u_surface.h"
 
 #include "util/u_inlines.h"
+#include "util/u_box.h"
 
 #include <math.h>
 
@@ -73,7 +73,7 @@ renderer_draw(struct xorg_renderer *r)
    if (buf) {
       cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
 
-      util_draw_vertex_buffer(pipe, buf, 0,
+      util_draw_vertex_buffer(pipe, r->cso, buf, 0,
                               PIPE_PRIM_QUADS,
                               num_verts,  /* verts */
                               r->attrs_per_vertex); /* attribs/vert */
@@ -107,6 +107,7 @@ renderer_init_state(struct xorg_renderer *r)
    /* XXX: move to renderer_init_state? */
    memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
    raster.gl_rasterization_rules = 1;
+   raster.depth_clip = 1;
    cso_set_rasterizer(r->cso, &raster);
 
    /* vertex elements state */
@@ -429,13 +430,14 @@ void renderer_set_constants(struct xorg_renderer *r,
    pipe_resource_reference(cbuf, NULL);
    *cbuf = pipe_buffer_create(r->pipe->screen,
                               PIPE_BIND_CONSTANT_BUFFER,
+                              PIPE_USAGE_STATIC,
                               param_bytes);
 
    if (*cbuf) {
       pipe_buffer_write(r->pipe, *cbuf,
                         0, param_bytes, params);
    }
-   r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
+   pipe_set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
 }
 
 
@@ -449,8 +451,7 @@ void renderer_copy_prepare(struct xorg_renderer *r,
 
    assert(screen->is_format_supported(screen, dst_surface->format,
                                       PIPE_TEXTURE_2D, 0,
-                                      PIPE_BIND_RENDER_TARGET,
-                                      0));
+                                      PIPE_BIND_RENDER_TARGET));
    (void) screen;
 
 
@@ -518,14 +519,10 @@ renderer_clone_texture(struct xorg_renderer *r,
    struct pipe_resource *pt;
    struct pipe_resource templ;
 
-   if (pipe->is_resource_referenced(pipe, src, 0, 0) &
-       PIPE_REFERENCED_FOR_WRITE)
-      pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
    /* the coming in texture should already have that invariance */
    debug_assert(screen->is_format_supported(screen, src->format,
                                             PIPE_TEXTURE_2D, 0,
-                                            PIPE_BIND_SAMPLER_VIEW, 0));
+                                            PIPE_BIND_SAMPLER_VIEW));
 
    format = src->format;
 
@@ -536,6 +533,7 @@ renderer_clone_texture(struct xorg_renderer *r,
    templ.width0 = src->width0;
    templ.height0 = src->height0;
    templ.depth0 = 1;
+   templ.array_size = 1;
    templ.bind = PIPE_BIND_SAMPLER_VIEW;
 
    pt = screen->resource_create(screen, &templ);
@@ -547,19 +545,15 @@ renderer_clone_texture(struct xorg_renderer *r,
 
    {
       /* copy source framebuffer surface into texture */
-      struct pipe_subresource subsrc, subdst;
-      subsrc.face = 0;
-      subsrc.level = 0;
-      subdst.face = 0;
-      subdst.level = 0;
+      struct pipe_box src_box;
+      u_box_origin_2d(src->width0, src->height0, &src_box);
+
       pipe->resource_copy_region(pipe,
                                  pt, /* dest */
-                                 subdst,
+                                 0, /* dest_level */
                                  0, 0, 0, /* destx/y/z */
                                  src,
-                                 subsrc,
-                                 0, 0, 0,
-                                 src->width0, src->height0);
+                                 0, &src_box);
    }
 
    return pt;
@@ -602,7 +596,7 @@ void renderer_copy_pixmap(struct xorg_renderer *r,
 
 
 void renderer_draw_yuv(struct xorg_renderer *r,
-                       int src_x, int src_y, int src_w, int src_h,
+                       float src_x, float src_y, float src_w, float src_h,
                        int dst_x, int dst_y, int dst_w, int dst_h,
                        struct pipe_resource **textures)
 {
@@ -619,7 +613,7 @@ void renderer_draw_yuv(struct xorg_renderer *r,
 
       cso_set_vertex_elements(r->cso, num_attribs, r->velems);
 
-      util_draw_vertex_buffer(pipe, buf, 0,
+      util_draw_vertex_buffer(pipe, r->cso, buf, 0,
                               PIPE_PRIM_QUADS,
                               4,  /* verts */
                               num_attribs); /* attribs/vert */