1311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/********************************************************** 2311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * Copyright 2008-2009 VMware, Inc. All rights reserved. 3311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 4311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * Permission is hereby granted, free of charge, to any person 5311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * obtaining a copy of this software and associated documentation 6311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * files (the "Software"), to deal in the Software without 7311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * restriction, including without limitation the rights to use, copy, 8311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * modify, merge, publish, distribute, sublicense, and/or sell copies 9311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * of the Software, and to permit persons to whom the Software is 10311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * furnished to do so, subject to the following conditions: 11311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 12311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * The above copyright notice and this permission notice shall be 13311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * included in all copies or substantial portions of the Software. 14311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 15311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * SOFTWARE. 23311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 24311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff **********************************************************/ 25311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 26311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#ifndef SVGA_SAMPLER_VIEW_H 27311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#define SVGA_SAMPLER_VIEW_H 28311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 29311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 30311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "pipe/p_compiler.h" 31311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "pipe/p_state.h" 32311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "util/u_inlines.h" 33311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#include "svga_screen_cache.h" 34311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 35311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct pipe_context; 36311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct pipe_screen; 37311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct svga_context; 38311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct svga_winsys_surface; 39311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffenum SVGA3dSurfaceFormat; 40311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 41311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 42311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff/** 43311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * A sampler's view into a texture 44311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 45311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * We currently cache one sampler view on 46311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * the texture and in there by holding a reference 47311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * from the texture to the sampler view. 48311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 49311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * Because of this we can not hold a refernce to the 50311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * texture from the sampler view. So the user 51311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * of the sampler views must make sure that the 52311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * texture has a reference take for as long as 53311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * the sampler view is refrenced. 54311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * 55311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * Just unreferencing the sampler_view before the 56311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff * texture is enough. 57311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff */ 58311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstruct svga_sampler_view 59311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff{ 60311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct pipe_reference reference; 61311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 62311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct pipe_resource *texture; 63311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 64311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int min_lod; 65311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff int max_lod; 66311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 67311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned age; 68311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 69311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct svga_host_surface_cache_key key; 70311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct svga_winsys_surface *handle; 71311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff}; 72311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 73311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 74311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 75311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffextern struct svga_sampler_view * 76311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffsvga_get_tex_sampler_view(struct pipe_context *pipe, 77311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct pipe_resource *pt, 78311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff unsigned min_lod, unsigned max_lod); 79311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 80311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffvoid 81311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffsvga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v); 82311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 83d18457863096b3685e56f5a8919959f6afbdb121openvcdiffvoid 84311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffsvga_destroy_sampler_view_priv(struct svga_sampler_view *v); 85311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 86311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffvoid 87311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffsvga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv); 88311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 89311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffstatic INLINE void 90311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiffsvga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v) 91311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff{ 92311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff struct svga_sampler_view *old = *ptr; 93311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 94311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff if (pipe_reference_described(&(*ptr)->reference, &v->reference, 95311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff (debug_reference_descriptor)svga_debug_describe_sampler_view)) 96311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff svga_destroy_sampler_view_priv(old); 97311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff *ptr = v; 98311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff} 99311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 100311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff 101311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff#endif 102311c71486f5f6074e5ba62a7f4c5397c8700b868openvcdiff