xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/freedreno/a5xx/fd5_texture.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2016 Rob Clark <[email protected]>
3  * SPDX-License-Identifier: MIT
4  *
5  * Authors:
6  *    Rob Clark <[email protected]>
7  */
8 
9 #ifndef FD5_TEXTURE_H_
10 #define FD5_TEXTURE_H_
11 
12 #include "pipe/p_context.h"
13 
14 #include "freedreno_resource.h"
15 #include "freedreno_texture.h"
16 
17 #include "fd5_context.h"
18 #include "fd5_format.h"
19 
20 struct fd5_sampler_stateobj {
21    struct pipe_sampler_state base;
22    uint32_t texsamp0, texsamp1, texsamp2, texsamp3;
23    bool needs_border;
24 };
25 
26 static inline struct fd5_sampler_stateobj *
fd5_sampler_stateobj(struct pipe_sampler_state * samp)27 fd5_sampler_stateobj(struct pipe_sampler_state *samp)
28 {
29    return (struct fd5_sampler_stateobj *)samp;
30 }
31 
32 struct fd5_pipe_sampler_view {
33    struct pipe_sampler_view base;
34    uint32_t texconst0, texconst1, texconst2, texconst3, texconst5;
35    uint32_t texconst6, texconst7, texconst8, texconst9, texconst10, texconst11;
36    uint32_t offset;
37 };
38 
39 static inline struct fd5_pipe_sampler_view *
fd5_pipe_sampler_view(struct pipe_sampler_view * pview)40 fd5_pipe_sampler_view(struct pipe_sampler_view *pview)
41 {
42    return (struct fd5_pipe_sampler_view *)pview;
43 }
44 
45 void fd5_texture_init(struct pipe_context *pctx);
46 
47 static inline enum a5xx_tex_type
fd5_tex_type(unsigned target)48 fd5_tex_type(unsigned target)
49 {
50    switch (target) {
51    default:
52       unreachable("Unsupported target");;
53    case PIPE_BUFFER:
54       return A5XX_TEX_BUFFER;
55    case PIPE_TEXTURE_1D:
56    case PIPE_TEXTURE_1D_ARRAY:
57       return A5XX_TEX_1D;
58    case PIPE_TEXTURE_RECT:
59    case PIPE_TEXTURE_2D:
60    case PIPE_TEXTURE_2D_ARRAY:
61       return A5XX_TEX_2D;
62    case PIPE_TEXTURE_3D:
63       return A5XX_TEX_3D;
64    case PIPE_TEXTURE_CUBE:
65    case PIPE_TEXTURE_CUBE_ARRAY:
66       return A5XX_TEX_CUBE;
67    }
68 }
69 
70 #endif /* FD5_TEXTURE_H_ */
71