1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/********************************************************** 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright 2008-2009 VMware, Inc. All rights reserved. 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * obtaining a copy of this software and associated documentation 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * files (the "Software"), to deal in the Software without 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * restriction, including without limitation the rights to use, copy, 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * modify, merge, publish, distribute, sublicense, and/or sell copies 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the Software, and to permit persons to whom the Software is 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * furnished to do so, subject to the following conditions: 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * included in all copies or substantial portions of the Software. 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * SOFTWARE. 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org **********************************************************/ 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef SVGA_SAMPLER_VIEW_H 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define SVGA_SAMPLER_VIEW_H 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_compiler.h" 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "pipe/p_state.h" 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "util/u_inlines.h" 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "svga_screen_cache.h" 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_context; 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct pipe_screen; 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct svga_context; 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct svga_winsys_surface; 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum SVGA3dSurfaceFormat; 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * A sampler's view into a texture 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * We currently cache one sampler view on 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the texture and in there by holding a reference 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * from the texture to the sampler view. 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Because of this we can not hold a refernce to the 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * texture from the sampler view. So the user 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * of the sampler views must make sure that the 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * texture has a reference take for as long as 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the sampler view is refrenced. 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Just unreferencing the sampler_view before the 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * texture is enough. 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct svga_sampler_view 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_reference reference; 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_resource *texture; 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int min_lod; 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org int max_lod; 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned age; 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct svga_host_surface_cache_key key; 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct svga_winsys_surface *handle; 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern struct svga_sampler_view * 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_get_tex_sampler_view(struct pipe_context *pipe, 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct pipe_resource *pt, 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org unsigned min_lod, unsigned max_lod); 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v); 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_destroy_sampler_view_priv(struct svga_sampler_view *v); 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgvoid 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv); 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic INLINE void 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgsvga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v) 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct svga_sampler_view *old = *ptr; 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (pipe_reference_described(&(*ptr)->reference, &v->reference, 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org (debug_reference_descriptor)svga_debug_describe_sampler_view)) 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org svga_destroy_sampler_view_priv(old); 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *ptr = v; 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 102