• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (c) 2008 VMware, Inc.
2  * Copyright © 2018 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
22 
23 #include "u_prim.h"
24 #include "pipe/p_state.h"
25 
26 
27 /** Return string name of given primitive type */
28 const char *
u_prim_name(enum pipe_prim_type prim)29 u_prim_name(enum pipe_prim_type prim)
30 {
31 #if defined(__GNUC__)
32    /* Check that the enum is packed: */
33    STATIC_ASSERT(sizeof(enum pipe_prim_type) == 1);
34 #endif
35 
36    /* Draw merging in u_threaded_context requires that sizeof(mode) == 1. */
37    struct pipe_draw_info info;
38    STATIC_ASSERT(sizeof(info.mode) == 1);
39 
40    struct pipe_draw_vertex_state_info dvs_info;
41    STATIC_ASSERT(sizeof(dvs_info.mode) == 1);
42 
43    static const struct debug_named_value names[] = {
44       DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
45       DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),
46       DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_LOOP),
47       DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP),
48       DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES),
49       DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP),
50       DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_FAN),
51       DEBUG_NAMED_VALUE(PIPE_PRIM_QUADS),
52       DEBUG_NAMED_VALUE(PIPE_PRIM_QUAD_STRIP),
53       DEBUG_NAMED_VALUE(PIPE_PRIM_POLYGON),
54       DEBUG_NAMED_VALUE(PIPE_PRIM_LINES_ADJACENCY),
55       DEBUG_NAMED_VALUE(PIPE_PRIM_LINE_STRIP_ADJACENCY),
56       DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLES_ADJACENCY),
57       DEBUG_NAMED_VALUE(PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY),
58       DEBUG_NAMED_VALUE_END
59    };
60    return debug_dump_enum(names, prim);
61 }
62