Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / drivers / i965 / brw_pipe_flush.c
1
2 #include "util/u_upload_mgr.h"
3
4 #include "brw_context.h"
5 #include "brw_screen.h"
6 #include "brw_batchbuffer.h"
7
8
9
10 /* All batchbuffer flushes must go through this function.
11 */
12 void brw_context_flush( struct brw_context *brw )
13 {
14 /*
15 *
16 */
17 brw_emit_query_end(brw);
18
19 /* Move to the end of the current upload buffer so that we'll force choosing
20 * a new buffer next time.
21 */
22 u_upload_flush( brw->vb.upload_vertex );
23 u_upload_flush( brw->vb.upload_index );
24
25 _brw_batchbuffer_flush( brw->batch, __FILE__, __LINE__ );
26
27 /* Mark all context state as needing to be re-emitted.
28 * This is probably not as severe as on 915, since almost all of our state
29 * is just in referenced buffers.
30 */
31 brw->state.dirty.brw |= BRW_NEW_CONTEXT;
32 brw->state.dirty.mesa |= ~0;
33 brw->state.dirty.brw |= ~0;
34 brw->state.dirty.cache |= ~0;
35
36 brw->curbe.need_new_bo = GL_TRUE;
37 }
38
39 static void
40 brw_flush( struct pipe_context *pipe,
41 unsigned flags,
42 struct pipe_fence_handle **fence )
43 {
44 brw_context_flush( brw_context( pipe ) );
45 if (fence)
46 *fence = NULL;
47 }
48
49 static unsigned brw_is_buffer_referenced(struct pipe_context *pipe,
50 struct pipe_buffer *buffer)
51 {
52 struct brw_context *brw = brw_context(pipe);
53 struct brw_screen *bscreen = brw_screen(brw->base.screen);
54
55 return brw_is_buffer_referenced_by_bo( bscreen,
56 buffer,
57 brw->batch->buf );
58 }
59
60 static unsigned brw_is_texture_referenced(struct pipe_context *pipe,
61 struct pipe_texture *texture,
62 unsigned face,
63 unsigned level)
64 {
65 struct brw_context *brw = brw_context(pipe);
66 struct brw_screen *bscreen = brw_screen(brw->base.screen);
67
68 return brw_is_texture_referenced_by_bo( bscreen,
69 texture, face, level,
70 brw->batch->buf );
71 }
72
73 void brw_pipe_flush_init( struct brw_context *brw )
74 {
75 brw->base.flush = brw_flush;
76 brw->base.is_buffer_referenced = brw_is_buffer_referenced;
77 brw->base.is_texture_referenced = brw_is_texture_referenced;
78 }
79
80
81 void brw_pipe_flush_cleanup( struct brw_context *brw )
82 {
83 }