def _setup_vertex_state(self): mapping = self.shader.mapping bindings = [] attributes = [] attribute_names = [] for binding in mapping["bindings"]: bindings.append( hvk.vertex_input_binding_description(binding=binding["id"], stride=binding["stride"])) for attr in mapping["attributes"]: attributes.append( hvk.vertex_input_attribute_description( location=attr["location"], binding=attr["binding"], format=attr["format"], offset=attr.get("offset", 0))) self.ordered_attribute_names = tuple( a["name"] for a in sorted(mapping["attributes"], key=lambda i: i["binding"])) self.vertex_input_state = hvk.pipeline_vertex_input_state_create_info( vertex_binding_descriptions=bindings, vertex_attribute_descriptions=attributes)
def setup_vertex_input_binding(): global vertex_bindings, vertex_attributes # Setup shader vertex input state position_binding = hvk.vertex_input_binding_description( binding=0, stride=hvk.utils.format_size(vk.FORMAT_R32G32B32_SFLOAT)) normals_binding = hvk.vertex_input_binding_description( binding=1, stride=hvk.utils.format_size(vk.FORMAT_R32G32B32_SFLOAT)) position_attribute = hvk.vertex_input_attribute_description( location=0, binding=0, format=vk.FORMAT_R32G32B32_SFLOAT, offset=0) normals_attribute = hvk.vertex_input_attribute_description( location=1, binding=1, format=vk.FORMAT_R32G32B32_SFLOAT, offset=0) vertex_bindings = (position_binding, normals_binding) vertex_attributes = (position_attribute, normals_attribute)