void insert_face_into_mesh() { if (!m_inside_mesh_def) { // Begin the definition of the new mesh. m_builder.begin_mesh(m_mesh_name); m_inside_mesh_def = true; } // Insert the features into the mesh, updating index mappings as necessary. insert_vertices_into_mesh(); insert_vertex_normals_into_mesh(); insert_tex_coords_into_mesh(); // Translate feature indices from internal space to mesh space. translate_indices(m_face_vertex_indices, m_vertex_index_mapping); translate_indices(m_face_normal_indices, m_normal_index_mapping); translate_indices(m_face_tex_coord_indices, m_tex_coord_index_mapping); const size_t n = m_face_vertex_indices.size(); // Begin defining a new face. m_builder.begin_face(n); // Set face vertices. m_builder.set_face_vertices(&m_face_vertex_indices.front()); // Set face vertex normals (if any). if (m_face_normal_indices.size() == n) m_builder.set_face_vertex_normals(&m_face_normal_indices.front()); // Set face vertex texture coordinates (if any). if (m_face_tex_coord_indices.size() == n) m_builder.set_face_vertex_tex_coords(&m_face_tex_coord_indices.front()); // End defining the face. m_builder.end_face(); }
void insert_face_into_mesh() { // Begin a mesh definition if we're not already inside one. ensure_mesh_def(); // Insert the features into the mesh, updating index mappings as necessary. insert_vertices_into_mesh(); insert_vertex_normals_into_mesh(); insert_tex_coords_into_mesh(); // Translate feature indices from internal space to mesh space. translate_indices(m_face_vertex_indices, m_vertex_index_mapping); translate_indices(m_face_normal_indices, m_normal_index_mapping); translate_indices(m_face_tex_coord_indices, m_tex_coord_index_mapping); const size_t n = m_face_vertex_indices.size(); // Begin defining a new face. m_builder.begin_face(n); // Set face vertices. m_builder.set_face_vertices(&m_face_vertex_indices.front()); // Set face vertex normals (if any). if (m_face_normal_indices.size() == n) m_builder.set_face_vertex_normals(&m_face_normal_indices.front()); // Set face vertex texture coordinates (if any). if (m_face_tex_coord_indices.size() == n) m_builder.set_face_vertex_tex_coords(&m_face_tex_coord_indices.front()); // Set face material. m_builder.set_face_material(m_current_material_slot_index); // End defining the face. m_builder.end_face(); }
enum pipe_error svga_hwtnl_draw_range_elements(struct svga_hwtnl *hwtnl, struct pipe_resource *index_buffer, unsigned index_size, int index_bias, unsigned min_index, unsigned max_index, unsigned prim, unsigned start, unsigned count, unsigned start_instance, unsigned instance_count) { unsigned gen_prim, gen_size, gen_nr; enum indices_mode gen_type; u_translate_func gen_func; enum pipe_error ret = PIPE_OK; if (hwtnl->api_fillmode != PIPE_POLYGON_MODE_FILL && prim >= PIPE_PRIM_TRIANGLES) { gen_type = u_unfilled_translator(prim, index_size, count, hwtnl->api_fillmode, &gen_prim, &gen_size, &gen_nr, &gen_func); } else { gen_type = u_index_translator(svga_hw_prims, prim, index_size, count, hwtnl->api_pv, hwtnl->hw_pv, PR_DISABLE, &gen_prim, &gen_size, &gen_nr, &gen_func); } if (gen_type == U_TRANSLATE_MEMCPY) { /* No need for translation, just pass through to hardware: */ return svga_hwtnl_simple_draw_range_elements(hwtnl, index_buffer, index_size, index_bias, min_index, max_index, gen_prim, start, count, start_instance, instance_count); } else { struct pipe_resource *gen_buf = NULL; /* Need to allocate a new index buffer and run the translate * func to populate it. Could potentially cache this translated * index buffer with the original to avoid future * re-translations. Not much point if we're just accelerating * GL though, as index buffers are typically used only once * there. */ ret = translate_indices(hwtnl, index_buffer, start * index_size, gen_prim, gen_nr, gen_size, gen_func, &gen_buf); if (ret != PIPE_OK) goto done; ret = svga_hwtnl_simple_draw_range_elements(hwtnl, gen_buf, gen_size, index_bias, min_index, max_index, gen_prim, 0, gen_nr, start_instance, instance_count); if (ret != PIPE_OK) goto done; done: if (gen_buf) pipe_resource_reference(&gen_buf, NULL); return ret; } }