anv: Use a switch statement for binding table setup

It theoretically could be more efficient but the real point here is that
it's no longer really a matter of dealing with special cases and then
the "real" thing.  The way we're handling binding tables, it's more of a
multi-step process and a switch is more natural.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
Jason Ekstrand
2019-11-07 14:39:28 -06:00
parent 9baa33cef0
commit ca8117b5d5

View File

@@ -2148,7 +2148,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
struct anv_state surface_state;
if (binding->set == ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS) {
switch (binding->set) {
case ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS:
/* Color attachment binding */
assert(stage == MESA_SHADER_FRAGMENT);
if (binding->index < subpass->color_count) {
@@ -2171,8 +2172,9 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
}
bt_map[s] = surface_state.offset + state_offset;
continue;
} else if (binding->set == ANV_DESCRIPTOR_SET_SHADER_CONSTANTS) {
break;
case ANV_DESCRIPTOR_SET_SHADER_CONSTANTS: {
struct anv_state surface_state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
@@ -2191,12 +2193,14 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
bt_map[s] = surface_state.offset + state_offset;
add_surface_reloc(cmd_buffer, surface_state, constant_data);
continue;
} else if (binding->set == ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS) {
break;
}
case ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS: {
/* This is always the first binding for compute shaders */
assert(stage == MESA_SHADER_COMPUTE && s == 0);
if (!get_cs_prog_data(pipeline)->uses_num_work_groups)
continue;
break;
struct anv_state surface_state =
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
@@ -2212,8 +2216,10 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
add_surface_reloc(cmd_buffer, surface_state,
cmd_buffer->state.compute.num_workgroups);
}
continue;
} else if (binding->set == ANV_DESCRIPTOR_SET_DESCRIPTORS) {
break;
}
case ANV_DESCRIPTOR_SET_DESCRIPTORS: {
/* This is a descriptor set buffer so the set index is actually
* given by binding->binding. (Yes, that's confusing.)
*/
@@ -2224,9 +2230,11 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
bt_map[s] = set->desc_surface_state.offset + state_offset;
add_surface_reloc(cmd_buffer, set->desc_surface_state,
anv_descriptor_set_address(cmd_buffer, set));
continue;
break;
}
default: {
assert(binding->set < MAX_SETS);
const struct anv_descriptor *desc =
&pipe_state->descriptors[binding->set]->descriptors[binding->index];
@@ -2350,8 +2358,10 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
assert(!"Invalid descriptor type");
continue;
}
bt_map[s] = surface_state.offset + state_offset;
break;
}
}
}
return VK_SUCCESS;