freedreno: Add a6xx backend
[mesa.git] / src / gallium / drivers / freedreno / a6xx / fd6_texture.h
1 /*
2 * Copyright (C) 2016 Rob Clark <robclark@freedesktop.org>
3 * Copyright © 2018 Google, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * 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 * Authors:
25 * Rob Clark <robclark@freedesktop.org>
26 */
27
28 #ifndef FD6_TEXTURE_H_
29 #define FD6_TEXTURE_H_
30
31 #include "pipe/p_context.h"
32
33 #include "freedreno_texture.h"
34 #include "freedreno_resource.h"
35
36 #include "fd6_context.h"
37 #include "fd6_format.h"
38
39 struct fd6_sampler_stateobj {
40 struct pipe_sampler_state base;
41 uint32_t texsamp0, texsamp1, texsamp2, texsamp3;
42 bool saturate_s, saturate_t, saturate_r;
43 bool needs_border;
44 };
45
46 static inline struct fd6_sampler_stateobj *
47 fd6_sampler_stateobj(struct pipe_sampler_state *samp)
48 {
49 return (struct fd6_sampler_stateobj *)samp;
50 }
51
52 struct fd6_pipe_sampler_view {
53 struct pipe_sampler_view base;
54 uint32_t texconst0, texconst1, texconst2, texconst3, texconst5;
55 uint32_t texconst6, texconst7, texconst8, texconst9, texconst10, texconst11;
56 uint32_t offset;
57 bool astc_srgb;
58 };
59
60 static inline struct fd6_pipe_sampler_view *
61 fd6_pipe_sampler_view(struct pipe_sampler_view *pview)
62 {
63 return (struct fd6_pipe_sampler_view *)pview;
64 }
65
66 void fd6_texture_init(struct pipe_context *pctx);
67
68
69 static inline enum a6xx_tex_type
70 fd6_tex_type(unsigned target)
71 {
72 switch (target) {
73 default:
74 assert(0);
75 case PIPE_BUFFER:
76 case PIPE_TEXTURE_1D:
77 case PIPE_TEXTURE_1D_ARRAY:
78 return A6XX_TEX_1D;
79 case PIPE_TEXTURE_RECT:
80 case PIPE_TEXTURE_2D:
81 case PIPE_TEXTURE_2D_ARRAY:
82 return A6XX_TEX_2D;
83 case PIPE_TEXTURE_3D:
84 return A6XX_TEX_3D;
85 case PIPE_TEXTURE_CUBE:
86 case PIPE_TEXTURE_CUBE_ARRAY:
87 return A6XX_TEX_CUBE;
88 }
89 }
90
91 #endif /* FD6_TEXTURE_H_ */