1 /* 2 * Copyright © 2014 Rob Clark <[email protected]> 3 * SPDX-License-Identifier: MIT 4 * 5 * Authors: 6 * Rob Clark <[email protected]> 7 */ 8 9 #ifndef FD4_TEXTURE_H_ 10 #define FD4_TEXTURE_H_ 11 12 #include "pipe/p_context.h" 13 14 #include "freedreno_resource.h" 15 #include "freedreno_texture.h" 16 17 #include "fd4_context.h" 18 #include "fd4_format.h" 19 20 struct fd4_sampler_stateobj { 21 struct pipe_sampler_state base; 22 uint32_t texsamp0, texsamp1; 23 bool needs_border; 24 }; 25 26 static inline struct fd4_sampler_stateobj * fd4_sampler_stateobj(struct pipe_sampler_state * samp)27fd4_sampler_stateobj(struct pipe_sampler_state *samp) 28 { 29 return (struct fd4_sampler_stateobj *)samp; 30 } 31 32 struct fd4_pipe_sampler_view { 33 struct pipe_sampler_view base; 34 uint32_t texconst0, texconst1, texconst2, texconst3, texconst4; 35 uint32_t offset; 36 bool astc_srgb; 37 uint32_t swizzle; 38 }; 39 40 static inline struct fd4_pipe_sampler_view * fd4_pipe_sampler_view(struct pipe_sampler_view * pview)41fd4_pipe_sampler_view(struct pipe_sampler_view *pview) 42 { 43 return (struct fd4_pipe_sampler_view *)pview; 44 } 45 46 unsigned fd4_get_const_idx(struct fd_context *ctx, 47 struct fd_texture_stateobj *tex, unsigned samp_id); 48 49 void fd4_texture_init(struct pipe_context *pctx); 50 51 static inline enum a4xx_tex_type fd4_tex_type(unsigned target)52fd4_tex_type(unsigned target) 53 { 54 switch (target) { 55 default: 56 unreachable("Unsupported target"); 57 case PIPE_BUFFER: 58 return A4XX_TEX_BUFFER; 59 case PIPE_TEXTURE_1D: 60 case PIPE_TEXTURE_1D_ARRAY: 61 return A4XX_TEX_1D; 62 case PIPE_TEXTURE_RECT: 63 case PIPE_TEXTURE_2D: 64 case PIPE_TEXTURE_2D_ARRAY: 65 return A4XX_TEX_2D; 66 case PIPE_TEXTURE_3D: 67 return A4XX_TEX_3D; 68 case PIPE_TEXTURE_CUBE: 69 case PIPE_TEXTURE_CUBE_ARRAY: 70 return A4XX_TEX_CUBE; 71 } 72 } 73 74 #endif /* FD4_TEXTURE_H_ */ 75