1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2010 Luca Barbieri
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a copy of this software and associated documentation files (the
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sublicense, and/or sell copies of the Software, and to
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * portions of the Software.
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h"
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_format.h"
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_debug_describe.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_string.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdebug_describe_reference(char* buf, const struct pipe_reference*ptr)
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   strcpy(buf, "pipe_object");
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdebug_describe_resource(char* buf, const struct pipe_resource *ptr)
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   switch(ptr->target)
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   {
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_BUFFER:
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_buffer<%u>", (unsigned)util_format_get_stride(ptr->format, ptr->width0));
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_TEXTURE_1D:
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_texture1d<%u,%s,%u>", ptr->width0, util_format_short_name(ptr->format), ptr->last_level);
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_TEXTURE_2D:
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_texture2d<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_TEXTURE_RECT:
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_texture_rect<%u,%u,%s>", ptr->width0, ptr->height0, util_format_short_name(ptr->format));
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_TEXTURE_CUBE:
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_texture_cube<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   case PIPE_TEXTURE_3D:
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_texture3d<%u,%u,%u,%s,%u>", ptr->width0, ptr->height0, ptr->depth0, util_format_short_name(ptr->format), ptr->last_level);
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   default:
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      util_sprintf(buf, "pipe_martian_resource<%u>", ptr->target);
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      break;
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdebug_describe_surface(char* buf, const struct pipe_surface *ptr)
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   char res[128];
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   debug_describe_resource(res, ptr->texture);
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_sprintf(buf, "pipe_surface<%s,%u,%u,%u>", res, ptr->u.tex.level, ptr->u.tex.first_layer, ptr->u.tex.last_layer);
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdebug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   char res[128];
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   debug_describe_resource(res, ptr->texture);
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_sprintf(buf, "pipe_sampler_view<%s,%s>", res, util_format_short_name(ptr->format));
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgdebug_describe_so_target(char* buf,
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                         const struct pipe_stream_output_target *ptr)
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   char res[128];
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   debug_describe_resource(res, ptr->buffer);
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   util_sprintf(buf, "pipe_stream_output_target<%s,%u,%u>", res,
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org                ptr->buffer_offset, ptr->buffer_size);
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
92