1287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell/********************************************************** 2287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Copyright 2008-2009 VMware, Inc. All rights reserved. 3287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 4287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Permission is hereby granted, free of charge, to any person 5287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * obtaining a copy of this software and associated documentation 6287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * files (the "Software"), to deal in the Software without 7287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * restriction, including without limitation the rights to use, copy, 8287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * modify, merge, publish, distribute, sublicense, and/or sell copies 9287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * of the Software, and to permit persons to whom the Software is 10287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * furnished to do so, subject to the following conditions: 11287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 12287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * The above copyright notice and this permission notice shall be 13287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * included in all copies or substantial portions of the Software. 14287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 15287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * SOFTWARE. 23287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 24287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell **********************************************************/ 25287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 26287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#ifndef SVGA_SAMPLER_VIEW_H 27287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#define SVGA_SAMPLER_VIEW_H 28287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 29287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 30287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "pipe/p_compiler.h" 31287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "pipe/p_state.h" 32287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_inlines.h" 33287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "svga_screen_cache.h" 34287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 35287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_context; 36287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct pipe_screen; 37287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct svga_context; 38287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct svga_winsys_surface; 39287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellenum SVGA3dSurfaceFormat; 40287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell/** 43287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * A sampler's view into a texture 44287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 45287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * We currently cache one sampler view on 46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * the texture and in there by holding a reference 47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * from the texture to the sampler view. 48287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 49287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Because of this we can not hold a refernce to the 50287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture from the sampler view. So the user 51287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * of the sampler views must make sure that the 52287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture has a reference take for as long as 53287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * the sampler view is refrenced. 54287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 55287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Just unreferencing the sampler_view before the 56287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture is enough. 57287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell */ 58287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct svga_sampler_view 59287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 60287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_reference reference; 61287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 62287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *texture; 63287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 64287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell int min_lod; 65287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell int max_lod; 66287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 67287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned age; 68287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 69287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_host_surface_cache_key key; 70287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_winsys_surface *handle; 71287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}; 72287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 73287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 74287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 75287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellextern struct svga_sampler_view * 76287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_get_tex_sampler_view(struct pipe_context *pipe, 77287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *pt, 78287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned min_lod, unsigned max_lod); 79287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 80287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 81287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v); 82287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 83287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 84287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_destroy_sampler_view_priv(struct svga_sampler_view *v); 85287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 86912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantzvoid 87912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantzsvga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv); 88912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz 89287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstatic INLINE void 90287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v) 91287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 92287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_sampler_view *old = *ptr; 93287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 94912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz if (pipe_reference_described(&(*ptr)->reference, &v->reference, 95912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz (debug_reference_descriptor)svga_debug_describe_sampler_view)) 96287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell svga_destroy_sampler_view_priv(old); 97287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell *ptr = v; 98287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 99287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 100287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 101287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#endif 102