Squashed commit of the following:
[mesa.git] / src / gallium / drivers / trace / tr_rbug.c
index af1d7f3224e8d8f07f409911ff84d8b9e6ffbd51..3ce1b85854b893e8644a0800dcb4a9ec6752d9dd 100644 (file)
  **************************************************************************/
 
 
+#include "os/os_thread.h"
+#include "util/u_format.h"
 #include "util/u_string.h"
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 #include "util/u_simple_list.h"
 #include "util/u_network.h"
+#include "os/os_time.h"
 
 #include "tgsi/tgsi_parse.h"
 
 #include "tr_dump.h"
 #include "tr_state.h"
-#include "tr_buffer.h"
 #include "tr_texture.h"
 
 #include "rbug/rbug.h"
 
 #include <errno.h>
 
-#if defined(PIPE_SUBSYSTEM_WINDOWS_USER)
-#  define sleep Sleep
-#elif defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
-void usleep(int);
-#  define sleep usleep
-#else
-#  warning "No socket implementation"
-#endif
-
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
@@ -156,7 +150,7 @@ static int
 trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
 {
    struct trace_screen *tr_scr = tr_rbug->tr_scr;
-   struct trace_texture *tr_tex = NULL;
+   struct trace_resource *tr_tex = NULL;
    struct tr_list *ptr;
    rbug_texture_t *texs;
    int i = 0;
@@ -164,7 +158,7 @@ trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header,
    pipe_mutex_lock(tr_scr->list_mutex);
    texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t));
    foreach(ptr, &tr_scr->textures) {
-      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
       texs[i++] = VOID2U64(tr_tex);
    }
    pipe_mutex_unlock(tr_scr->list_mutex);
