1 /*
2  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3  * Copyright 2010 Marek Olšák <maraeo@gmail.com>
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * on the rights to use, copy, modify, merge, publish, distribute, sub
9  * license, and/or sell copies of the Software, and to permit persons to whom
10  * the Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22  * USE OR OTHER DEALINGS IN THE SOFTWARE. */
23 
24 #ifndef R300_SCREEN_H
25 #define R300_SCREEN_H
26 
27 #include "r300_chipset.h"
28 #include "radeon/radeon_winsys.h"
29 #include "pipe/p_screen.h"
30 #include "util/disk_cache.h"
31 #include "util/slab.h"
32 #include "os/os_thread.h"
33 #include <stdio.h>
34 
35 struct r300_screen {
36     /* Parent class */
37     struct pipe_screen screen;
38 
39     struct radeon_winsys *rws;
40 
41     /* Chipset info and capabilities. */
42     struct radeon_info info;
43     struct r300_capabilities caps;
44 
45     /** Combination of DBG_xxx flags */
46     unsigned debug;
47 
48     struct disk_cache *disk_shader_cache;
49 
50     struct slab_parent_pool pool_transfers;
51 
52     /* The MSAA texture with CMASK access; */
53     struct pipe_resource *cmask_resource;
54     mtx_t cmask_mutex;
55 };
56 
57 
58 /* Convenience cast wrappers. */
r300_screen(struct pipe_screen * screen)59 static inline struct r300_screen* r300_screen(struct pipe_screen* screen) {
60     return (struct r300_screen*)screen;
61 }
62 
63 static inline struct radeon_winsys *
radeon_winsys(struct pipe_screen * screen)64 radeon_winsys(struct pipe_screen *screen) {
65     return r300_screen(screen)->rws;
66 }
67 
68 /* Debug functionality. */
69 
70 /**
71  * Debug flags to disable/enable certain groups of debugging outputs.
72  *
73  * \note These may be rather coarse, and the grouping may be impractical.
74  * If you find, while debugging the driver, that a different grouping
75  * of these flags would be beneficial, just feel free to change them
76  * but make sure to update the documentation in r300_debug.c to reflect
77  * those changes.
78  */
79 /*@{*/
80 
81 /* Logging. */
82 #define DBG_PSC         (1 << 0)
83 #define DBG_FP          (1 << 1)
84 #define DBG_VP          (1 << 2)
85 #define DBG_SWTCL       (1 << 3)
86 #define DBG_DRAW        (1 << 4)
87 #define DBG_TEX         (1 << 5)
88 #define DBG_TEXALLOC    (1 << 6)
89 #define DBG_RS          (1 << 7)
90 #define DBG_FB          (1 << 8)
91 #define DBG_RS_BLOCK    (1 << 9)
92 #define DBG_CBZB        (1 << 10)
93 #define DBG_HYPERZ      (1 << 11)
94 #define DBG_SCISSOR     (1 << 12)
95 #define DBG_INFO        (1 << 13)
96 #define DBG_MSAA        (1 << 14)
97 /* Features. */
98 #define DBG_ANISOHQ     (1 << 16)
99 #define DBG_NO_TILING   (1 << 17)
100 #define DBG_NO_IMMD     (1 << 18)
101 #define DBG_NO_OPT      (1 << 19)
102 #define DBG_NO_CBZB     (1 << 20)
103 #define DBG_NO_ZMASK    (1 << 21)
104 #define DBG_NO_HIZ      (1 << 22)
105 #define DBG_NO_CMASK    (1 << 23)
106 /* Statistics. */
107 #define DBG_P_STAT      (1 << 25)
108 /*@}*/
109 
SCREEN_DBG_ON(struct r300_screen * screen,unsigned flags)110 static inline boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags)
111 {
112     return (screen->debug & flags) ? TRUE : FALSE;
113 }
114 
SCREEN_DBG(struct r300_screen * screen,unsigned flags,const char * fmt,...)115 static inline void SCREEN_DBG(struct r300_screen * screen, unsigned flags,
116                               const char * fmt, ...)
117 {
118     if (SCREEN_DBG_ON(screen, flags)) {
119         va_list va;
120         va_start(va, fmt);
121         vfprintf(stderr, fmt, va);
122         va_end(va);
123     }
124 }
125 
126 void r300_init_debug(struct r300_screen* ctx);
127 
128 void r300_init_screen_resource_functions(struct r300_screen *r300screen);
129 
130 #endif /* R300_SCREEN_H */
131