diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-08-07 10:11:28 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-08-13 09:43:14 -0700 |
commit | f714eab882d90f4b9c8643dc070cbc81a48bb323 (patch) | |
tree | dfaa53184183ab044e91b8b5bc8f030abfff0b12 /src | |
parent | 9b2514d6c6e3b5cfa12e347b0aa100406338d26f (diff) |
panfrost: Import stream out utility from iris
We'll need this in a moment. Ken's implementation, lightly edited for
Panfrost.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Suggested-by: Kenneth Graunke <[email protected]>
Reviewed-by: Boris Brezillon <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 7c4c0f76984..e6cbd057818 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1,6 +1,7 @@ /* * © Copyright 2018 Alyssa Rosenzweig * Copyright © 2014-2017 Broadcom + * Copyright (C) 2017 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -2017,6 +2018,45 @@ panfrost_variant_matches( return true; } +/** + * Fix an uncompiled shader's stream output info, and produce a bitmask + * of which VARYING_SLOT_* are captured for stream output. + * + * Core Gallium stores output->register_index as a "slot" number, where + * slots are assigned consecutively to all outputs in info->outputs_written. + * This naive packing of outputs doesn't work for us - we too have slots, + * but the layout is defined by the VUE map, which we won't have until we + * compile a specific shader variant. So, we remap these and simply store + * VARYING_SLOT_* in our copy's output->register_index fields. + * + * We then produce a bitmask of outputs which are used for SO. + * + * Implementation from iris. + */ + +static uint64_t +update_so_info(struct pipe_stream_output_info *so_info, + uint64_t outputs_written) +{ + uint64_t so_outputs = 0; + uint8_t reverse_map[64] = {}; + unsigned slot = 0; + + while (outputs_written) + reverse_map[slot++] = u_bit_scan64(&outputs_written); + + for (unsigned i = 0; i < so_info->num_outputs; i++) { + struct pipe_stream_output *output = &so_info->output[i]; + + /* Map Gallium's condensed "slots" back to real VARYING_SLOT_* enums */ + output->register_index = reverse_map[output->register_index]; + + so_outputs |= 1ull << output->register_index; + } + + return so_outputs; +} + static void panfrost_bind_shader_state( struct pipe_context *pctx, |