@@ -179,14 +173,14 @@ static int
 trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
 {
    struct trace_screen *tr_scr = tr_rbug->tr_scr;
-   struct trace_texture *tr_tex;
+   struct trace_resource *tr_tex = NULL;
    struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
    struct tr_list *ptr;
-   struct pipe_texture *t;
+   struct pipe_resource *t;
 
    pipe_mutex_lock(tr_scr->list_mutex);
    foreach(ptr, &tr_scr->textures) {
-      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
       if (gpti->texture == VOID2U64(tr_tex))
          break;
       tr_tex = NULL;
@@ -197,18 +191,18 @@ trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
       return -ESRCH;
    }
 
-   t = tr_tex->texture;
+   t = tr_tex->resource;
    rbug_send_texture_info_reply(tr_rbug->con, serial,
                                t->target, t->format,
                                &t->width0, 1,
                                &t->height0, 1,
                                &t->depth0, 1,
-                               pf_get_blockwidth(t->format),
-                               pf_get_blockheight(t->format),
-                               pf_get_blocksize(t->format),
+                               util_format_get_blockwidth(t->format),
+                               util_format_get_blockheight(t->format),
+                               util_format_get_blocksize(t->format),
                                t->last_level,
                                t->nr_samples,
-                               t->tex_usage,
+                               t->bind,
                                NULL);
 
    pipe_mutex_unlock(tr_scr->list_mutex);
@@ -222,18 +216,18 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
    struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header;
 
    struct trace_screen *tr_scr = tr_rbug->tr_scr;
-   struct trace_texture *tr_tex;
+   struct trace_resource *tr_tex = NULL;
    struct tr_list *ptr;
 
-   struct pipe_screen *screen = tr_scr->screen;
-   struct pipe_texture *tex;
+   struct pipe_context *context = tr_scr->private_context;
+   struct pipe_resource *tex;
    struct pipe_transfer *t;
 
    void *map;
 
    pipe_mutex_lock(tr_scr->list_mutex);
    foreach(ptr, &tr_scr->textures) {
-      tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+      tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
       if (gptr->texture == VOID2U64(tr_tex))
          break;
       tr_tex = NULL;
@@ -244,26 +238,27 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
       return -ESRCH;
    }
 
-   tex = tr_tex->texture;
-   t = screen->get_tex_transfer(tr_scr->screen, tex,
-                                gptr->face, gptr->level, gptr->zslice,
-                                PIPE_TRANSFER_READ,
-                                gptr->x, gptr->y, gptr->w, gptr->h);
+   tex = tr_tex->resource;
+   t = pipe_get_transfer(context, tex,
+                                gptr->face, gptr->level, gptr->zslice,
+                                PIPE_TRANSFER_READ,
+                                gptr->x, gptr->y, gptr->w, gptr->h);
 
-   map = screen->transfer_map(screen, t);
+   map = context->transfer_map(context, t);
 
    rbug_send_texture_read_reply(tr_rbug->con, serial,
-                                t->texture->format,
-                                pf_get_blockwidth(t->texture->format),
-                                pf_get_blockheight(t->texture->format),
-                                pf_get_blocksize(t->texture->format),
+                                t->resource->format,
+                                util_format_get_blockwidth(t->resource->format),
+                                util_format_get_blockheight(t->resource->format),
+                                util_format_get_blocksize(t->resource->format),
                                 (uint8_t*)map,
-                                t->stride * pf_get_nblocksy(t->texture->format, t->height),
+                                t->stride * util_format_get_nblocksy(t->resource->format,
+                                                                    t->box.height),
                                 t->stride,
                                 NULL);
 
-   screen->transfer_unmap(screen, t);
-   screen->tex_transfer_destroy(t);
+   context->transfer_unmap(context, t);
+   context->transfer_destroy(context, t);
 
    pipe_mutex_unlock(tr_scr->list_mutex);
 
@@ -319,12 +314,12 @@ trace_rbug_context_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
    for (i = 0; i < tr_ctx->curr.nr_cbufs; i++)
       cbufs[i] = VOID2U64(tr_ctx->curr.cbufs[i]);
 
-   for (i = 0; i < tr_ctx->curr.num_texs; i++)
-      texs[i] = VOID2U64(tr_ctx->curr.tex[i]);
+   for (i = 0; i < tr_ctx->curr.num_sampler_views; i++)
+      texs[i] = VOID2U64(tr_ctx->curr.sampler_views[i]);
 
    rbug_send_context_info_reply(tr_rbug->con, serial,
                                 VOID2U64(tr_ctx->curr.vs), VOID2U64(tr_ctx->curr.fs),
-                                texs, tr_ctx->curr.num_texs,
+                                texs, tr_ctx->curr.num_sampler_views,
                                 cbufs, tr_ctx->curr.nr_cbufs,
                                 VOID2U64(tr_ctx->curr.zsbuf),
                                 tr_ctx->draw_blocker, tr_ctx->draw_blocked, NULL);
@@ -450,7 +445,7 @@ trace_rbug_context_draw_rule(struct trace_rbug *tr_rbug, struct rbug_header *hea
    pipe_mutex_lock(tr_ctx->draw_mutex);
    tr_ctx->draw_rule.vs = U642VOID(rule->vertex);
    tr_ctx->draw_rule.fs = U642VOID(rule->fragment);
-   tr_ctx->draw_rule.tex = U642VOID(rule->texture);
+   tr_ctx->draw_rule.sampler_view = U642VOID(rule->texture);
    tr_ctx->draw_rule.surf = U642VOID(rule->surface);
    tr_ctx->draw_rule.blocker = rule->block;
    tr_ctx->draw_blocker |= RBUG_BLOCK_RULE;
@@ -804,7 +799,7 @@ PIPE_THREAD_ROUTINE(trace_rbug_thread, void_tr_rbug)
    debug_printf("trace_rbug - remote debugging listening on port %u\n", --port);
 
    while(tr_rbug->running) {
-      sleep(1);
+      os_time_sleep(1);
 
       c = u_socket_accept(s);
       if (c < 0)