Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 1 | /********************************************************** |
| 2 | * Copyright 2008-2009 VMware, Inc. All rights reserved. |
| 3 | * |
| 4 | * Permission is hereby granted, free of charge, to any person |
| 5 | * obtaining a copy of this software and associated documentation |
| 6 | * files (the "Software"), to deal in the Software without |
| 7 | * restriction, including without limitation the rights to use, copy, |
| 8 | * modify, merge, publish, distribute, sublicense, and/or sell copies |
| 9 | * of the Software, and to permit persons to whom the Software is |
| 10 | * furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice shall be |
| 13 | * included in all copies or substantial portions of the Software. |
| 14 | * |
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 18 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 19 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 20 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 21 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | * |
| 24 | **********************************************************/ |
| 25 | |
| 26 | #ifndef SVGA_SAMPLER_VIEW_H |
| 27 | #define SVGA_SAMPLER_VIEW_H |
| 28 | |
| 29 | |
| 30 | #include "pipe/p_compiler.h" |
| 31 | #include "pipe/p_state.h" |
| 32 | #include "util/u_inlines.h" |
| 33 | #include "svga_screen_cache.h" |
| 34 | |
| 35 | struct pipe_context; |
| 36 | struct pipe_screen; |
| 37 | struct svga_context; |
Charmaine Lee | 6303231 | 2015-12-22 11:20:41 -0800 | [diff] [blame] | 38 | struct svga_pipe_sampler_view; |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 39 | struct svga_winsys_surface; |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 40 | struct svga_surface; |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 41 | enum SVGA3dSurfaceFormat; |
| 42 | |
| 43 | |
| 44 | /** |
| 45 | * A sampler's view into a texture |
| 46 | * |
| 47 | * We currently cache one sampler view on |
| 48 | * the texture and in there by holding a reference |
| 49 | * from the texture to the sampler view. |
| 50 | * |
| 51 | * Because of this we can not hold a refernce to the |
| 52 | * texture from the sampler view. So the user |
| 53 | * of the sampler views must make sure that the |
| 54 | * texture has a reference take for as long as |
| 55 | * the sampler view is refrenced. |
| 56 | * |
| 57 | * Just unreferencing the sampler_view before the |
| 58 | * texture is enough. |
| 59 | */ |
| 60 | struct svga_sampler_view |
| 61 | { |
| 62 | struct pipe_reference reference; |
| 63 | |
| 64 | struct pipe_resource *texture; |
| 65 | |
| 66 | int min_lod; |
| 67 | int max_lod; |
| 68 | |
| 69 | unsigned age; |
| 70 | |
| 71 | struct svga_host_surface_cache_key key; |
| 72 | struct svga_winsys_surface *handle; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | |
| 77 | extern struct svga_sampler_view * |
| 78 | svga_get_tex_sampler_view(struct pipe_context *pipe, |
| 79 | struct pipe_resource *pt, |
| 80 | unsigned min_lod, unsigned max_lod); |
| 81 | |
| 82 | void |
| 83 | svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v); |
| 84 | |
| 85 | void |
| 86 | svga_destroy_sampler_view_priv(struct svga_sampler_view *v); |
| 87 | |
Jakob Bornecrantz | 912ad88 | 2011-02-17 14:58:55 +0000 | [diff] [blame] | 88 | void |
| 89 | svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv); |
| 90 | |
Ilia Mirkin | a2a1a58 | 2015-07-20 19:58:43 -0400 | [diff] [blame] | 91 | static inline void |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 92 | svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v) |
| 93 | { |
| 94 | struct svga_sampler_view *old = *ptr; |
| 95 | |
Jakob Bornecrantz | 912ad88 | 2011-02-17 14:58:55 +0000 | [diff] [blame] | 96 | if (pipe_reference_described(&(*ptr)->reference, &v->reference, |
| 97 | (debug_reference_descriptor)svga_debug_describe_sampler_view)) |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 98 | svga_destroy_sampler_view_priv(old); |
| 99 | *ptr = v; |
| 100 | } |
| 101 | |
Brian Paul | e054251 | 2015-08-13 11:00:58 -0700 | [diff] [blame] | 102 | boolean |
Brian Paul | 1ee181b | 2017-04-10 15:02:05 -0600 | [diff] [blame] | 103 | svga_check_sampler_view_resource_collision(const struct svga_context *svga, |
| 104 | const struct svga_winsys_surface *res, |
Brian Paul | f5602c2 | 2016-08-29 10:15:36 -0600 | [diff] [blame] | 105 | enum pipe_shader_type shader); |
Charmaine Lee | 6303231 | 2015-12-22 11:20:41 -0800 | [diff] [blame] | 106 | |
Brian Paul | ff500ed | 2016-08-25 18:01:57 -0600 | [diff] [blame] | 107 | boolean |
| 108 | svga_check_sampler_framebuffer_resource_collision(struct svga_context *svga, |
| 109 | enum pipe_shader_type shader); |
| 110 | |
Charmaine Lee | 6303231 | 2015-12-22 11:20:41 -0800 | [diff] [blame] | 111 | enum pipe_error |
| 112 | svga_validate_pipe_sampler_view(struct svga_context *svga, |
| 113 | struct svga_pipe_sampler_view *sv); |
| 114 | |
Keith Whitwell | 287c94e | 2010-04-10 16:05:54 +0100 | [diff] [blame] | 115 | #endif |