[Mesa-dev] [PATCH 2/5] i965: Explicitly maintain a count of SO_DECL structures emitted.
Kenneth Graunke
kenneth at whitecape.org
Mon Oct 28 19:41:16 CET 2013
On 10/28/2013 10:53 AM, Ian Romanick wrote:
> On 10/26/2013 01:33 PM, Kenneth Graunke wrote:
>> Currently, we emit one SO_DECL structure per output, so we use the index
>> in the Outputs[] array as the index into the so_decl[] array as well.
>>
>> In order to support the fake "gl_SkipComponents[1234]" varyings from
>> ARB_transform_feedback3, we'll need to emit SO_DECLs to fill in the
>> holes between successive outputs. This means we'll likely emit more
>> SO_DECLs than there are outputs, so we need to count it explicitly.
>>
>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
>> ---
>> src/mesa/drivers/dri/i965/gen7_sol_state.c | 15 +++++++--------
>> 1 file changed, 7 insertions(+), 8 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/gen7_sol_state.c b/src/mesa/drivers/dri/i965/gen7_sol_state.c
>> index 3e02bdf..b9debdb 100644
>> --- a/src/mesa/drivers/dri/i965/gen7_sol_state.c
>> +++ b/src/mesa/drivers/dri/i965/gen7_sol_state.c
>> @@ -108,17 +108,17 @@ gen7_upload_3dstate_so_decl_list(struct brw_context *brw,
>> /* BRW_NEW_TRANSFORM_FEEDBACK */
>> const struct gl_transform_feedback_info *linked_xfb_info =
>> &vs_prog->LinkedTransformFeedback;
>> - int i;
>> uint16_t so_decl[128];
>> int buffer_mask = 0;
>> int next_offset[4] = {0, 0, 0, 0};
>> + int decls = 0;
>>
>> STATIC_ASSERT(ARRAY_SIZE(so_decl) >= MAX_PROGRAM_OUTPUTS);
>>
>> /* Construct the list of SO_DECLs to be emitted. The formatting of the
>> * command is feels strange -- each dword pair contains a SO_DECL per stream.
>> */
>> - for (i = 0; i < linked_xfb_info->NumOutputs; i++) {
>> + for (int i = 0; i < linked_xfb_info->NumOutputs; i++) {
>
> This is "only" C code, but I strongly approve.
This is actually allowed in C99...and since no one compiles DRI drivers
with MSVC (for obvious reasons), we're free to use C99 features in
src/drivers/dri. It's really great :)
--Ken
More information about the mesa-dev
mailing list