2 * Copyright © 2011 Intel Corporation
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
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
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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Code to initialize the binding table entries used by transform feedback.
29 #include "brw_context.h"
30 #include "intel_batchbuffer.h"
31 #include "brw_defines.h"
34 gen6_update_sol_surfaces(struct brw_context
*brw
)
36 struct gl_context
*ctx
= &brw
->intel
.ctx
;
37 /* _NEW_TRANSFORM_FEEDBACK */
38 struct gl_transform_feedback_object
*xfb_obj
=
39 ctx
->TransformFeedback
.CurrentObject
;
40 /* BRW_NEW_VERTEX_PROGRAM */
41 const struct gl_shader_program
*shaderprog
=
42 ctx
->Shader
.CurrentVertexProgram
;
43 const struct gl_transform_feedback_info
*linked_xfb_info
=
44 &shaderprog
->LinkedTransformFeedback
;
47 for (i
= 0; i
< BRW_MAX_SOL_BINDINGS
; ++i
) {
48 const int surf_index
= SURF_INDEX_SOL_BINDING(i
);
49 if (xfb_obj
->Active
&& i
< linked_xfb_info
->NumOutputs
) {
50 unsigned buffer
= linked_xfb_info
->Outputs
[i
].OutputBuffer
;
51 unsigned buffer_offset
=
52 xfb_obj
->Offset
[buffer
] / 4 +
53 linked_xfb_info
->Outputs
[i
].DstOffset
;
54 brw_update_sol_surface(
55 brw
, xfb_obj
->Buffers
[buffer
], &brw
->bind
.surf_offset
[surf_index
],
56 linked_xfb_info
->Outputs
[i
].NumComponents
,
57 linked_xfb_info
->BufferStride
[buffer
], buffer_offset
);
59 brw
->bind
.surf_offset
[surf_index
] = 0;
64 const struct brw_tracked_state gen6_sol_surface
= {
66 .mesa
= _NEW_TRANSFORM_FEEDBACK
,
67 .brw
= (BRW_NEW_BATCH
|
68 BRW_NEW_VERTEX_PROGRAM
),
71 .emit
= gen6_update_sol_surfaces
,
75 brw_end_transform_feedback(struct gl_context
*ctx
,
76 struct gl_transform_feedback_object
*obj
)
78 /* After EndTransformFeedback, it's likely that the client program will try
79 * to draw using the contents of the transform feedback buffer as vertex
80 * input. In order for this to work, we need to flush the data through at
81 * least the GS stage of the pipeline, and flush out the render cache. For
82 * simplicity, just do a full flush.
84 struct brw_context
*brw
= brw_context(ctx
);
85 struct intel_context
*intel
= &brw
->intel
;
86 intel_batchbuffer_emit_mi_flush(intel
);