1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 2012 Red Hat Inc.
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
12bf215546Sopenharmony_ci * all copies or substantial portions of the Software.
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
21bf215546Sopenharmony_ci *
22bf215546Sopenharmony_ci * Authors: Ben Skeggs
23bf215546Sopenharmony_ci *
24bf215546Sopenharmony_ci */
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "util/u_inlines.h"
27bf215546Sopenharmony_ci#include "util/format/u_format.h"
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_ci#include "nv_object.xml.h"
30bf215546Sopenharmony_ci#include "nv30/nv30-40_3d.xml.h"
31bf215546Sopenharmony_ci#include "nv30/nv30_context.h"
32bf215546Sopenharmony_ci#include "nv30/nv30_format.h"
33bf215546Sopenharmony_ci
34bf215546Sopenharmony_ci#define NV30_3D_TEX_WRAP_S_MIRROR_REPEAT NV30_3D_TEX_WRAP_S_MIRRORED_REPEAT
35bf215546Sopenharmony_ci#define NV30_WRAP(n) \
36bf215546Sopenharmony_ci   case PIPE_TEX_WRAP_##n: ret = NV30_3D_TEX_WRAP_S_##n; break
37bf215546Sopenharmony_ci#define NV40_WRAP(n) \
38bf215546Sopenharmony_ci   case PIPE_TEX_WRAP_##n: ret = NV40_3D_TEX_WRAP_S_##n; break
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_cistatic inline unsigned
41bf215546Sopenharmony_ciwrap_mode(unsigned pipe)
42bf215546Sopenharmony_ci{
43bf215546Sopenharmony_ci   unsigned ret = NV30_3D_TEX_WRAP_S_REPEAT;
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci   switch (pipe) {
46bf215546Sopenharmony_ci   NV30_WRAP(REPEAT);
47bf215546Sopenharmony_ci   NV30_WRAP(MIRROR_REPEAT);
48bf215546Sopenharmony_ci   NV30_WRAP(CLAMP_TO_EDGE);
49bf215546Sopenharmony_ci   NV30_WRAP(CLAMP_TO_BORDER);
50bf215546Sopenharmony_ci   NV30_WRAP(CLAMP);
51bf215546Sopenharmony_ci   NV40_WRAP(MIRROR_CLAMP_TO_EDGE);
52bf215546Sopenharmony_ci   NV40_WRAP(MIRROR_CLAMP_TO_BORDER);
53bf215546Sopenharmony_ci   NV40_WRAP(MIRROR_CLAMP);
54bf215546Sopenharmony_ci   default:
55bf215546Sopenharmony_ci      break;
56bf215546Sopenharmony_ci   }
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci   return ret >> NV30_3D_TEX_WRAP_S__SHIFT;
59bf215546Sopenharmony_ci}
60bf215546Sopenharmony_ci
61bf215546Sopenharmony_cistatic inline unsigned
62bf215546Sopenharmony_cifilter_mode(const struct pipe_sampler_state *cso)
63bf215546Sopenharmony_ci{
64bf215546Sopenharmony_ci   unsigned filter;
65bf215546Sopenharmony_ci
66bf215546Sopenharmony_ci   switch (cso->mag_img_filter) {
67bf215546Sopenharmony_ci   case PIPE_TEX_FILTER_LINEAR:
68bf215546Sopenharmony_ci      filter = NV30_3D_TEX_FILTER_MAG_LINEAR;
69bf215546Sopenharmony_ci      break;
70bf215546Sopenharmony_ci   default:
71bf215546Sopenharmony_ci      filter = NV30_3D_TEX_FILTER_MAG_NEAREST;
72bf215546Sopenharmony_ci      break;
73bf215546Sopenharmony_ci   }
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   switch (cso->min_img_filter) {
76bf215546Sopenharmony_ci   case PIPE_TEX_FILTER_LINEAR:
77bf215546Sopenharmony_ci      switch (cso->min_mip_filter) {
78bf215546Sopenharmony_ci      case PIPE_TEX_MIPFILTER_NEAREST:
79bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_LINEAR_MIPMAP_NEAREST;
80bf215546Sopenharmony_ci         break;
81bf215546Sopenharmony_ci      case PIPE_TEX_MIPFILTER_LINEAR:
82bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_LINEAR_MIPMAP_LINEAR;
83bf215546Sopenharmony_ci         break;
84bf215546Sopenharmony_ci      default:
85bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_LINEAR;
86bf215546Sopenharmony_ci         break;
87bf215546Sopenharmony_ci      }
88bf215546Sopenharmony_ci      break;
89bf215546Sopenharmony_ci   default:
90bf215546Sopenharmony_ci      switch (cso->min_mip_filter) {
91bf215546Sopenharmony_ci      case PIPE_TEX_MIPFILTER_NEAREST:
92bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_NEAREST_MIPMAP_NEAREST;
93bf215546Sopenharmony_ci         break;
94bf215546Sopenharmony_ci      case PIPE_TEX_MIPFILTER_LINEAR:
95bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_NEAREST_MIPMAP_LINEAR;
96bf215546Sopenharmony_ci         break;
97bf215546Sopenharmony_ci      default:
98bf215546Sopenharmony_ci         filter |= NV30_3D_TEX_FILTER_MIN_NEAREST;
99bf215546Sopenharmony_ci         break;
100bf215546Sopenharmony_ci      }
101bf215546Sopenharmony_ci      break;
102bf215546Sopenharmony_ci   }
103bf215546Sopenharmony_ci
104bf215546Sopenharmony_ci   return filter;
105bf215546Sopenharmony_ci}
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_cistatic inline unsigned
108bf215546Sopenharmony_cicompare_mode(const struct pipe_sampler_state *cso)
109bf215546Sopenharmony_ci{
110bf215546Sopenharmony_ci   if (cso->compare_mode != PIPE_TEX_COMPARE_R_TO_TEXTURE)
111bf215546Sopenharmony_ci      return 0;
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ci   switch (cso->compare_func) {
114bf215546Sopenharmony_ci   case PIPE_FUNC_NEVER   : return NV30_3D_TEX_WRAP_RCOMP_NEVER;
115bf215546Sopenharmony_ci   case PIPE_FUNC_GREATER : return NV30_3D_TEX_WRAP_RCOMP_GREATER;
116bf215546Sopenharmony_ci   case PIPE_FUNC_EQUAL   : return NV30_3D_TEX_WRAP_RCOMP_EQUAL;
117bf215546Sopenharmony_ci   case PIPE_FUNC_GEQUAL  : return NV30_3D_TEX_WRAP_RCOMP_GEQUAL;
118bf215546Sopenharmony_ci   case PIPE_FUNC_LESS    : return NV30_3D_TEX_WRAP_RCOMP_LESS;
119bf215546Sopenharmony_ci   case PIPE_FUNC_NOTEQUAL: return NV30_3D_TEX_WRAP_RCOMP_NOTEQUAL;
120bf215546Sopenharmony_ci   case PIPE_FUNC_LEQUAL  : return NV30_3D_TEX_WRAP_RCOMP_LEQUAL;
121bf215546Sopenharmony_ci   case PIPE_FUNC_ALWAYS  : return NV30_3D_TEX_WRAP_RCOMP_ALWAYS;
122bf215546Sopenharmony_ci   default:
123bf215546Sopenharmony_ci      return 0;
124bf215546Sopenharmony_ci   }
125bf215546Sopenharmony_ci}
126bf215546Sopenharmony_ci
127bf215546Sopenharmony_cistatic void *
128bf215546Sopenharmony_cinv30_sampler_state_create(struct pipe_context *pipe,
129bf215546Sopenharmony_ci                          const struct pipe_sampler_state *cso)
130bf215546Sopenharmony_ci{
131bf215546Sopenharmony_ci   struct nouveau_object *eng3d = nv30_context(pipe)->screen->eng3d;
132bf215546Sopenharmony_ci   struct nv30_sampler_state *so;
133bf215546Sopenharmony_ci   const float max_lod = 15.0 + (255.0 / 256.0);
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ci   so = MALLOC_STRUCT(nv30_sampler_state);
136bf215546Sopenharmony_ci   if (!so)
137bf215546Sopenharmony_ci      return NULL;
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci   so->pipe  = *cso;
140bf215546Sopenharmony_ci   so->fmt   = 0;
141bf215546Sopenharmony_ci   so->wrap  = (wrap_mode(cso->wrap_s) << NV30_3D_TEX_WRAP_S__SHIFT) |
142bf215546Sopenharmony_ci               (wrap_mode(cso->wrap_t) << NV30_3D_TEX_WRAP_T__SHIFT) |
143bf215546Sopenharmony_ci               (wrap_mode(cso->wrap_r) << NV30_3D_TEX_WRAP_R__SHIFT);
144bf215546Sopenharmony_ci   so->en    = 0;
145bf215546Sopenharmony_ci   so->wrap |= compare_mode(cso);
146bf215546Sopenharmony_ci   so->filt  = filter_mode(cso) | 0x00002000;
147bf215546Sopenharmony_ci   so->bcol  = (float_to_ubyte(cso->border_color.f[3]) << 24) |
148bf215546Sopenharmony_ci               (float_to_ubyte(cso->border_color.f[0]) << 16) |
149bf215546Sopenharmony_ci               (float_to_ubyte(cso->border_color.f[1]) <<  8) |
150bf215546Sopenharmony_ci               (float_to_ubyte(cso->border_color.f[2]) <<  0);
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ci   if (eng3d->oclass >= NV40_3D_CLASS) {
153bf215546Sopenharmony_ci      unsigned aniso = cso->max_anisotropy;
154bf215546Sopenharmony_ci
155bf215546Sopenharmony_ci      if (!cso->normalized_coords)
156bf215546Sopenharmony_ci         so->fmt |= NV40_3D_TEX_FORMAT_RECT;
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_ci      if (aniso > 1) {
159bf215546Sopenharmony_ci         if      (aniso >= 16) so->en |= NV40_3D_TEX_ENABLE_ANISO_16X;
160bf215546Sopenharmony_ci         else if (aniso >= 12) so->en |= NV40_3D_TEX_ENABLE_ANISO_12X;
161bf215546Sopenharmony_ci         else if (aniso >= 10) so->en |= NV40_3D_TEX_ENABLE_ANISO_10X;
162bf215546Sopenharmony_ci         else if (aniso >=  8) so->en |= NV40_3D_TEX_ENABLE_ANISO_8X;
163bf215546Sopenharmony_ci         else if (aniso >=  6) so->en |= NV40_3D_TEX_ENABLE_ANISO_6X;
164bf215546Sopenharmony_ci         else if (aniso >=  4) so->en |= NV40_3D_TEX_ENABLE_ANISO_4X;
165bf215546Sopenharmony_ci         else                  so->en |= NV40_3D_TEX_ENABLE_ANISO_2X;
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ci         so->wrap |= nv30_context(pipe)->config.aniso;
168bf215546Sopenharmony_ci      }
169bf215546Sopenharmony_ci   } else {
170bf215546Sopenharmony_ci      so->en |= NV30_3D_TEX_ENABLE_ENABLE;
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci      if      (cso->max_anisotropy >= 8) so->en |= NV30_3D_TEX_ENABLE_ANISO_8X;
173bf215546Sopenharmony_ci      else if (cso->max_anisotropy >= 4) so->en |= NV30_3D_TEX_ENABLE_ANISO_4X;
174bf215546Sopenharmony_ci      else if (cso->max_anisotropy >= 2) so->en |= NV30_3D_TEX_ENABLE_ANISO_2X;
175bf215546Sopenharmony_ci   }
176bf215546Sopenharmony_ci
177bf215546Sopenharmony_ci   so->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
178bf215546Sopenharmony_ci   so->max_lod = (int)(CLAMP(cso->max_lod, 0.0, max_lod) * 256.0);
179bf215546Sopenharmony_ci   so->min_lod = (int)(CLAMP(cso->min_lod, 0.0, max_lod) * 256.0);
180bf215546Sopenharmony_ci   return so;
181bf215546Sopenharmony_ci}
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_cistatic void
184bf215546Sopenharmony_cinv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
185bf215546Sopenharmony_ci{
186bf215546Sopenharmony_ci   FREE(hwcso);
187bf215546Sopenharmony_ci}
188bf215546Sopenharmony_ci
189bf215546Sopenharmony_cistatic void
190bf215546Sopenharmony_cinv30_bind_sampler_states(struct pipe_context *pipe,
191bf215546Sopenharmony_ci                         enum pipe_shader_type shader, unsigned start_slot,
192bf215546Sopenharmony_ci                         unsigned num_samplers, void **samplers)
193bf215546Sopenharmony_ci{
194bf215546Sopenharmony_ci   switch (shader) {
195bf215546Sopenharmony_ci   case PIPE_SHADER_VERTEX:
196bf215546Sopenharmony_ci      nv40_verttex_sampler_states_bind(pipe, num_samplers, samplers);
197bf215546Sopenharmony_ci      break;
198bf215546Sopenharmony_ci   case PIPE_SHADER_FRAGMENT:
199bf215546Sopenharmony_ci      nv30_fragtex_sampler_states_bind(pipe, num_samplers, samplers);
200bf215546Sopenharmony_ci      break;
201bf215546Sopenharmony_ci   default:
202bf215546Sopenharmony_ci      assert(!"unexpected shader type");
203bf215546Sopenharmony_ci      break;
204bf215546Sopenharmony_ci   }
205bf215546Sopenharmony_ci}
206bf215546Sopenharmony_ci
207bf215546Sopenharmony_cistatic inline uint32_t
208bf215546Sopenharmony_ciswizzle(const struct nv30_texfmt *fmt, unsigned cmp, unsigned swz)
209bf215546Sopenharmony_ci{
210bf215546Sopenharmony_ci   uint32_t data = fmt->swz[swz].src << 8;
211bf215546Sopenharmony_ci   if (swz <= PIPE_SWIZZLE_W)
212bf215546Sopenharmony_ci      data |= fmt->swz[swz].cmp;
213bf215546Sopenharmony_ci   else
214bf215546Sopenharmony_ci      data |= fmt->swz[cmp].cmp;
215bf215546Sopenharmony_ci   return data;
216bf215546Sopenharmony_ci}
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_cistatic struct pipe_sampler_view *
219bf215546Sopenharmony_cinv30_sampler_view_create(struct pipe_context *pipe, struct pipe_resource *pt,
220bf215546Sopenharmony_ci                         const struct pipe_sampler_view *tmpl)
221bf215546Sopenharmony_ci{
222bf215546Sopenharmony_ci   const struct nv30_texfmt *fmt = nv30_texfmt(pipe->screen, tmpl->format);
223bf215546Sopenharmony_ci   struct nouveau_object *eng3d = nv30_context(pipe)->screen->eng3d;
224bf215546Sopenharmony_ci   struct nv30_miptree *mt = nv30_miptree(pt);
225bf215546Sopenharmony_ci   struct nv30_sampler_view *so;
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_ci   so = MALLOC_STRUCT(nv30_sampler_view);
228bf215546Sopenharmony_ci   if (!so)
229bf215546Sopenharmony_ci      return NULL;
230bf215546Sopenharmony_ci   so->pipe = *tmpl;
231bf215546Sopenharmony_ci   so->pipe.reference.count = 1;
232bf215546Sopenharmony_ci   so->pipe.texture = NULL;
233bf215546Sopenharmony_ci   so->pipe.context = pipe;
234bf215546Sopenharmony_ci   pipe_resource_reference(&so->pipe.texture, pt);
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_ci   so->fmt = NV30_3D_TEX_FORMAT_NO_BORDER;
237bf215546Sopenharmony_ci   switch (pt->target) {
238bf215546Sopenharmony_ci   case PIPE_TEXTURE_1D:
239bf215546Sopenharmony_ci      so->fmt |= NV30_3D_TEX_FORMAT_DIMS_1D;
240bf215546Sopenharmony_ci      break;
241bf215546Sopenharmony_ci   case PIPE_TEXTURE_CUBE:
242bf215546Sopenharmony_ci      so->fmt |= NV30_3D_TEX_FORMAT_CUBIC;
243bf215546Sopenharmony_ci      FALLTHROUGH;
244bf215546Sopenharmony_ci   case PIPE_TEXTURE_2D:
245bf215546Sopenharmony_ci   case PIPE_TEXTURE_RECT:
246bf215546Sopenharmony_ci      so->fmt |= NV30_3D_TEX_FORMAT_DIMS_2D;
247bf215546Sopenharmony_ci      break;
248bf215546Sopenharmony_ci   case PIPE_TEXTURE_3D:
249bf215546Sopenharmony_ci      so->fmt |= NV30_3D_TEX_FORMAT_DIMS_3D;
250bf215546Sopenharmony_ci      break;
251bf215546Sopenharmony_ci   default:
252bf215546Sopenharmony_ci      assert(0);
253bf215546Sopenharmony_ci      so->fmt |= NV30_3D_TEX_FORMAT_DIMS_1D;
254bf215546Sopenharmony_ci      break;
255bf215546Sopenharmony_ci   }
256bf215546Sopenharmony_ci
257bf215546Sopenharmony_ci   so->filt = fmt->filter;
258bf215546Sopenharmony_ci   so->wrap = fmt->wrap;
259bf215546Sopenharmony_ci   so->swz  = fmt->swizzle;
260bf215546Sopenharmony_ci   so->swz |= swizzle(fmt, 3, tmpl->swizzle_a);
261bf215546Sopenharmony_ci   so->swz |= swizzle(fmt, 0, tmpl->swizzle_r) << 2;
262bf215546Sopenharmony_ci   so->swz |= swizzle(fmt, 1, tmpl->swizzle_g) << 4;
263bf215546Sopenharmony_ci   so->swz |= swizzle(fmt, 2, tmpl->swizzle_b) << 6;
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci   /* apparently, we need to ignore the t coordinate for 1D textures to
266bf215546Sopenharmony_ci    * fix piglit tex1d-2dborder
267bf215546Sopenharmony_ci    */
268bf215546Sopenharmony_ci   so->wrap_mask = ~0;
269bf215546Sopenharmony_ci   if (pt->target == PIPE_TEXTURE_1D) {
270bf215546Sopenharmony_ci      so->wrap_mask &= ~NV30_3D_TEX_WRAP_T__MASK;
271bf215546Sopenharmony_ci      so->wrap      |=  NV30_3D_TEX_WRAP_T_REPEAT;
272bf215546Sopenharmony_ci   }
273bf215546Sopenharmony_ci
274bf215546Sopenharmony_ci   /* yet more hardware suckage, can't filter 32-bit float formats */
275bf215546Sopenharmony_ci   switch (tmpl->format) {
276bf215546Sopenharmony_ci   case PIPE_FORMAT_R32_FLOAT:
277bf215546Sopenharmony_ci   case PIPE_FORMAT_R32G32B32A32_FLOAT:
278bf215546Sopenharmony_ci      so->filt_mask = ~(NV30_3D_TEX_FILTER_MIN__MASK |
279bf215546Sopenharmony_ci                        NV30_3D_TEX_FILTER_MAG__MASK);
280bf215546Sopenharmony_ci      so->filt     |= NV30_3D_TEX_FILTER_MIN_NEAREST |
281bf215546Sopenharmony_ci                      NV30_3D_TEX_FILTER_MAG_NEAREST;
282bf215546Sopenharmony_ci      break;
283bf215546Sopenharmony_ci   default:
284bf215546Sopenharmony_ci      so->filt_mask = ~0;
285bf215546Sopenharmony_ci      break;
286bf215546Sopenharmony_ci   }
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci   so->npot_size0 = (pt->width0 << 16) | pt->height0;
289bf215546Sopenharmony_ci   if (eng3d->oclass >= NV40_3D_CLASS) {
290bf215546Sopenharmony_ci      so->npot_size1 = (pt->depth0 << 20) | mt->uniform_pitch;
291bf215546Sopenharmony_ci      if (mt->uniform_pitch)
292bf215546Sopenharmony_ci         so->fmt |= NV40_3D_TEX_FORMAT_LINEAR;
293bf215546Sopenharmony_ci      so->fmt |= 0x00008000;
294bf215546Sopenharmony_ci      so->fmt |= (pt->last_level + 1) << NV40_3D_TEX_FORMAT_MIPMAP_COUNT__SHIFT;
295bf215546Sopenharmony_ci   } else {
296bf215546Sopenharmony_ci      so->swz |= mt->uniform_pitch << NV30_3D_TEX_SWIZZLE_RECT_PITCH__SHIFT;
297bf215546Sopenharmony_ci      if (pt->last_level)
298bf215546Sopenharmony_ci         so->fmt |= NV30_3D_TEX_FORMAT_MIPMAP;
299bf215546Sopenharmony_ci      so->fmt |= util_logbase2(pt->width0)  << 20;
300bf215546Sopenharmony_ci      so->fmt |= util_logbase2(pt->height0) << 24;
301bf215546Sopenharmony_ci      so->fmt |= util_logbase2(pt->depth0)  << 28;
302bf215546Sopenharmony_ci      so->fmt |= 0x00010000;
303bf215546Sopenharmony_ci   }
304bf215546Sopenharmony_ci
305bf215546Sopenharmony_ci   so->base_lod = so->pipe.u.tex.first_level << 8;
306bf215546Sopenharmony_ci   so->high_lod = MIN2(pt->last_level, so->pipe.u.tex.last_level) << 8;
307bf215546Sopenharmony_ci   return &so->pipe;
308bf215546Sopenharmony_ci}
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_cistatic void
311bf215546Sopenharmony_cinv30_sampler_view_destroy(struct pipe_context *pipe,
312bf215546Sopenharmony_ci                          struct pipe_sampler_view *view)
313bf215546Sopenharmony_ci{
314bf215546Sopenharmony_ci   pipe_resource_reference(&view->texture, NULL);
315bf215546Sopenharmony_ci   FREE(view);
316bf215546Sopenharmony_ci}
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_civoid
319bf215546Sopenharmony_cinv30_texture_init(struct pipe_context *pipe)
320bf215546Sopenharmony_ci{
321bf215546Sopenharmony_ci   pipe->create_sampler_state = nv30_sampler_state_create;
322bf215546Sopenharmony_ci   pipe->delete_sampler_state = nv30_sampler_state_delete;
323bf215546Sopenharmony_ci   pipe->bind_sampler_states = nv30_bind_sampler_states;
324bf215546Sopenharmony_ci
325bf215546Sopenharmony_ci   pipe->create_sampler_view = nv30_sampler_view_create;
326bf215546Sopenharmony_ci   pipe->sampler_view_destroy = nv30_sampler_view_destroy;
327bf215546Sopenharmony_ci}
328