• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2011-2024 Broadcom. All Rights Reserved.
3  * The term “Broadcom” refers to Broadcom Inc.
4  * and/or its subsidiaries.
5  * SPDX-License-Identifier: MIT
6  */
7 
8 #ifndef SVGA_FORMAT_H_
9 #define SVGA_FORMAT_H_
10 
11 
12 #include "util/format/u_formats.h"
13 #include "svga_context.h"
14 #include "svga_reg.h"
15 #include "svga3d_reg.h"
16 
17 
18 struct svga_screen;
19 
20 
21 /**
22  * Vertex format flags.  These are used to specify that some vertex formats
23  * need extra processing/conversion in the vertex shader.  For example,
24  * setting the W component to 1, or swapping R/B, or converting packed uint
25  * types to signed int/snorm.
26  */
27 #define VF_ADJUST_RANGE     (1 << 0)
28 #define VF_W_TO_1           (1 << 1)
29 #define VF_U_TO_F_CAST      (1 << 2)  /* convert uint to float */
30 #define VF_I_TO_F_CAST      (1 << 3)  /* convert sint to float */
31 #define VF_BGRA             (1 << 4)  /* swap R/B */
32 #define VF_PUINT_TO_SNORM   (1 << 5)  /* 10_10_10_2 to snorm */
33 #define VF_PUINT_TO_USCALED (1 << 6)  /* 10_10_10_2 to uscaled */
34 #define VF_PUINT_TO_SSCALED (1 << 7)  /* 10_10_10_2 to sscaled */
35 
36 /**
37  * Texture format flags.
38  */
39 #define TF_GEN_MIPS         (1 << 8)  /* supports hw generate mipmap */
40 #define TF_000X             (1 << 9)  /* swizzle <0, 0, 0, X> */
41 #define TF_XXXX             (1 << 10) /* swizzle <X, X, X, X> */
42 #define TF_XXX1             (1 << 11) /* swizzle <X, X, X, 1> */
43 #define TF_XXXY             (1 << 12) /* swizzle <X, X, X, Y> */
44 #define TF_UAV              (1 << 13) /* supports uav */
45 #define TF_SM5              (1 << 14) /* supported in SM5 */
46 
47 void
48 svga_translate_vertex_format_vgpu10(enum pipe_format format,
49                                     SVGA3dSurfaceFormat *svga_format,
50                                     unsigned *vf_flags);
51 
52 void
53 svga_translate_texture_buffer_view_format(enum pipe_format format,
54                                           SVGA3dSurfaceFormat *svga_format,
55                                           unsigned *tf_flags);
56 
57 enum SVGA3dSurfaceFormat
58 svga_translate_format(const struct svga_screen *ss,
59                       enum pipe_format format,
60                       unsigned bind);
61 
62 void
63 svga_get_format_cap(struct svga_screen *ss,
64                     SVGA3dSurfaceFormat format,
65                     SVGA3dSurfaceFormatCaps *caps);
66 
67 void
68 svga_format_size(SVGA3dSurfaceFormat format,
69                  unsigned *block_width,
70                  unsigned *block_height,
71                  unsigned *bytes_per_block);
72 
73 const char *
74 svga_format_name(SVGA3dSurfaceFormat format);
75 
76 bool
77 svga_format_is_integer(SVGA3dSurfaceFormat format);
78 
79 bool
80 svga_format_support_gen_mips(enum pipe_format format);
81 
82 enum tgsi_return_type
83 svga_get_texture_datatype(enum pipe_format format);
84 
85 
86 // XXX: Move this to svga_context?
87 bool
88 svga_has_any_integer_cbufs(const struct svga_context *svga);
89 
90 
91 SVGA3dSurfaceFormat
92 svga_typeless_format(SVGA3dSurfaceFormat format);
93 
94 
95 SVGA3dSurfaceFormat
96 svga_sampler_format(SVGA3dSurfaceFormat format);
97 
98 
99 bool
100 svga_format_is_uncompressed_snorm(SVGA3dSurfaceFormat format);
101 
102 
103 bool
104 svga_format_is_typeless(SVGA3dSurfaceFormat format);
105 
106 bool
107 svga_format_is_shareable(const struct svga_screen *ss,
108                          enum pipe_format pformat,
109                          SVGA3dSurfaceFormat sformat,
110                          unsigned bind,
111                          bool verbose);
112 
113 SVGA3dSurfaceFormat
114 svga_linear_to_srgb(SVGA3dSurfaceFormat format);
115 
116 
117 bool
118 svga_is_format_supported(struct pipe_screen *screen,
119                          enum pipe_format format,
120                          enum pipe_texture_target target,
121                          unsigned sample_count,
122                          unsigned storage_sample_count,
123                          unsigned bindings);
124 
125 
126 bool
127 svga_is_dx_format_supported(struct pipe_screen *screen,
128                             enum pipe_format format,
129                             enum pipe_texture_target target,
130                             unsigned sample_count,
131                             unsigned storage_sample_count,
132                             unsigned bindings);
133 
134 #endif /* SVGA_FORMAT_H_ */
135