Merge remote branch 'origin/master' into pipe-video
[mesa.git] / src / gallium / state_trackers / xorg / xorg_renderer.c
index 13fa561390fbbc792a1b47b5de6dbd1bc6027287..3b3ae455c0b6648cad00c000483d8cb2ad378e64 100644 (file)
@@ -7,10 +7,10 @@
 #include "util/u_draw_quad.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
-#include "util/u_rect.h"
 #include "util/u_sampler.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 */
@@ -429,6 +429,7 @@ 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) {
@@ -448,7 +449,7 @@ void renderer_copy_prepare(struct xorg_renderer *r,
    struct xorg_shader shader;
 
    assert(screen->is_format_supported(screen, dst_surface->format,
-                                      PIPE_TEXTURE_2D,
+                                      PIPE_TEXTURE_2D, 0,
                                       PIPE_BIND_RENDER_TARGET,
                                       0));
    (void) screen;
@@ -524,7 +525,7 @@ renderer_clone_texture(struct xorg_renderer *r,
 
    /* the coming in texture should already have that invariance */
    debug_assert(screen->is_format_supported(screen, src->format,
-                                            PIPE_TEXTURE_2D,
+                                            PIPE_TEXTURE_2D, 0,
                                             PIPE_BIND_SAMPLER_VIEW, 0));
 
    format = src->format;
@@ -536,6 +537,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,25 +549,15 @@ renderer_clone_texture(struct xorg_renderer *r,
 
    {
       /* copy source framebuffer surface into texture */
-      struct pipe_surface *ps_read = screen->get_tex_surface(
-         screen, src, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
-      struct pipe_surface *ps_tex = screen->get_tex_surface(
-         screen, pt, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION );
-      if (pipe->surface_copy) {
-         pipe->surface_copy(pipe,
-                ps_tex, /* dest */
-                0, 0, /* destx/y */
-                ps_read,
-                0, 0, src->width0, src->height0);
-      } else {
-          util_surface_copy(pipe, FALSE,
-                ps_tex, /* dest */
-                0, 0, /* destx/y */
-                ps_read,
-                0, 0, src->width0, src->height0);
-      }
-      pipe_surface_reference(&ps_read, NULL);
-      pipe_surface_reference(&ps_tex, NULL);
+      struct pipe_box src_box;
+      u_box_origin_2d(src->width0, src->height0, &src_box);
+
+      pipe->resource_copy_region(pipe,
+                                 pt, /* dest */
+                                 0, /* dest_level */
+                                 0, 0, 0, /* destx/y/z */
+                                 src,
+                                 0, &src_box);
    }
 
    return pt;
@@ -608,7 +600,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)
 {
@@ -625,7 +617,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 */