Path: blob/21.2-virgl/src/gallium/auxiliary/util/u_debug_describe.c
4561 views
/**************************************************************************1*2* Copyright 2010 Luca Barbieri3*4* Permission is hereby granted, free of charge, to any person obtaining5* a copy of this software and associated documentation files (the6* "Software"), to deal in the Software without restriction, including7* without limitation the rights to use, copy, modify, merge, publish,8* distribute, sublicense, and/or sell copies of the Software, and to9* permit persons to whom the Software is furnished to do so, subject to10* the following conditions:11*12* The above copyright notice and this permission notice (including the13* next paragraph) shall be included in all copies or substantial14* portions of the Software.15*16* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF18* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.19* IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE20* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION21* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION22* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.23*24**************************************************************************/2526#include "pipe/p_state.h"27#include "util/format/u_format.h"28#include "util/u_debug_describe.h"29#include "util/u_string.h"3031void32debug_describe_reference(char* buf, UNUSED const struct pipe_reference*ptr)33{34strcpy(buf, "pipe_object");35}3637void38debug_describe_resource(char* buf, const struct pipe_resource *ptr)39{40switch(ptr->target)41{42case PIPE_BUFFER:43sprintf(buf, "pipe_buffer<%u>", (unsigned)util_format_get_stride(ptr->format, ptr->width0));44break;45case PIPE_TEXTURE_1D:46sprintf(buf, "pipe_texture1d<%u,%s,%u>", ptr->width0, util_format_short_name(ptr->format), ptr->last_level);47break;48case PIPE_TEXTURE_2D:49sprintf(buf, "pipe_texture2d<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);50break;51case PIPE_TEXTURE_RECT:52sprintf(buf, "pipe_texture_rect<%u,%u,%s>", ptr->width0, ptr->height0, util_format_short_name(ptr->format));53break;54case PIPE_TEXTURE_CUBE:55sprintf(buf, "pipe_texture_cube<%u,%u,%s,%u>", ptr->width0, ptr->height0, util_format_short_name(ptr->format), ptr->last_level);56break;57case PIPE_TEXTURE_3D:58sprintf(buf, "pipe_texture3d<%u,%u,%u,%s,%u>", ptr->width0, ptr->height0, ptr->depth0, util_format_short_name(ptr->format), ptr->last_level);59break;60case PIPE_TEXTURE_1D_ARRAY:61sprintf(buf, "pipe_texture_1darray<%u,%u,%s,%u>", ptr->width0, ptr->array_size, util_format_short_name(ptr->format), ptr->last_level);62break;63case PIPE_TEXTURE_2D_ARRAY:64sprintf(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);65break;66case PIPE_TEXTURE_CUBE_ARRAY:67sprintf(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);68break;69default:70sprintf(buf, "pipe_martian_resource<%u>", ptr->target);71break;72}73}7475void76debug_describe_surface(char* buf, const struct pipe_surface *ptr)77{78char res[128];79debug_describe_resource(res, ptr->texture);80sprintf(buf, "pipe_surface<%s,%u,%u,%u>", res, ptr->u.tex.level, ptr->u.tex.first_layer, ptr->u.tex.last_layer);81}8283void84debug_describe_sampler_view(char* buf, const struct pipe_sampler_view *ptr)85{86char res[128];87debug_describe_resource(res, ptr->texture);88sprintf(buf, "pipe_sampler_view<%s,%s>", res, util_format_short_name(ptr->format));89}9091void92debug_describe_image_view(char* buf, const struct pipe_image_view *ptr)93{94char res[128];95debug_describe_resource(res, ptr->resource);96sprintf(buf, "pipe_image_view<%s,%s>", res,97util_format_short_name(ptr->format));98}99100void101debug_describe_so_target(char* buf,102const struct pipe_stream_output_target *ptr)103{104char res[128];105debug_describe_resource(res, ptr->buffer);106sprintf(buf, "pipe_stream_output_target<%s,%u,%u>", res,107ptr->buffer_offset, ptr->buffer_size);108}109110111