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; 386303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Leestruct svga_pipe_sampler_view; 39287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct svga_winsys_surface; 40e054251ed11e25a080f64b92db9334c9b07c8c76Brian Paulstruct svga_surface; 41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellenum SVGA3dSurfaceFormat; 42287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 43287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 44287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell/** 45287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * A sampler's view into a texture 46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * We currently cache one sampler view on 48287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * the texture and in there by holding a reference 49287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * from the texture to the sampler view. 50287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 51287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Because of this we can not hold a refernce to the 52287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture from the sampler view. So the user 53287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * of the sampler views must make sure that the 54287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture has a reference take for as long as 55287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * the sampler view is refrenced. 56287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * 57287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * Just unreferencing the sampler_view before the 58287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell * texture is enough. 59287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell */ 60287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstruct svga_sampler_view 61287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 62287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_reference reference; 63287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 64287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *texture; 65287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 66287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell int min_lod; 67287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell int max_lod; 68287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 69287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned age; 70287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 71287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_host_surface_cache_key key; 72287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_winsys_surface *handle; 73287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell}; 74287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 75287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 76287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 77287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellextern struct svga_sampler_view * 78287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_get_tex_sampler_view(struct pipe_context *pipe, 79287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct pipe_resource *pt, 80287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell unsigned min_lod, unsigned max_lod); 81287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 82287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 83287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v); 84287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 85287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 86287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_destroy_sampler_view_priv(struct svga_sampler_view *v); 87287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 88912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantzvoid 89912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantzsvga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv); 90912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz 91a2a1a5805fd617e7f3cc8be44dd79b50da07ebb9Ilia Mirkinstatic inline void 92287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellsvga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v) 93287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 94287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell struct svga_sampler_view *old = *ptr; 95287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 96912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz if (pipe_reference_described(&(*ptr)->reference, &v->reference, 97912ad8874200c0a89bd23663dc0de378f6691140Jakob Bornecrantz (debug_reference_descriptor)svga_debug_describe_sampler_view)) 98287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell svga_destroy_sampler_view_priv(old); 99287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell *ptr = v; 100287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 101287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 102e054251ed11e25a080f64b92db9334c9b07c8c76Brian Paulboolean 103e054251ed11e25a080f64b92db9334c9b07c8c76Brian Paulsvga_check_sampler_view_resource_collision(struct svga_context *svga, 104b2fd41ce465e16a178d51000b843b5228640b670Charmaine Lee struct svga_winsys_surface *res, 105f5602c27ec681f1f66cdb8d79378991b79ce45e7Brian Paul enum pipe_shader_type shader); 1066303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Lee 107ff500ed5a1287eadc06fc19661f0aad8767b664dBrian Paulboolean 108ff500ed5a1287eadc06fc19661f0aad8767b664dBrian Paulsvga_check_sampler_framebuffer_resource_collision(struct svga_context *svga, 109ff500ed5a1287eadc06fc19661f0aad8767b664dBrian Paul enum pipe_shader_type shader); 110ff500ed5a1287eadc06fc19661f0aad8767b664dBrian Paul 1116303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Leeenum pipe_error 1126303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Leesvga_validate_pipe_sampler_view(struct svga_context *svga, 1136303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Lee struct svga_pipe_sampler_view *sv); 1146303231a1ddf646b05c43c6bbc7fa71314ebb3fcCharmaine Lee 115287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#endif 116