[Mesa-dev] [PATCH 3/3] i965: Simplify SO_DECL handling.
Kenneth Graunke
kenneth at whitecape.org
Wed May 31 08:17:47 UTC 2017
We can initialize structs directly, avoid some temporaries, and cut out
about half of the skip component handling.
---
src/mesa/drivers/dri/i965/genX_state_upload.c | 41 +++++++++------------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 5d45625c1c1..1f05eea4426 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -3080,25 +3080,15 @@ genX(upload_3dstate_so_decl_list)(struct brw_context *brw,
for (unsigned i = 0; i < linked_xfb_info->NumOutputs; i++) {
const struct gl_transform_feedback_output *output =
&linked_xfb_info->Outputs[i];
- struct GENX(SO_DECL) decl = {0};
const int buffer = output->OutputBuffer;
const int varying = output->OutputRegister;
- const unsigned components = output->NumComponents;
- unsigned component_mask = (1 << components) - 1;
const unsigned stream_id = output->StreamId;
- const unsigned decl_buffer_slot = buffer;
assert(stream_id < MAX_VERTEX_STREAMS);
- component_mask <<= output->ComponentOffset;
-
buffer_mask[stream_id] |= 1 << buffer;
assert(vue_map->varying_to_slot[varying] >= 0);
- decl.OutputBufferSlot = decl_buffer_slot;
- decl.RegisterIndex = vue_map->varying_to_slot[varying];
- decl.ComponentMask = component_mask;
-
/* Mesa doesn't store entries for gl_SkipComponents in the Outputs[]
* array. Instead, it simply increments DstOffset for the following
* input by the number of components that should be skipped.
@@ -3111,28 +3101,23 @@ genX(upload_3dstate_so_decl_list)(struct brw_context *brw,
*/
int skip_components = output->DstOffset - next_offset[buffer];
- next_offset[buffer] += skip_components;
-
- while (skip_components >= 4) {
- struct GENX(SO_DECL) *d = &so_decl[stream_id][decls[stream_id]++];
- d->HoleFlag = 1;
- d->OutputBufferSlot = decl_buffer_slot;
- d->ComponentMask = 0xf;
+ while (skip_components > 0) {
+ so_decl[stream_id][decls[stream_id]++] = (struct GENX(SO_DECL)) {
+ .HoleFlag = 1,
+ .OutputBufferSlot = output->OutputBuffer,
+ .ComponentMask = (1 << MIN2(skip_components, 4)) - 1,
+ };
skip_components -= 4;
}
- if (skip_components > 0) {
- struct GENX(SO_DECL) *d = &so_decl[stream_id][decls[stream_id]++];
- d->HoleFlag = 1;
- d->OutputBufferSlot = decl_buffer_slot;
- d->ComponentMask = (1 << skip_components) - 1;
- }
-
- assert(output->DstOffset == next_offset[buffer]);
+ next_offset[buffer] = output->DstOffset + output->NumComponents;
- next_offset[buffer] += components;
-
- so_decl[stream_id][decls[stream_id]++] = decl;
+ so_decl[stream_id][decls[stream_id]++] = (struct GENX(SO_DECL)) {
+ .OutputBufferSlot = output->OutputBuffer,
+ .RegisterIndex = vue_map->varying_to_slot[varying],
+ .ComponentMask =
+ ((1 << output->NumComponents) - 1) << output->ComponentOffset,
+ };
if (decls[stream_id] > max_decls)
max_decls = decls[stream_id];
--
2.13.0
More information about the mesa-dev
mailing list