14a49301eSmrg/*
24a49301eSmrg * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
33464ebd5Sriastradh * Copyright 2010 Marek Olšák <maraeo@gmail.com>
44a49301eSmrg *
54a49301eSmrg * Permission is hereby granted, free of charge, to any person obtaining a
64a49301eSmrg * copy of this software and associated documentation files (the "Software"),
74a49301eSmrg * to deal in the Software without restriction, including without limitation
84a49301eSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub
94a49301eSmrg * license, and/or sell copies of the Software, and to permit persons to whom
104a49301eSmrg * the Software is furnished to do so, subject to the following conditions:
114a49301eSmrg *
124a49301eSmrg * The above copyright notice and this permission notice (including the next
134a49301eSmrg * paragraph) shall be included in all copies or substantial portions of the
144a49301eSmrg * Software.
154a49301eSmrg *
164a49301eSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
174a49301eSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
184a49301eSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
194a49301eSmrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
204a49301eSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
214a49301eSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
224a49301eSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. */
234a49301eSmrg
244a49301eSmrg#ifndef R300_SCREEN_H
254a49301eSmrg#define R300_SCREEN_H
264a49301eSmrg
274a49301eSmrg#include "r300_chipset.h"
2801e04c3fSmrg#include "radeon/radeon_winsys.h"
29af69d88dSmrg#include "pipe/p_screen.h"
307ec681f3Smrg#include "util/disk_cache.h"
3101e04c3fSmrg#include "util/slab.h"
32af69d88dSmrg#include "os/os_thread.h"
333464ebd5Sriastradh#include <stdio.h>
343464ebd5Sriastradh
354a49301eSmrgstruct r300_screen {
364a49301eSmrg    /* Parent class */
374a49301eSmrg    struct pipe_screen screen;
384a49301eSmrg
393464ebd5Sriastradh    struct radeon_winsys *rws;
40cdc920a0Smrg
41af69d88dSmrg    /* Chipset info and capabilities. */
42af69d88dSmrg    struct radeon_info info;
433464ebd5Sriastradh    struct r300_capabilities caps;
443464ebd5Sriastradh
45cdc920a0Smrg    /** Combination of DBG_xxx flags */
46cdc920a0Smrg    unsigned debug;
474a49301eSmrg
487ec681f3Smrg    struct disk_cache *disk_shader_cache;
497ec681f3Smrg
5001e04c3fSmrg    struct slab_parent_pool pool_transfers;
5101e04c3fSmrg
52af69d88dSmrg    /* The MSAA texture with CMASK access; */
53af69d88dSmrg    struct pipe_resource *cmask_resource;
5401e04c3fSmrg    mtx_t cmask_mutex;
554a49301eSmrg};
564a49301eSmrg
573464ebd5Sriastradh
583464ebd5Sriastradh/* Convenience cast wrappers. */
5901e04c3fSmrgstatic inline struct r300_screen* r300_screen(struct pipe_screen* screen) {
604a49301eSmrg    return (struct r300_screen*)screen;
614a49301eSmrg}
624a49301eSmrg
6301e04c3fSmrgstatic inline struct radeon_winsys *
643464ebd5Sriastradhradeon_winsys(struct pipe_screen *screen) {
653464ebd5Sriastradh    return r300_screen(screen)->rws;
664a49301eSmrg}
674a49301eSmrg
68cdc920a0Smrg/* Debug functionality. */
69cdc920a0Smrg
70cdc920a0Smrg/**
71cdc920a0Smrg * Debug flags to disable/enable certain groups of debugging outputs.
72cdc920a0Smrg *
73cdc920a0Smrg * \note These may be rather coarse, and the grouping may be impractical.
74cdc920a0Smrg * If you find, while debugging the driver, that a different grouping
75cdc920a0Smrg * of these flags would be beneficial, just feel free to change them
76cdc920a0Smrg * but make sure to update the documentation in r300_debug.c to reflect
77cdc920a0Smrg * those changes.
78cdc920a0Smrg */
79cdc920a0Smrg/*@{*/
803464ebd5Sriastradh
813464ebd5Sriastradh/* Logging. */
823464ebd5Sriastradh#define DBG_PSC         (1 << 0)
833464ebd5Sriastradh#define DBG_FP          (1 << 1)
843464ebd5Sriastradh#define DBG_VP          (1 << 2)
853464ebd5Sriastradh#define DBG_SWTCL       (1 << 3)
863464ebd5Sriastradh#define DBG_DRAW        (1 << 4)
873464ebd5Sriastradh#define DBG_TEX         (1 << 5)
883464ebd5Sriastradh#define DBG_TEXALLOC    (1 << 6)
893464ebd5Sriastradh#define DBG_RS          (1 << 7)
903464ebd5Sriastradh#define DBG_FB          (1 << 8)
913464ebd5Sriastradh#define DBG_RS_BLOCK    (1 << 9)
923464ebd5Sriastradh#define DBG_CBZB        (1 << 10)
933464ebd5Sriastradh#define DBG_HYPERZ      (1 << 11)
943464ebd5Sriastradh#define DBG_SCISSOR     (1 << 12)
953464ebd5Sriastradh#define DBG_INFO        (1 << 13)
96af69d88dSmrg#define DBG_MSAA        (1 << 14)
973464ebd5Sriastradh/* Features. */
983464ebd5Sriastradh#define DBG_ANISOHQ     (1 << 16)
993464ebd5Sriastradh#define DBG_NO_TILING   (1 << 17)
1003464ebd5Sriastradh#define DBG_NO_IMMD     (1 << 18)
1013464ebd5Sriastradh#define DBG_NO_OPT      (1 << 19)
1023464ebd5Sriastradh#define DBG_NO_CBZB     (1 << 20)
1033464ebd5Sriastradh#define DBG_NO_ZMASK    (1 << 21)
1043464ebd5Sriastradh#define DBG_NO_HIZ      (1 << 22)
105af69d88dSmrg#define DBG_NO_CMASK    (1 << 23)
1063464ebd5Sriastradh/* Statistics. */
1073464ebd5Sriastradh#define DBG_P_STAT      (1 << 25)
108cdc920a0Smrg/*@}*/
109cdc920a0Smrg
11001e04c3fSmrgstatic inline boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags)
111cdc920a0Smrg{
112cdc920a0Smrg    return (screen->debug & flags) ? TRUE : FALSE;
113cdc920a0Smrg}
114cdc920a0Smrg
11501e04c3fSmrgstatic inline void SCREEN_DBG(struct r300_screen * screen, unsigned flags,
116cdc920a0Smrg                              const char * fmt, ...)
117cdc920a0Smrg{
118cdc920a0Smrg    if (SCREEN_DBG_ON(screen, flags)) {
119cdc920a0Smrg        va_list va;
120cdc920a0Smrg        va_start(va, fmt);
1213464ebd5Sriastradh        vfprintf(stderr, fmt, va);
122cdc920a0Smrg        va_end(va);
123cdc920a0Smrg    }
124cdc920a0Smrg}
125cdc920a0Smrg
126cdc920a0Smrgvoid r300_init_debug(struct r300_screen* ctx);
1274a49301eSmrg
1283464ebd5Sriastradhvoid r300_init_screen_resource_functions(struct r300_screen *r300screen);
129cdc920a0Smrg
1303464ebd5Sriastradh#endif /* R300_SCREEN_H */
131