17ec681f3Smrg/**************************************************************************
27ec681f3Smrg *
37ec681f3Smrg * Copyright 2010 Luca Barbieri
47ec681f3Smrg *
57ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining
67ec681f3Smrg * a copy of this software and associated documentation files (the
77ec681f3Smrg * "Software"), to deal in the Software without restriction, including
87ec681f3Smrg * without limitation the rights to use, copy, modify, merge, publish,
97ec681f3Smrg * distribute, sublicense, and/or sell copies of the Software, and to
107ec681f3Smrg * permit persons to whom the Software is furnished to do so, subject to
117ec681f3Smrg * the following conditions:
127ec681f3Smrg *
137ec681f3Smrg * The above copyright notice and this permission notice (including the
147ec681f3Smrg * next paragraph) shall be included in all copies or substantial
157ec681f3Smrg * portions of the Software.
167ec681f3Smrg *
177ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
187ec681f3Smrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
197ec681f3Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
207ec681f3Smrg * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
217ec681f3Smrg * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
227ec681f3Smrg * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
237ec681f3Smrg * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
247ec681f3Smrg *
257ec681f3Smrg **************************************************************************/
267ec681f3Smrg
277ec681f3Smrg#include "pipe/p_state.h"
287ec681f3Smrg#include "util/format/u_format.h"
297ec681f3Smrg#include "util/u_debug_describe.h"
307ec681f3Smrg#include "util/u_string.h"
317ec681f3Smrg
327ec681f3Smrgvoid
337ec681f3Smrgdebug_describe_reference(char* buf, UNUSED const struct pipe_reference*ptr)
347ec681f3Smrg{
357ec681f3Smrg   strcpy(buf, "pipe_object");
367ec681f3Smrg}
377ec681f3Smrg
387ec681f3Smrgvoid
397ec681f3Smrgdebug_describe_resource(char* buf, const struct pipe_resource *ptr)
407ec681f3Smrg{
417ec681f3Smrg   switch(ptr->target)
427ec681f3Smrg   {
437ec681f3Smrg   case PIPE_BUFFER:
447ec681f3Smrg      sprintf(buf, "pipe_buffer<%u>", (unsigned)util_format_get_stride(ptr->format, ptr->width0));
457ec681f3Smrg      break;
467ec681f3Smrg   case PIPE_TEXTURE_1D:
477ec681f3Smrg      sprintf(buf, "pipe_texture1d<%u,%s,%u>", ptr->width0, util_format_short_name(ptr->format), ptr->last_level);
487ec681f3Smrg      break;
497ec681f3Smrg   case PIPE_TEXTURE_2D:
507ec681f3Smrg      sprintf(buf, "pipe_texture2d<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);
517ec681f3Smrg      break;
527ec681f3Smrg   case PIPE_TEXTURE_RECT:
537ec681f3Smrg      sprintf(buf, "pipe_texture_rect<%u,%u,%s>", ptr->width0, ptr->height0, util_format_short_name(ptr->format));
547ec681f3Smrg      break;
557ec681f3Smrg   case PIPE_TEXTURE_CUBE:
567ec681f3Smrg      sprintf(buf, "pipe_texture_cube<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);
577ec681f3Smrg      break;
587ec681f3Smrg   case PIPE_TEXTURE_3D:
597ec681f3Smrg      sprintf(buf, "pipe_texture3d<%u,%u,%u,%s,%u>", ptr->width0, ptr->height0, ptr->depth0, util_format_short_name(ptr->format), ptr->last_level);
607ec681f3Smrg      break;
617ec681f3Smrg   case PIPE_TEXTURE_1D_ARRAY:
627ec681f3Smrg      sprintf(buf, "pipe_texture_1darray<%u,%u,%s,%u>", ptr->width0, ptr->array_size, util_format_short_name(ptr->format), ptr->last_level);
637ec681f3Smrg      break;
647ec681f3Smrg   case PIPE_TEXTURE_2D_ARRAY:
657ec681f3Smrg      sprintf(buf, "pipe_texture_2darray<%u,%u,%u,%s,%u>", ptr->width0, ptr->height0, ptr->array_size, util_format_short_name(ptr->format), ptr->last_level);
667ec681f3Smrg      break;
677ec681f3Smrg   case PIPE_TEXTURE_CUBE_ARRAY:
687ec681f3Smrg      sprintf(buf, "pipe_texture_cubearray<%u,%u,%u,%s,%u>", ptr->width0, ptr->height0, ptr->array_size, util_format_short_name(ptr->format), ptr->last_level);
697ec681f3Smrg      break;
707ec681f3Smrg   default:
717ec681f3Smrg      sprintf(buf, "pipe_martian_resource<%u>", ptr->target);
727ec681f3Smrg      break;
737ec681f3Smrg   }
747ec681f3Smrg}
757ec681f3Smrg
767ec681f3Smrgvoid
777ec681f3Smrgdebug_describe_surface(char* buf, const struct pipe_surface *ptr)
787ec681f3Smrg{
797ec681f3Smrg   char res[128];
807ec681f3Smrg   debug_describe_resource(res, ptr->texture);
817ec681f3Smrg   sprintf(buf, "pipe_surface<%s,%u,%u,%u>", res, ptr->u.tex.level, ptr->u.tex.first_layer, ptr->u.tex.last_layer);
827ec681f3Smrg}
837ec681f3Smrg
847ec681f3Smrgvoid
857ec681f3Smrgdebug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)
867ec681f3Smrg{
877ec681f3Smrg   char res[128];
887ec681f3Smrg   debug_describe_resource(res, ptr->texture);
897ec681f3Smrg   sprintf(buf, "pipe_sampler_view<%s,%s>", res, util_format_short_name(ptr->format));
907ec681f3Smrg}
917ec681f3Smrg
927ec681f3Smrgvoid
937ec681f3Smrgdebug_describe_image_view(char* buf, const struct pipe_image_view *ptr)
947ec681f3Smrg{
957ec681f3Smrg   char res[128];
967ec681f3Smrg   debug_describe_resource(res, ptr->resource);
977ec681f3Smrg   sprintf(buf, "pipe_image_view<%s,%s>", res,
987ec681f3Smrg                util_format_short_name(ptr->format));
997ec681f3Smrg}
1007ec681f3Smrg
1017ec681f3Smrgvoid
1027ec681f3Smrgdebug_describe_so_target(char* buf,
1037ec681f3Smrg                         const struct pipe_stream_output_target *ptr)
1047ec681f3Smrg{
1057ec681f3Smrg   char res[128];
1067ec681f3Smrg   debug_describe_resource(res, ptr->buffer);
1077ec681f3Smrg   sprintf(buf, "pipe_stream_output_target<%s,%u,%u>", res,
1087ec681f3Smrg                ptr->buffer_offset, ptr->buffer_size);
1097ec681f3Smrg}
110