diff options
Diffstat (limited to 'src/gallium/drivers/trace/tr_screen.c')
-rw-r--r-- | src/gallium/drivers/trace/tr_screen.c | 496 |
1 files changed, 59 insertions, 437 deletions
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 388d83eb5c2..63a45d7e512 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -29,14 +29,13 @@ #include "util/u_memory.h" #include "util/u_simple_list.h" -#include "tr_buffer.h" #include "tr_dump.h" #include "tr_dump_state.h" #include "tr_texture.h" #include "tr_context.h" #include "tr_screen.h" +#include "tr_public.h" -#include "util/u_inlines.h" #include "pipe/p_format.h" @@ -212,70 +211,73 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen, */ -static struct pipe_texture * -trace_screen_texture_create(struct pipe_screen *_screen, - const struct pipe_texture *templat) +static struct pipe_resource * +trace_screen_resource_create(struct pipe_screen *_screen, + const struct pipe_resource *templat) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; - struct pipe_texture *result; + struct pipe_resource *result; - trace_dump_call_begin("pipe_screen", "texture_create"); + trace_dump_call_begin("pipe_screen", "resource_create"); trace_dump_arg(ptr, screen); - trace_dump_arg(template, templat); + trace_dump_arg(resource_template, templat); - result = screen->texture_create(screen, templat); + result = screen->resource_create(screen, templat); trace_dump_ret(ptr, result); trace_dump_call_end(); - result = trace_texture_create(tr_scr, result); + result = trace_resource_create(tr_scr, result); return result; } - -static struct pipe_texture * -trace_screen_texture_blanket(struct pipe_screen *_screen, - const struct pipe_texture *templat, - const unsigned *ppitch, - struct pipe_buffer *_buffer) +static struct pipe_resource * +trace_screen_resource_from_handle(struct pipe_screen *_screen, + const struct pipe_resource *templ, + struct winsys_handle *handle) { - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - unsigned pitch = *ppitch; - struct pipe_texture *result; + struct trace_screen *tr_screen = trace_screen(_screen); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_resource *result; - trace_dump_call_begin("pipe_screen", "texture_blanket"); + /* TODO trace call */ - trace_dump_arg(ptr, screen); - trace_dump_arg(template, templat); - trace_dump_arg(uint, pitch); - trace_dump_arg(ptr, buffer); + result = screen->resource_from_handle(screen, templ, handle); - result = screen->texture_blanket(screen, templat, ppitch, buffer); + result = trace_resource_create(trace_screen(_screen), result); - trace_dump_ret(ptr, result); + return result; +} - trace_dump_call_end(); +static boolean +trace_screen_resource_get_handle(struct pipe_screen *_screen, + struct pipe_resource *_texture, + struct winsys_handle *handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_resource *tr_texture = trace_resource(_texture); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_resource *texture = tr_texture->resource; - result = trace_texture_create(tr_scr, result); + /* TODO trace call */ - return result; + return screen->resource_get_handle(screen, texture, handle); } + static void -trace_screen_texture_destroy(struct pipe_texture *_texture) +trace_screen_resource_destroy(struct pipe_screen *_screen, + struct pipe_resource *_texture) { - struct trace_screen *tr_scr = trace_screen(_texture->screen); - struct trace_texture *tr_tex = trace_texture(_texture); + struct trace_screen *tr_scr = trace_screen(_screen); + struct trace_resource *tr_tex = trace_resource(_texture); struct pipe_screen *screen = tr_scr->screen; - struct pipe_texture *texture = tr_tex->texture; + struct pipe_resource *texture = tr_tex->resource; assert(texture->screen == screen); @@ -286,7 +288,7 @@ trace_screen_texture_destroy(struct pipe_texture *_texture) trace_dump_call_end(); - trace_texture_destroy(tr_tex); + trace_resource_destroy(tr_scr, tr_tex); } @@ -297,15 +299,15 @@ trace_screen_texture_destroy(struct pipe_texture *_texture) static struct pipe_surface * trace_screen_get_tex_surface(struct pipe_screen *_screen, - struct pipe_texture *_texture, + struct pipe_resource *_texture, unsigned face, unsigned level, unsigned zslice, unsigned usage) { struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(_texture); + struct trace_resource *tr_tex = trace_resource(_texture); struct pipe_screen *screen = tr_scr->screen; - struct pipe_texture *texture = tr_tex->texture; + struct pipe_resource *texture = tr_tex->resource; struct pipe_surface *result = NULL; assert(texture->screen == screen); @@ -350,133 +352,7 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface) } -/******************************************************************** - * transfer - */ - - -static struct pipe_transfer * -trace_screen_get_tex_transfer(struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned face, unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(_texture); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_texture *texture = tr_tex->texture; - struct pipe_transfer *result = NULL; - - assert(texture->screen == screen); - - trace_dump_call_begin("pipe_screen", "get_tex_transfer"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, texture); - trace_dump_arg(uint, face); - trace_dump_arg(uint, level); - trace_dump_arg(uint, zslice); - trace_dump_arg(uint, usage); - - trace_dump_arg(uint, x); - trace_dump_arg(uint, y); - trace_dump_arg(uint, w); - trace_dump_arg(uint, h); - - result = screen->get_tex_transfer(screen, texture, face, level, zslice, usage, - x, y, w, h); - - trace_dump_ret(ptr, result); - - trace_dump_call_end(); - - if (result) - result = trace_transfer_create(tr_tex, result); - - return result; -} - - -static void -trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - - trace_dump_call_begin("pipe_screen", "tex_transfer_destroy"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, transfer); - trace_dump_call_end(); - - trace_transfer_destroy(tr_trans); -} - - -static void * -trace_screen_transfer_map(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - void *map; - - map = screen->transfer_map(screen, transfer); - if(map) { - if(transfer->usage & PIPE_TRANSFER_WRITE) { - assert(!tr_trans->map); - tr_trans->map = map; - } - } - - return map; -} - - -static void -trace_screen_transfer_unmap(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - - if(tr_trans->map) { - size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->height) * transfer->stride; - - trace_dump_call_begin("pipe_screen", "transfer_write"); - - trace_dump_arg(ptr, screen); - - trace_dump_arg(ptr, transfer); - - trace_dump_arg_begin("stride"); - trace_dump_uint(transfer->stride); - trace_dump_arg_end(); - - trace_dump_arg_begin("data"); - trace_dump_bytes(tr_trans->map, size); - trace_dump_arg_end(); - - trace_dump_arg_begin("size"); - trace_dump_uint(size); - trace_dump_arg_end(); - - trace_dump_call_end(); - - tr_trans->map = NULL; - } - - screen->transfer_unmap(screen, transfer); -} /******************************************************************** @@ -484,92 +360,16 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen, */ -static struct pipe_buffer * -trace_screen_surface_buffer_create(struct pipe_screen *_screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *pstride) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct pipe_screen *screen = tr_scr->screen; - unsigned stride; - struct pipe_buffer *result; - - trace_dump_call_begin("pipe_screen", "surface_buffer_create"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(uint, width); - trace_dump_arg(uint, height); - trace_dump_arg(format, format); - trace_dump_arg(uint, usage); - trace_dump_arg(uint, tex_usage); - - result = screen->surface_buffer_create(screen, - width, height, - format, - usage, - tex_usage, - pstride); - - stride = *pstride; - - trace_dump_arg(uint, stride); - - trace_dump_ret(ptr, result); - - trace_dump_call_end(); - - return trace_buffer_create(tr_scr, result); -} - -static struct pipe_buffer * -trace_screen_buffer_create(struct pipe_screen *_screen, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *result; - - trace_dump_call_begin("pipe_screen", "buffer_create"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(uint, alignment); - trace_dump_arg(uint, usage); - trace_dump_arg(uint, size); - - result = screen->buffer_create(screen, alignment, usage, size); - - trace_dump_ret(ptr, result); - - trace_dump_call_end(); - - /* Zero the buffer to avoid dumping uninitialized memory */ - if(result->usage & PIPE_BUFFER_USAGE_CPU_WRITE) { - void *map; - map = pipe_buffer_map(screen, result, PIPE_BUFFER_USAGE_CPU_WRITE); - if(map) { - memset(map, 0, result->size); - screen->buffer_unmap(screen, result); - } - } - - return trace_buffer_create(tr_scr, result); -} - - -static struct pipe_buffer * +static struct pipe_resource * trace_screen_user_buffer_create(struct pipe_screen *_screen, void *data, - unsigned size) + unsigned size, + unsigned usage) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *result; + struct pipe_resource *result; trace_dump_call_begin("pipe_screen", "user_buffer_create"); @@ -578,189 +378,23 @@ trace_screen_user_buffer_create(struct pipe_screen *_screen, trace_dump_bytes(data, size); trace_dump_arg_end(); trace_dump_arg(uint, size); + trace_dump_arg(uint, usage); - result = screen->user_buffer_create(screen, data, size); + result = screen->user_buffer_create(screen, data, size, usage); trace_dump_ret(ptr, result); trace_dump_call_end(); if(result) { - assert(!(result->usage & TRACE_BUFFER_USAGE_USER)); - result->usage |= TRACE_BUFFER_USAGE_USER; - } - - return trace_buffer_create(tr_scr, result); -} - - -/** - * This function is used to track if data has been changed on a user buffer - * without map/unmap being called. - */ -void -trace_screen_user_buffer_update(struct pipe_screen *_screen, - struct pipe_buffer *_buffer) -{ -#if 0 - struct trace_screen *tr_scr = trace_screen(_screen); - struct pipe_screen *screen = tr_scr->screen; - const void *map; - - if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) { - map = screen->buffer_map(screen, buffer, PIPE_BUFFER_USAGE_CPU_READ); - if(map) { - trace_dump_call_begin("pipe_winsys", "buffer_write"); - - trace_dump_arg(ptr, screen); - - trace_dump_arg(ptr, buffer); - - trace_dump_arg_begin("data"); - trace_dump_bytes(map, buffer->size); - trace_dump_arg_end(); - - trace_dump_arg_begin("size"); - trace_dump_uint(buffer->size); - trace_dump_arg_end(); - - trace_dump_call_end(); - - screen->buffer_unmap(screen, buffer); - } - } -#endif -} - - -static void * -trace_screen_buffer_map(struct pipe_screen *_screen, - struct pipe_buffer *_buffer, - unsigned usage) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - void *map; - - assert(screen->buffer_map); - map = screen->buffer_map(screen, buffer, usage); - if(map) { - if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) { - tr_buf->map = map; - } - } - - return map; -} - - -static void * -trace_screen_buffer_map_range(struct pipe_screen *_screen, - struct pipe_buffer *_buffer, - unsigned offset, - unsigned length, - unsigned usage) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - void *map; - - assert(screen->buffer_map_range); - map = screen->buffer_map_range(screen, buffer, offset, length, usage); - if(map) { - if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) { - tr_buf->map = map; - } + assert(!(result->flags & TRACE_FLAG_USER_BUFFER)); + result->flags |= TRACE_FLAG_USER_BUFFER; } - return map; + return trace_resource_create(tr_scr, result); } -static void -buffer_write(struct pipe_screen *screen, - struct pipe_buffer *buffer, - unsigned offset, - const char *map, - unsigned size) -{ - assert(map); - - trace_dump_call_begin("pipe_screen", "buffer_write"); - - trace_dump_arg(ptr, screen); - - trace_dump_arg(ptr, buffer); - - trace_dump_arg(uint, offset); - - trace_dump_arg_begin("data"); - trace_dump_bytes(map + offset, size); - trace_dump_arg_end(); - - trace_dump_arg(uint, size); - - trace_dump_call_end(); - -} - - -static void -trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen, - struct pipe_buffer *_buffer, - unsigned offset, - unsigned length) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - - assert(tr_buf->map); - buffer_write(screen, buffer, offset, tr_buf->map, length); - tr_buf->range_flushed = TRUE; - screen->buffer_flush_mapped_range(screen, buffer, offset, length); -} - - -static void -trace_screen_buffer_unmap(struct pipe_screen *_screen, - struct pipe_buffer *_buffer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - - if (tr_buf->map && !tr_buf->range_flushed) - buffer_write(screen, buffer, 0, tr_buf->map, buffer->size); - tr_buf->map = NULL; - tr_buf->range_flushed = FALSE; - screen->buffer_unmap(screen, buffer); -} - - -static void -trace_screen_buffer_destroy(struct pipe_buffer *_buffer) -{ - struct trace_screen *tr_scr = trace_screen(_buffer->screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - - trace_dump_call_begin("pipe_screen", "buffer_destroy"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, buffer); - - trace_dump_call_end(); - - trace_buffer_destroy(tr_scr, _buffer); -} /******************************************************************** @@ -930,32 +564,22 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.is_format_supported = trace_screen_is_format_supported; assert(screen->context_create); tr_scr->base.context_create = trace_screen_context_create; - tr_scr->base.texture_create = trace_screen_texture_create; - tr_scr->base.texture_blanket = trace_screen_texture_blanket; - tr_scr->base.texture_destroy = trace_screen_texture_destroy; + tr_scr->base.resource_create = trace_screen_resource_create; + tr_scr->base.resource_from_handle = trace_screen_resource_from_handle; + tr_scr->base.resource_get_handle = trace_screen_resource_get_handle; + tr_scr->base.resource_destroy = trace_screen_resource_destroy; tr_scr->base.get_tex_surface = trace_screen_get_tex_surface; tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy; - tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer; - tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy; - tr_scr->base.transfer_map = trace_screen_transfer_map; - tr_scr->base.transfer_unmap = trace_screen_transfer_unmap; - tr_scr->base.buffer_create = trace_screen_buffer_create; tr_scr->base.user_buffer_create = trace_screen_user_buffer_create; - tr_scr->base.surface_buffer_create = trace_screen_surface_buffer_create; - if (screen->buffer_map) - tr_scr->base.buffer_map = trace_screen_buffer_map; - if (screen->buffer_map_range) - tr_scr->base.buffer_map_range = trace_screen_buffer_map_range; - if (screen->buffer_flush_mapped_range) - tr_scr->base.buffer_flush_mapped_range = trace_screen_buffer_flush_mapped_range; - if (screen->buffer_unmap) - tr_scr->base.buffer_unmap = trace_screen_buffer_unmap; - tr_scr->base.buffer_destroy = trace_screen_buffer_destroy; tr_scr->base.fence_reference = trace_screen_fence_reference; tr_scr->base.fence_signalled = trace_screen_fence_signalled; tr_scr->base.fence_finish = trace_screen_fence_finish; tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer; + tr_scr->screen = screen; + tr_scr->private_context = screen->context_create(screen, NULL); + if (tr_scr->private_context == NULL) + goto error3; trace_dump_ret(ptr, screen); trace_dump_call_end(); @@ -965,10 +589,8 @@ trace_screen_create(struct pipe_screen *screen) return &tr_scr->base; -#if 0 error3: FREE(tr_scr); -#endif error2: trace_dump_ret(ptr, screen); trace_dump_call_end(); |