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:
@@ -2148,7 +2148,8 @@ emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
|
|
||||||
struct anv_state surface_state;
|
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 */
|
/* Color attachment binding */
|
||||||
assert(stage == MESA_SHADER_FRAGMENT);
|
assert(stage == MESA_SHADER_FRAGMENT);
|
||||||
if (binding->index < subpass->color_count) {
|
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;
|
bt_map[s] = surface_state.offset + state_offset;
|
||||||
continue;
|
break;
|
||||||
} else if (binding->set == ANV_DESCRIPTOR_SET_SHADER_CONSTANTS) {
|
|
||||||
|
case ANV_DESCRIPTOR_SET_SHADER_CONSTANTS: {
|
||||||
struct anv_state surface_state =
|
struct anv_state surface_state =
|
||||||
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
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;
|
bt_map[s] = surface_state.offset + state_offset;
|
||||||
add_surface_reloc(cmd_buffer, surface_state, constant_data);
|
add_surface_reloc(cmd_buffer, surface_state, constant_data);
|
||||||
continue;
|
break;
|
||||||
} else if (binding->set == ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS) {
|
}
|
||||||
|
|
||||||
|
case ANV_DESCRIPTOR_SET_NUM_WORK_GROUPS: {
|
||||||
/* This is always the first binding for compute shaders */
|
/* This is always the first binding for compute shaders */
|
||||||
assert(stage == MESA_SHADER_COMPUTE && s == 0);
|
assert(stage == MESA_SHADER_COMPUTE && s == 0);
|
||||||
if (!get_cs_prog_data(pipeline)->uses_num_work_groups)
|
if (!get_cs_prog_data(pipeline)->uses_num_work_groups)
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
struct anv_state surface_state =
|
struct anv_state surface_state =
|
||||||
anv_cmd_buffer_alloc_surface_state(cmd_buffer);
|
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,
|
add_surface_reloc(cmd_buffer, surface_state,
|
||||||
cmd_buffer->state.compute.num_workgroups);
|
cmd_buffer->state.compute.num_workgroups);
|
||||||
}
|
}
|
||||||
continue;
|
break;
|
||||||
} else if (binding->set == ANV_DESCRIPTOR_SET_DESCRIPTORS) {
|
}
|
||||||
|
|
||||||
|
case ANV_DESCRIPTOR_SET_DESCRIPTORS: {
|
||||||
/* This is a descriptor set buffer so the set index is actually
|
/* This is a descriptor set buffer so the set index is actually
|
||||||
* given by binding->binding. (Yes, that's confusing.)
|
* 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;
|
bt_map[s] = set->desc_surface_state.offset + state_offset;
|
||||||
add_surface_reloc(cmd_buffer, set->desc_surface_state,
|
add_surface_reloc(cmd_buffer, set->desc_surface_state,
|
||||||
anv_descriptor_set_address(cmd_buffer, set));
|
anv_descriptor_set_address(cmd_buffer, set));
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
assert(binding->set < MAX_SETS);
|
||||||
const struct anv_descriptor *desc =
|
const struct anv_descriptor *desc =
|
||||||
&pipe_state->descriptors[binding->set]->descriptors[binding->index];
|
&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");
|
assert(!"Invalid descriptor type");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_map[s] = surface_state.offset + state_offset;
|
bt_map[s] = surface_state.offset + state_offset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
Reference in New Issue
Block a user