761aedebfcfb1871dea0a5ecd21ba301c2d71392
[mesa.git] / src / gallium / drivers / r300 / r300_winsys.h
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef R300_WINSYS_H
24 #define R300_WINSYS_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /* The public interface header for the r300 pipe driver.
31 * Any winsys hosting this pipe needs to implement r300_winsys and then
32 * call r300_create_context to start things. */
33
34 #include "pipe/p_defines.h"
35 #include "pipe/p_state.h"
36 #include "pipe/internal/p_winsys_screen.h"
37
38 struct r300_winsys {
39 /* Parent class */
40 struct pipe_winsys base;
41
42 /* Opaque Radeon-specific winsys object. */
43 void* radeon_winsys;
44
45 /* CS object. This is very much like Intel's batchbuffer.
46 * Fill it full of dwords and relocs and then submit.
47 * Repeat as needed. */
48 struct radeon_cs* cs;
49
50 /* PCI ID */
51 uint32_t pci_id;
52
53 /* GB pipe count */
54 uint32_t gb_pipes;
55
56 /* GART size. */
57 uint32_t gart_size;
58
59 /* VRAM size. */
60 uint32_t vram_size;
61
62 /* Add a pipe_buffer to the list of buffer objects to validate. */
63 void (*add_buffer)(struct r300_winsys* winsys,
64 struct pipe_buffer* pbuffer,
65 uint32_t rd,
66 uint32_t wd);
67
68 /* Revalidate all currently setup pipe_buffers.
69 * Returns TRUE if a flush is required. */
70 boolean (*validate)(struct r300_winsys* winsys);
71
72 /* Check to see if there's room for commands. */
73 boolean (*check_cs)(struct r300_winsys* winsys, int size);
74
75 /* Start a command emit. */
76 void (*begin_cs)(struct r300_winsys* winsys,
77 int size,
78 const char* file,
79 const char* function,
80 int line);
81
82 /* Write a dword to the command buffer. */
83 void (*write_cs_dword)(struct r300_winsys* winsys, uint32_t dword);
84
85 /* Write a relocated dword to the command buffer. */
86 void (*write_cs_reloc)(struct r300_winsys* winsys,
87 struct pipe_buffer* bo,
88 uint32_t rd,
89 uint32_t wd,
90 uint32_t flags);
91
92 /* Finish a command emit. */
93 void (*end_cs)(struct r300_winsys* winsys,
94 const char* file,
95 const char* function,
96 int line);
97
98 /* Flush the CS. */
99 void (*flush_cs)(struct r300_winsys* winsys);
100 };
101
102 struct pipe_context* r300_create_context(struct pipe_screen* screen,
103 struct r300_winsys* r300_winsys);
104
105 boolean r300_get_texture_buffer(struct pipe_texture* texture,
106 struct pipe_buffer** buffer,
107 unsigned* stride);
108
109 #ifdef __cplusplus
110 }
111 #endif
112
113 #endif /* R300_WINSYS_H */