r300_screen.h revision 70b86fb273ee9c3b6fea750bc14eae43328ba677
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 "pipe/p_screen.h"
28
29#include "r300_chipset.h"
30
31#include "util/u_slab.h"
32
33#include <stdio.h>
34
35struct radeon_winsys;
36
37struct r300_screen {
38    /* Parent class */
39    struct pipe_screen screen;
40
41    struct radeon_winsys *rws;
42
43    /* Chipset capabilities */
44    struct r300_capabilities caps;
45
46    /* Memory pools. */
47    struct util_slab_mempool pool_buffers;
48
49    /** Combination of DBG_xxx flags */
50    unsigned debug;
51
52    /* The number of created contexts to know whether we have multiple
53     * contexts or not. */
54    int num_contexts;
55    pipe_mutex num_contexts_mutex;
56};
57
58
59/* Convenience cast wrappers. */
60static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) {
61    return (struct r300_screen*)screen;
62}
63
64static INLINE struct radeon_winsys *
65radeon_winsys(struct pipe_screen *screen) {
66    return r300_screen(screen)->rws;
67}
68
69/* Debug functionality. */
70
71/**
72 * Debug flags to disable/enable certain groups of debugging outputs.
73 *
74 * \note These may be rather coarse, and the grouping may be impractical.
75 * If you find, while debugging the driver, that a different grouping
76 * of these flags would be beneficial, just feel free to change them
77 * but make sure to update the documentation in r300_debug.c to reflect
78 * those changes.
79 */
80/*@{*/
81
82/* Logging. */
83#define DBG_PSC         (1 << 0)
84#define DBG_FP          (1 << 1)
85#define DBG_VP          (1 << 2)
86#define DBG_SWTCL       (1 << 3)
87#define DBG_DRAW        (1 << 4)
88#define DBG_TEX         (1 << 5)
89#define DBG_TEXALLOC    (1 << 6)
90#define DBG_RS          (1 << 7)
91/* gap - fill it */
92#define DBG_FB          (1 << 9)
93#define DBG_RS_BLOCK    (1 << 10)
94#define DBG_CBZB        (1 << 11)
95#define DBG_HYPERZ      (1 << 12)
96#define DBG_SCISSOR     (1 << 13)
97#define DBG_UPLOAD      (1 << 14)
98#define DBG_INFO        (1 << 15)
99/* Features. */
100#define DBG_ANISOHQ     (1 << 16)
101#define DBG_NO_TILING   (1 << 17)
102#define DBG_NO_IMMD     (1 << 18)
103/* gap - fill it */
104#define DBG_NO_OPT      (1 << 20)
105#define DBG_NO_CBZB     (1 << 21)
106#define DBG_NO_ZMASK    (1 << 22)
107#define DBG_NO_HIZ      (1 << 23)
108/* Statistics. */
109#define DBG_P_STAT      (1 << 25)
110/*@}*/
111
112static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags)
113{
114    return (screen->debug & flags) ? TRUE : FALSE;
115}
116
117static INLINE void SCREEN_DBG(struct r300_screen * screen, unsigned flags,
118                              const char * fmt, ...)
119{
120    if (SCREEN_DBG_ON(screen, flags)) {
121        va_list va;
122        va_start(va, fmt);
123        vfprintf(stderr, fmt, va);
124        va_end(va);
125    }
126}
127
128void r300_init_debug(struct r300_screen* ctx);
129
130void r300_init_screen_resource_functions(struct r300_screen *r300screen);
131
132#endif /* R300_SCREEN_H */
133