Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4358 Serge 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
 
27
#define SVGA_SCREEN_CACHE_H_
28
29
 
30
 
31
#include "svga_reg.h"
32
#include "svga3d_reg.h"
33
34
 
35
36
 
37
38
 
39
 
40
 * this amount:
41
 */
42
#define SVGA_HOST_SURFACE_CACHE_BYTES (16 * 1024 * 1024)
43
44
 
45
 */
46
#define SVGA_HOST_SURFACE_CACHE_SIZE 1024
47
48
 
49
 */
50
#define SVGA_HOST_SURFACE_CACHE_BUCKETS 256
51
52
 
53
 
54
struct svga_screen;
55
56
 
57
 * Same as svga_winsys_screen::surface_create.
58
 */
59
struct svga_host_surface_cache_key
60
{
61
   SVGA3dSurfaceFlags flags;
62
   SVGA3dSurfaceFormat format;
63
   SVGA3dSize size;
64
   uint32_t numFaces:24;
65
   uint32_t numMipLevels:7;
66
   uint32_t cachable:1;         /* False if this is a shared surface */
67
};
68
69
 
70
 
71
{
72
   /**
73
    * Head for the LRU list, svga_host_surface_cache::unused, and
74
    * svga_host_surface_cache::empty
75
    */
76
   struct list_head head;
77
78
 
79
   struct list_head bucket_head;
80
81
 
82
   struct svga_winsys_surface *handle;
83
84
 
85
};
86
87
 
88
 
89
 * Cache of the host surfaces.
90
 *
91
 * A cache entry can be in the following stages:
92
 * 1. empty (entry->handle = NULL)
93
 * 2. holding a buffer in a validate list
94
 * 3. holding a flushed buffer (not in any validate list) with an active fence
95
 * 4. holding a flushed buffer with an expired fence
96
 *
97
 * An entry progresses from 1 -> 2 -> 3 -> 4. When we need an entry to put a
98
 * buffer into we preferentially take from 1, or from the least recently used
99
 * buffer from 3/4.
100
 */
101
struct svga_host_surface_cache
102
{
103
   pipe_mutex mutex;
104
105
 
106
   struct list_head bucket[SVGA_HOST_SURFACE_CACHE_BUCKETS];
107
108
 
109
    * (3 and 4) */
110
   struct list_head unused;
111
112
 
113
   struct list_head validated;
114
115
 
116
   struct list_head empty;
117
118
 
119
   struct svga_host_surface_cache_entry entries[SVGA_HOST_SURFACE_CACHE_SIZE];
120
121
 
122
   unsigned total_size;
123
};
124
125
 
126
 
127
svga_screen_cache_cleanup(struct svga_screen *svgascreen);
128
129
 
130
svga_screen_cache_flush(struct svga_screen *svgascreen,
131
                        struct pipe_fence_handle *fence);
132
133
 
134
svga_screen_cache_init(struct svga_screen *svgascreen);
135
136
 
137
 
138
svga_screen_surface_create(struct svga_screen *svgascreen,
139
                           struct svga_host_surface_cache_key *key);
140
141
 
142
svga_screen_surface_destroy(struct svga_screen *svgascreen,
143
                            const struct svga_host_surface_cache_key *key,
144
                            struct svga_winsys_surface **handle);
145
146
 
147
svga_screen_cache_dump(const struct svga_screen *svgascreen);
148
149
 
150
 
151