1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**************************************************************************
2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * All Rights Reserved.
5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a
7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the
8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * "Software"), to deal in the Software without restriction, including
9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * without limitation the rights to use, copy, modify, merge, publish,
10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * distribute, sub license, and/or sell copies of the Software, and to
11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * permit persons to whom the Software is furnished to do so, subject to
12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the following conditions:
13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice (including the
15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * next paragraph) shall be included in all copies or substantial portions
16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software.
17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *
26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **************************************************************************/
27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/context.h"
30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "program/prog_print.h"
31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h"
33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_shader_tokens.h"
34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "tgsi/tgsi_dump.h"
35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "cso_cache/cso_cache.h"
37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "st_context.h"
39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "st_debug.h"
40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "st_program.h"
41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef DEBUG
45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgint ST_DEBUG = 0;
46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic const struct debug_named_value st_debug_flags[] = {
48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "mesa",     DEBUG_MESA, NULL },
49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "tgsi",     DEBUG_TGSI, NULL },
50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "constants",DEBUG_CONSTANTS, NULL },
51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "pipe",     DEBUG_PIPE, NULL },
52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "tex",      DEBUG_TEX, NULL },
53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "fallback", DEBUG_FALLBACK, NULL },
54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "screen",   DEBUG_SCREEN, NULL },
55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   { "query",    DEBUG_QUERY, NULL },
56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   DEBUG_NAMED_VALUE_END
57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org};
58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgDEBUG_GET_ONCE_FLAGS_OPTION(st_debug, "ST_DEBUG", st_debug_flags, 0)
60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgst_debug_init(void)
65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifdef DEBUG
67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   ST_DEBUG = debug_get_option_st_debug();
68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/**
74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Print current state.  May be called from inside gdb to see currently
75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * bound vertex/fragment shaders and associated constants.
76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */
77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid
78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgst_print_current(void)
79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{
80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   GET_CURRENT_CONTEXT(ctx);
81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   struct st_context *st = st_context(ctx);
82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#if 0
84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   int i;
85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   printf("Vertex Transform Inputs:\n");
87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   for (i = 0; i < st->vp->state.num_inputs; i++) {
88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      printf("  Slot %d:  VERT_ATTRIB_%d\n", i, st->vp->index_to_input[i]);
89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   }
90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif
91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (st->vp->variants)
93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      tgsi_dump( st->vp->variants[0].tgsi.tokens, 0 );
94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (st->vp->Base.Base.Parameters)
95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      _mesa_print_parameter_list(st->vp->Base.Base.Parameters);
96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   tgsi_dump( st->fp->variants[0].tgsi.tokens, 0 );
98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org   if (st->fp->Base.Base.Parameters)
99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org      _mesa_print_parameter_list(st->fp->Base.Base.Parameters);
100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}
101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org
103