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