4 #include "util/u_math.h"
5 #include "pipe/p_defines.h"
6 #include "pipe/p_state.h"
10 nvfx_tex_wrap_mode(unsigned wrap
) {
14 case PIPE_TEX_WRAP_REPEAT
:
15 ret
= NV30_3D_TEX_WRAP_S_REPEAT
;
17 case PIPE_TEX_WRAP_MIRROR_REPEAT
:
18 ret
= NV30_3D_TEX_WRAP_S_MIRRORED_REPEAT
;
20 case PIPE_TEX_WRAP_CLAMP_TO_EDGE
:
21 ret
= NV30_3D_TEX_WRAP_S_CLAMP_TO_EDGE
;
23 case PIPE_TEX_WRAP_CLAMP_TO_BORDER
:
24 ret
= NV30_3D_TEX_WRAP_S_CLAMP_TO_BORDER
;
26 case PIPE_TEX_WRAP_CLAMP
:
27 ret
= NV30_3D_TEX_WRAP_S_CLAMP
;
29 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE
:
30 ret
= NV40_3D_TEX_WRAP_S_MIRROR_CLAMP_TO_EDGE
;
32 case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER
:
33 ret
= NV40_3D_TEX_WRAP_S_MIRROR_CLAMP_TO_BORDER
;
35 case PIPE_TEX_WRAP_MIRROR_CLAMP
:
36 ret
= NV40_3D_TEX_WRAP_S_MIRROR_CLAMP
;
40 ret
= NV30_3D_TEX_WRAP_S_REPEAT
;
44 return ret
>> NV30_3D_TEX_WRAP_S__SHIFT
;
47 static inline unsigned
48 nvfx_tex_wrap_compare_mode(unsigned func
)
52 return NV30_3D_TEX_WRAP_RCOMP_NEVER
;
53 case PIPE_FUNC_GREATER
:
54 return NV30_3D_TEX_WRAP_RCOMP_GREATER
;
56 return NV30_3D_TEX_WRAP_RCOMP_EQUAL
;
57 case PIPE_FUNC_GEQUAL
:
58 return NV30_3D_TEX_WRAP_RCOMP_GEQUAL
;
60 return NV30_3D_TEX_WRAP_RCOMP_LESS
;
61 case PIPE_FUNC_NOTEQUAL
:
62 return NV30_3D_TEX_WRAP_RCOMP_NOTEQUAL
;
63 case PIPE_FUNC_LEQUAL
:
64 return NV30_3D_TEX_WRAP_RCOMP_LEQUAL
;
65 case PIPE_FUNC_ALWAYS
:
66 return NV30_3D_TEX_WRAP_RCOMP_ALWAYS
;
73 static inline unsigned nvfx_tex_filter(const struct pipe_sampler_state
* cso
)
76 switch (cso
->mag_img_filter
) {
77 case PIPE_TEX_FILTER_LINEAR
:
78 filter
|= NV30_3D_TEX_FILTER_MAG_LINEAR
;
80 case PIPE_TEX_FILTER_NEAREST
:
82 filter
|= NV30_3D_TEX_FILTER_MAG_NEAREST
;
86 switch (cso
->min_img_filter
) {
87 case PIPE_TEX_FILTER_LINEAR
:
88 switch (cso
->min_mip_filter
) {
89 case PIPE_TEX_MIPFILTER_NEAREST
:
90 filter
|= NV30_3D_TEX_FILTER_MIN_LINEAR_MIPMAP_NEAREST
;
92 case PIPE_TEX_MIPFILTER_LINEAR
:
93 filter
|= NV30_3D_TEX_FILTER_MIN_LINEAR_MIPMAP_LINEAR
;
95 case PIPE_TEX_MIPFILTER_NONE
:
97 filter
|= NV30_3D_TEX_FILTER_MIN_LINEAR
;
101 case PIPE_TEX_FILTER_NEAREST
:
103 switch (cso
->min_mip_filter
) {
104 case PIPE_TEX_MIPFILTER_NEAREST
:
105 filter
|= NV30_3D_TEX_FILTER_MIN_NEAREST_MIPMAP_NEAREST
;
107 case PIPE_TEX_MIPFILTER_LINEAR
:
108 filter
|= NV30_3D_TEX_FILTER_MIN_NEAREST_MIPMAP_LINEAR
;
110 case PIPE_TEX_MIPFILTER_NONE
:
112 filter
|= NV30_3D_TEX_FILTER_MIN_NEAREST
;
120 static inline unsigned nvfx_tex_border_color(const float* border_color
)
122 return ((float_to_ubyte(border_color
[3]) << 24) |
123 (float_to_ubyte(border_color
[0]) << 16) |
124 (float_to_ubyte(border_color
[1]) << 8) |
125 (float_to_ubyte(border_color
[2]) << 0));
128 struct nvfx_sampler_state
{
139 struct nvfx_sampler_view
{
140 struct pipe_sampler_view base
;
148 uint32_t max_lod_limit
;
153 uint32_t fmt
[4]; /* nv30 has 4 entries, nv40 one */
158 uint32_t fmt
[2]; /* nv30 has 4 entries, nv40 one */
159 uint32_t npot_size2
; /* nv40 only */
165 struct nvfx_texture_format
{
169 unsigned char src
[6];
170 unsigned char comp
[6];
173 extern struct nvfx_texture_format nvfx_texture_formats
[PIPE_FORMAT_COUNT
];
175 #endif /* NVFX_TEX_H_ */