Path: blob/21.2-virgl/src/gallium/drivers/svga/svga_sampler_view.h
4570 views
/**********************************************************1* Copyright 2008-2009 VMware, Inc. All rights reserved.2*3* Permission is hereby granted, free of charge, to any person4* obtaining a copy of this software and associated documentation5* files (the "Software"), to deal in the Software without6* restriction, including without limitation the rights to use, copy,7* modify, merge, publish, distribute, sublicense, and/or sell copies8* of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*23**********************************************************/2425#ifndef SVGA_SAMPLER_VIEW_H26#define SVGA_SAMPLER_VIEW_H272829#include "pipe/p_compiler.h"30#include "pipe/p_state.h"31#include "util/u_inlines.h"32#include "svga_screen_cache.h"3334struct pipe_context;35struct pipe_screen;36struct svga_context;37struct svga_pipe_sampler_view;38struct svga_winsys_surface;39struct svga_surface;40enum SVGA3dSurfaceFormat;414243/**44* A sampler's view into a texture45*46* We currently cache one sampler view on47* the texture and in there by holding a reference48* from the texture to the sampler view.49*50* Because of this we can not hold a refernce to the51* texture from the sampler view. So the user52* of the sampler views must make sure that the53* texture has a reference take for as long as54* the sampler view is refrenced.55*56* Just unreferencing the sampler_view before the57* texture is enough.58*/59struct svga_sampler_view60{61struct pipe_reference reference;6263struct pipe_resource *texture;6465int min_lod;66int max_lod;6768unsigned age;6970struct svga_host_surface_cache_key key;71struct svga_winsys_surface *handle;72};73747576extern struct svga_sampler_view *77svga_get_tex_sampler_view(struct pipe_context *pipe,78struct pipe_resource *pt,79unsigned min_lod, unsigned max_lod);8081void82svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);8384void85svga_destroy_sampler_view_priv(struct svga_sampler_view *v);8687void88svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv);8990static inline void91svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)92{93struct svga_sampler_view *old = *ptr;9495if (pipe_reference_described(&(*ptr)->reference, &v->reference,96(debug_reference_descriptor)svga_debug_describe_sampler_view))97svga_destroy_sampler_view_priv(old);98*ptr = v;99}100101boolean102svga_check_sampler_view_resource_collision(const struct svga_context *svga,103const struct svga_winsys_surface *res,104enum pipe_shader_type shader);105106boolean107svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga,108enum pipe_shader_type shader);109110enum pipe_error111svga_validate_pipe_sampler_view(struct svga_context *svga,112struct svga_pipe_sampler_view *sv);113114#endif115116117