2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright 2010 Marek Olšák <maraeo@gmail.com>
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:
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
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. */
24 #include "draw/draw_context.h"
25 #include "draw/draw_private.h"
27 #include "util/u_simple_list.h"
28 #include "util/u_upload_mgr.h"
30 #include "r300_context.h"
32 #include "r300_emit.h"
34 static void r300_flush(struct pipe_context
* pipe
,
36 struct pipe_fence_handle
** fence
)
38 struct r300_context
*r300
= r300_context(pipe
);
39 struct r300_atom
*atom
;
40 struct r300_winsys_bo
**rfence
= (struct r300_winsys_bo
**)fence
;
42 if (r300
->draw
&& !r300
->draw_vbo_locked
)
43 r300_draw_flush_vbuf(r300
);
46 /* Create a fence, which is a dummy BO. */
47 *rfence
= r300
->rws
->buffer_create(r300
->rws
, 1, 1,
48 PIPE_BIND_VERTEX_BUFFER
,
51 /* Add the fence as a dummy relocation. */
52 r300
->rws
->cs_add_reloc(r300
->cs
,
53 r300
->rws
->buffer_get_cs_handle(*rfence
),
54 R300_DOMAIN_GTT
, R300_DOMAIN_GTT
);
58 r300_emit_hyperz_end(r300
);
59 r300_emit_query_end(r300
);
60 if (r300
->screen
->caps
.index_bias_supported
)
61 r500_emit_index_bias(r300
, 0);
63 r300
->flush_counter
++;
64 r300
->rws
->cs_flush(r300
->cs
);
67 /* New kitchen sink, baby. */
68 foreach_atom(r300
, atom
) {
69 if (atom
->state
|| atom
->allow_null_state
) {
70 r300_mark_atom_dirty(r300
, atom
);
73 r300
->vertex_arrays_dirty
= TRUE
;
75 /* Unmark HWTCL state for SWTCL. */
76 if (!r300
->screen
->caps
.has_tcl
) {
77 r300
->vs_state
.dirty
= FALSE
;
78 r300
->vs_constants
.dirty
= FALSE
;
81 r300
->validate_buffers
= TRUE
;
82 r300
->upload_vb_validated
= FALSE
;
83 r300
->upload_ib_validated
= FALSE
;
86 /* We have to create a fence object, but the command stream is empty
87 * and we cannot emit an empty CS. We must write some regs then. */
89 OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK
, 0);
90 r300
->rws
->cs_flush(r300
->cs
);
92 /* Even if hw is not dirty, we should at least reset the CS in case
93 * the space checking failed for the first draw operation. */
94 r300
->rws
->cs_flush(r300
->cs
);
99 void r300_init_flush_functions(struct r300_context
* r300
)
101 r300
->context
.flush
= r300_flush
;