12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**********************************************************
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Copyright 2008-2009 VMware, Inc.  All rights reserved.
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Permission is hereby granted, free of charge, to any person
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * obtaining a copy of this software and associated documentation
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * files (the "Software"), to deal in the Software without
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * restriction, including without limitation the rights to use, copy,
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * modify, merge, publish, distribute, sublicense, and/or sell copies
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * of the Software, and to permit persons to whom the Software is
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * furnished to do so, subject to the following conditions:
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * The above copyright notice and this permission notice shall be
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * included in all copies or substantial portions of the Software.
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * SOFTWARE.
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) **********************************************************/
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef SVGA_SAMPLER_VIEW_H
27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#define SVGA_SAMPLER_VIEW_H
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "pipe/p_compiler.h"
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "pipe/p_state.h"
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "util/u_inlines.h"
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "svga_screen_cache.h"
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct pipe_context;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct pipe_screen;
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct svga_context;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct svga_winsys_surface;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)enum SVGA3dSurfaceFormat;
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * A sampler's view into a texture
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * We currently cache one sampler view on
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * the texture and in there by holding a reference
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * from the texture to the sampler view.
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Because of this we can not hold a refernce to the
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * texture from the sampler view. So the user
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * of the sampler views must make sure that the
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * texture has a reference take for as long as
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * the sampler view is refrenced.
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Just unreferencing the sampler_view before the
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * texture is enough.
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct svga_sampler_view
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles){
60f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)   struct pipe_reference reference;
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   struct pipe_resource *texture;
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   int min_lod;
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   int max_lod;
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   unsigned age;
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   struct svga_host_surface_cache_key key;
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   struct svga_winsys_surface *handle;
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern struct svga_sampler_view *
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)svga_get_tex_sampler_view(struct pipe_context *pipe,
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          struct pipe_resource *pt,
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                          unsigned min_lod, unsigned max_lod);
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void
812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);
822a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
832a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void
842a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)void
872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv);
882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static INLINE void
902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
91{
92   struct svga_sampler_view *old = *ptr;
93
94   if (pipe_reference_described(&(*ptr)->reference, &v->reference,
95                                (debug_reference_descriptor)svga_debug_describe_sampler_view))
96      svga_destroy_sampler_view_priv(old);
97   *ptr = v;
98}
99
100
101#endif
102