Squashed commit of the following:
[mesa.git] / src / gallium / state_trackers / egl / x11 / native_dri2.c
index ad2fc24ed01198eaefdee4e10ffa3c583a0432fc..10a36ff8f637471a6b168b52e369a25e33db18bd 100644 (file)
  * The above copyright notice and this permission notice shall be included
  * in all copies or substantial portions of the Software.
  *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL 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.
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
  */
 
 #include "util/u_memory.h"
@@ -71,7 +72,7 @@ struct dri2_surface {
    unsigned int server_stamp;
    unsigned int client_stamp;
    int width, height;
-   struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+   struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
    uint valid_mask;
 
    boolean have_back, have_fake;
@@ -112,14 +113,14 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
 {
    struct dri2_surface *dri2surf = dri2_surface(nsurf);
    struct dri2_display *dri2dpy = dri2surf->dri2dpy;
-   struct pipe_texture templ;
+   struct pipe_resource templ;
    struct winsys_handle whandle;
    uint valid_mask;
    int i;
 
    /* free the old textures */
    for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
-      pipe_texture_reference(&dri2surf->textures[i], NULL);
+      pipe_resource_reference(&dri2surf->textures[i], NULL);
    dri2surf->valid_mask = 0x0;
 
    dri2surf->have_back = FALSE;
@@ -135,7 +136,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
    templ.height0 = dri2surf->height;
    templ.depth0 = 1;
    templ.format = dri2surf->color_format;
-   templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+   templ.bind = PIPE_BIND_RENDER_TARGET;
 
    valid_mask = 0x0;
    for (i = 0; i < num_xbufs; i++) {
@@ -174,7 +175,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
       memset(&whandle, 0, sizeof(whandle));
       whandle.stride = xbuf->pitch;
       whandle.handle = xbuf->name;
-      dri2surf->textures[natt] = dri2dpy->base.screen->texture_from_handle(
+      dri2surf->textures[natt] = dri2dpy->base.screen->resource_from_handle(
          dri2dpy->base.screen, &templ, &whandle);
       if (dri2surf->textures[natt])
          valid_mask |= 1 << natt;
@@ -324,7 +325,7 @@ dri2_surface_swap_buffers(struct native_surface *nsurf)
 
 static boolean
 dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
-                      unsigned int *seq_num, struct pipe_texture **textures,
+                      unsigned int *seq_num, struct pipe_resource **textures,
                       int *width, int *height)
 {
    struct dri2_surface *dri2surf = dri2_surface(nsurf);
@@ -342,10 +343,10 @@ dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
       int att;
       for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
          if (native_attachment_mask_test(attachment_mask, att)) {
-            struct pipe_texture *ptex = dri2surf->textures[att];
+            struct pipe_resource *ptex = dri2surf->textures[att];
 
             textures[att] = NULL;
-            pipe_texture_reference(&textures[att], ptex);
+            pipe_resource_reference(&textures[att], ptex);
          }
       }
    }
@@ -381,8 +382,8 @@ dri2_surface_destroy(struct native_surface *nsurf)
       free(dri2surf->last_xbufs);
 
    for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
-      struct pipe_texture *ptex = dri2surf->textures[i];
-      pipe_texture_reference(&ptex, NULL);
+      struct pipe_resource *ptex = dri2surf->textures[i];
+      pipe_resource_reference(&ptex, NULL);
    }
 
    if (dri2surf->drawable) {
@@ -517,8 +518,8 @@ is_format_supported(struct pipe_screen *screen,
                     enum pipe_format fmt, boolean is_color)
 {
    return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D,
-         (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET :
-         PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+         (is_color) ? PIPE_BIND_RENDER_TARGET :
+         PIPE_BIND_DEPTH_STENCIL, 0);
 }
 
 static boolean