r300g: fix min/max lod computation
[mesa.git] / src / gallium / drivers / r300 / r300_flush.c
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 #include "draw/draw_context.h"
25 #include "draw/draw_private.h"
26
27 #include "util/u_simple_list.h"
28 #include "util/u_upload_mgr.h"
29
30 #include "r300_context.h"
31 #include "r300_cs.h"
32 #include "r300_emit.h"
33
34 static void r300_flush(struct pipe_context* pipe,
35 unsigned flags,
36 struct pipe_fence_handle** fence)
37 {
38 struct r300_context *r300 = r300_context(pipe);
39 struct r300_query *query;
40 struct r300_atom *atom;
41 struct r300_fence **rfence = (struct r300_fence**)fence;
42
43 u_upload_flush(r300->upload_vb);
44 u_upload_flush(r300->upload_ib);
45
46 if (r300->draw)
47 r300_draw_flush_vbuf(r300);
48
49 if (r300->dirty_hw) {
50 r300_emit_hyperz_end(r300);
51 r300_emit_query_end(r300);
52 if (r500_index_bias_supported(r300))
53 r500_emit_index_bias(r300, 0);
54
55 r300->flush_counter++;
56 r300->rws->cs_flush(r300->cs);
57 r300->dirty_hw = 0;
58
59 /* New kitchen sink, baby. */
60 foreach(atom, &r300->atom_list) {
61 if (atom->state || atom->allow_null_state) {
62 atom->dirty = TRUE;
63 }
64 }
65
66 /* Unmark HWTCL state for SWTCL. */
67 if (!r300->screen->caps.has_tcl) {
68 r300->vs_state.dirty = FALSE;
69 r300->vs_constants.dirty = FALSE;
70 }
71 }
72
73 /* reset flushed query */
74 foreach(query, &r300->query_list) {
75 query->flushed = TRUE;
76 }
77
78 /* Create a new fence. */
79 if (rfence) {
80 *rfence = CALLOC_STRUCT(r300_fence);
81 pipe_reference_init(&(*rfence)->reference, 1);
82 (*rfence)->ctx = r300;
83 }
84 }
85
86 void r300_init_flush_functions(struct r300_context* r300)
87 {
88 r300->context.flush = r300_flush;
89 }