1/**************************************************************************
2 *
3 * Copyright 2020 Red Hat.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 **************************************************************************/
25#ifndef PIPE_TESSELLATOR_H
26#define PIPE_TESSELLATOR_H
27
28#include "pipe/p_defines.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34struct pipe_tessellator;
35struct pipe_tessellation_factors
36{
37   float outer_tf[4];
38   float inner_tf[2];
39   float pad[2];
40};
41
42struct pipe_tessellator_data
43{
44   uint32_t num_indices;
45   uint32_t num_domain_points;
46
47   uint32_t *indices;
48   float    *domain_points_u;
49   float    *domain_points_v;
50    // For Tri: domain_points_w[i] = 1.0f - domain_points_u[i] - domain_points_v[i]
51};
52
53/// Allocate and initialize a new tessellation context
54struct pipe_tessellator *p_tess_init(enum pipe_prim_type tes_prim_mode,
55                                     enum pipe_tess_spacing spacing,
56                                     bool tes_vertex_order_cw, bool tes_point_mode);
57/// Destroy & de-allocate tessellation context
58void p_tess_destroy(struct pipe_tessellator *pipe_ts);
59
60
61/// Perform Tessellation
62void p_tessellate(struct pipe_tessellator *pipe_ts,
63                  const struct pipe_tessellation_factors *tess_factors,
64                  struct pipe_tessellator_data *tess_data);
65
66#ifdef __cplusplus
67}
68#endif
69#endif
70