1bf215546Sopenharmony_ci/**********************************************************
2bf215546Sopenharmony_ci * Copyright 2011 VMware, Inc.  All rights reserved.
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person
5bf215546Sopenharmony_ci * obtaining a copy of this software and associated documentation
6bf215546Sopenharmony_ci * files (the "Software"), to deal in the Software without
7bf215546Sopenharmony_ci * restriction, including without limitation the rights to use, copy,
8bf215546Sopenharmony_ci * modify, merge, publish, distribute, sublicense, and/or sell copies
9bf215546Sopenharmony_ci * of the Software, and to permit persons to whom the Software is
10bf215546Sopenharmony_ci * furnished to do so, subject to the following conditions:
11bf215546Sopenharmony_ci *
12bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be
13bf215546Sopenharmony_ci * included in all copies or substantial portions of the Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18bf215546Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19bf215546Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20bf215546Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21bf215546Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22bf215546Sopenharmony_ci * SOFTWARE.
23bf215546Sopenharmony_ci *
24bf215546Sopenharmony_ci **********************************************************/
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#ifndef SVGA_FORMAT_H_
27bf215546Sopenharmony_ci#define SVGA_FORMAT_H_
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#include "pipe/p_format.h"
31bf215546Sopenharmony_ci#include "svga_context.h"
32bf215546Sopenharmony_ci#include "svga_types.h"
33bf215546Sopenharmony_ci#include "svga_reg.h"
34bf215546Sopenharmony_ci#include "svga3d_reg.h"
35bf215546Sopenharmony_ci
36bf215546Sopenharmony_ci
37bf215546Sopenharmony_cistruct svga_screen;
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci/**
41bf215546Sopenharmony_ci * Vertex format flags.  These are used to specify that some vertex formats
42bf215546Sopenharmony_ci * need extra processing/conversion in the vertex shader.  For example,
43bf215546Sopenharmony_ci * setting the W component to 1, or swapping R/B, or converting packed uint
44bf215546Sopenharmony_ci * types to signed int/snorm.
45bf215546Sopenharmony_ci */
46bf215546Sopenharmony_ci#define VF_ADJUST_RANGE     (1 << 0)
47bf215546Sopenharmony_ci#define VF_W_TO_1           (1 << 1)
48bf215546Sopenharmony_ci#define VF_U_TO_F_CAST      (1 << 2)  /* convert uint to float */
49bf215546Sopenharmony_ci#define VF_I_TO_F_CAST      (1 << 3)  /* convert sint to float */
50bf215546Sopenharmony_ci#define VF_BGRA             (1 << 4)  /* swap R/B */
51bf215546Sopenharmony_ci#define VF_PUINT_TO_SNORM   (1 << 5)  /* 10_10_10_2 to snorm */
52bf215546Sopenharmony_ci#define VF_PUINT_TO_USCALED (1 << 6)  /* 10_10_10_2 to uscaled */
53bf215546Sopenharmony_ci#define VF_PUINT_TO_SSCALED (1 << 7)  /* 10_10_10_2 to sscaled */
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_ci/**
56bf215546Sopenharmony_ci * Texture format flags.
57bf215546Sopenharmony_ci */
58bf215546Sopenharmony_ci#define TF_GEN_MIPS         (1 << 8)  /* supports hw generate mipmap */
59bf215546Sopenharmony_ci#define TF_000X             (1 << 9)  /* swizzle <0, 0, 0, X> */
60bf215546Sopenharmony_ci#define TF_XXXX             (1 << 10) /* swizzle <X, X, X, X> */
61bf215546Sopenharmony_ci#define TF_XXX1             (1 << 11) /* swizzle <X, X, X, 1> */
62bf215546Sopenharmony_ci#define TF_XXXY             (1 << 12) /* swizzle <X, X, X, Y> */
63bf215546Sopenharmony_ci#define TF_UAV              (1 << 13) /* supports uav */
64bf215546Sopenharmony_ci#define TF_SM5              (1 << 14) /* supported in SM5 */
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_civoid
67bf215546Sopenharmony_cisvga_translate_vertex_format_vgpu10(enum pipe_format format,
68bf215546Sopenharmony_ci                                    SVGA3dSurfaceFormat *svga_format,
69bf215546Sopenharmony_ci                                    unsigned *vf_flags);
70bf215546Sopenharmony_ci
71bf215546Sopenharmony_civoid
72bf215546Sopenharmony_cisvga_translate_texture_buffer_view_format(enum pipe_format format,
73bf215546Sopenharmony_ci                                          SVGA3dSurfaceFormat *svga_format,
74bf215546Sopenharmony_ci                                          unsigned *tf_flags);
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_cienum SVGA3dSurfaceFormat
77bf215546Sopenharmony_cisvga_translate_format(const struct svga_screen *ss,
78bf215546Sopenharmony_ci                      enum pipe_format format,
79bf215546Sopenharmony_ci                      unsigned bind);
80bf215546Sopenharmony_ci
81bf215546Sopenharmony_civoid
82bf215546Sopenharmony_cisvga_get_format_cap(struct svga_screen *ss,
83bf215546Sopenharmony_ci                    SVGA3dSurfaceFormat format,
84bf215546Sopenharmony_ci                    SVGA3dSurfaceFormatCaps *caps);
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_civoid
87bf215546Sopenharmony_cisvga_format_size(SVGA3dSurfaceFormat format,
88bf215546Sopenharmony_ci                 unsigned *block_width,
89bf215546Sopenharmony_ci                 unsigned *block_height,
90bf215546Sopenharmony_ci                 unsigned *bytes_per_block);
91bf215546Sopenharmony_ci
92bf215546Sopenharmony_ciconst char *
93bf215546Sopenharmony_cisvga_format_name(SVGA3dSurfaceFormat format);
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ciboolean
96bf215546Sopenharmony_cisvga_format_is_integer(SVGA3dSurfaceFormat format);
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ciboolean
99bf215546Sopenharmony_cisvga_format_support_gen_mips(enum pipe_format format);
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_cienum tgsi_return_type
102bf215546Sopenharmony_cisvga_get_texture_datatype(enum pipe_format format);
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ci
105bf215546Sopenharmony_ci// XXX: Move this to svga_context?
106bf215546Sopenharmony_ciboolean
107bf215546Sopenharmony_cisvga_has_any_integer_cbufs(const struct svga_context *svga);
108bf215546Sopenharmony_ci
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ciSVGA3dSurfaceFormat
111bf215546Sopenharmony_cisvga_typeless_format(SVGA3dSurfaceFormat format);
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ci
114bf215546Sopenharmony_ciSVGA3dSurfaceFormat
115bf215546Sopenharmony_cisvga_sampler_format(SVGA3dSurfaceFormat format);
116bf215546Sopenharmony_ci
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_cibool
119bf215546Sopenharmony_cisvga_format_is_uncompressed_snorm(SVGA3dSurfaceFormat format);
120bf215546Sopenharmony_ci
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_cibool
123bf215546Sopenharmony_cisvga_format_is_typeless(SVGA3dSurfaceFormat format);
124bf215546Sopenharmony_ci
125bf215546Sopenharmony_cibool
126bf215546Sopenharmony_cisvga_format_is_shareable(const struct svga_screen *ss,
127bf215546Sopenharmony_ci                         enum pipe_format pformat,
128bf215546Sopenharmony_ci                         SVGA3dSurfaceFormat sformat,
129bf215546Sopenharmony_ci                         unsigned bind,
130bf215546Sopenharmony_ci                         bool verbose);
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ciSVGA3dSurfaceFormat
133bf215546Sopenharmony_cisvga_linear_to_srgb(SVGA3dSurfaceFormat format);
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_cibool
137bf215546Sopenharmony_cisvga_is_format_supported(struct pipe_screen *screen,
138bf215546Sopenharmony_ci                         enum pipe_format format,
139bf215546Sopenharmony_ci                         enum pipe_texture_target target,
140bf215546Sopenharmony_ci                         unsigned sample_count,
141bf215546Sopenharmony_ci                         unsigned storage_sample_count,
142bf215546Sopenharmony_ci                         unsigned bindings);
143bf215546Sopenharmony_ci
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_cibool
146bf215546Sopenharmony_cisvga_is_dx_format_supported(struct pipe_screen *screen,
147bf215546Sopenharmony_ci                            enum pipe_format format,
148bf215546Sopenharmony_ci                            enum pipe_texture_target target,
149bf215546Sopenharmony_ci                            unsigned sample_count,
150bf215546Sopenharmony_ci                            unsigned storage_sample_count,
151bf215546Sopenharmony_ci                            unsigned bindings);
152bf215546Sopenharmony_ci
153bf215546Sopenharmony_ci#endif /* SVGA_FORMAT_H_ */
154