Blender
V3.3
|
#include "BLI_assert.h"
#include "BLI_compiler_compat.h"
#include "BLI_math_geom.h"
#include "GPU_common.h"
Go to the source code of this file.
Classes | |
struct | GPUVertAttr |
struct | GPUVertFormat |
struct | GPUPackedNormal |
struct | GPUNormal |
Macros | |
#define | GPU_VERT_ATTR_MAX_LEN 16 |
#define | GPU_VERT_ATTR_MAX_NAMES 6 |
#define | GPU_VERT_ATTR_NAMES_BUF_LEN 256 |
#define | GPU_VERT_FORMAT_MAX_NAMES 63 /* More than enough, actual max is ~30. */ |
#define | GPU_MAX_SAFE_ATTR_NAME 12 |
#define | SIGNED_INT_10_MAX 511 |
#define | SIGNED_INT_10_MIN -512 |
Typedefs | |
typedef struct GPUVertAttr | GPUVertAttr |
typedef struct GPUVertFormat | GPUVertFormat |
typedef struct GPUPackedNormal | GPUPackedNormal |
typedef struct GPUNormal | GPUNormal |
Enumerations | |
enum | GPUVertCompType { GPU_COMP_I8 = 0 , GPU_COMP_U8 , GPU_COMP_I16 , GPU_COMP_U16 , GPU_COMP_I32 , GPU_COMP_U32 , GPU_COMP_F32 , GPU_COMP_I10 } |
enum | GPUVertFetchMode { GPU_FETCH_FLOAT = 0 , GPU_FETCH_INT , GPU_FETCH_INT_TO_FLOAT_UNIT , GPU_FETCH_INT_TO_FLOAT } |
GPU vertex format
Definition in file GPU_vertex_format.h.
#define GPU_MAX_SAFE_ATTR_NAME 12 |
Definition at line 26 of file GPU_vertex_format.h.
#define GPU_VERT_ATTR_MAX_LEN 16 |
Definition at line 21 of file GPU_vertex_format.h.
#define GPU_VERT_ATTR_MAX_NAMES 6 |
Definition at line 22 of file GPU_vertex_format.h.
#define GPU_VERT_ATTR_NAMES_BUF_LEN 256 |
Definition at line 23 of file GPU_vertex_format.h.
Definition at line 24 of file GPU_vertex_format.h.
#define SIGNED_INT_10_MAX 511 |
Definition at line 169 of file GPU_vertex_format.h.
#define SIGNED_INT_10_MIN -512 |
Definition at line 170 of file GPU_vertex_format.h.
typedef struct GPUPackedNormal GPUPackedNormal |
typedef struct GPUVertAttr GPUVertAttr |
typedef struct GPUVertFormat GPUVertFormat |
enum GPUVertCompType |
Enumerator | |
---|---|
GPU_COMP_I8 | |
GPU_COMP_U8 | |
GPU_COMP_I16 | |
GPU_COMP_U16 | |
GPU_COMP_I32 | |
GPU_COMP_U32 | |
GPU_COMP_F32 | |
GPU_COMP_I10 |
Definition at line 28 of file GPU_vertex_format.h.
enum GPUVertFetchMode |
Enumerator | |
---|---|
GPU_FETCH_FLOAT | |
GPU_FETCH_INT | |
GPU_FETCH_INT_TO_FLOAT_UNIT | |
GPU_FETCH_INT_TO_FLOAT |
Definition at line 42 of file GPU_vertex_format.h.
BLI_STATIC_ASSERT | ( | GPU_VERT_ATTR_NAMES_BUF_LEN<= | 256, |
"We use uchar as index inside the name buffer " "so GPU_VERT_ATTR_NAMES_BUF_LEN needs to be " "smaller than GPUVertFormat->name_offset and " "GPUVertAttr->names maximum value" | |||
) |
BLI_INLINE int clampi | ( | int | x, |
int | min_allowed, | ||
int | max_allowed | ||
) |
Definition at line 172 of file GPU_vertex_format.h.
References x.
Referenced by gpu_convert_normalized_f32_to_i10().
BLI_INLINE int gpu_convert_i16_to_i10 | ( | short | x | ) |
Definition at line 194 of file GPU_vertex_format.h.
References x.
Referenced by GPU_normal_convert_i10_s3().
BLI_INLINE int gpu_convert_normalized_f32_to_i10 | ( | float | x | ) |
Definition at line 188 of file GPU_vertex_format.h.
References clampi(), SIGNED_INT_10_MAX, SIGNED_INT_10_MIN, and x.
Referenced by GPU_normal_convert_i10_v3().
BLI_INLINE GPUPackedNormal GPU_normal_convert_i10_s3 | ( | const short | data[3] | ) |
Definition at line 211 of file GPU_vertex_format.h.
References data, and gpu_convert_i16_to_i10().
BLI_INLINE GPUPackedNormal GPU_normal_convert_i10_v3 | ( | const float | data[3] | ) |
Definition at line 201 of file GPU_vertex_format.h.
References data, and gpu_convert_normalized_f32_to_i10().
Referenced by blender::draw::extract_fdots_nor_finish(), blender::draw::extract_lnor_iter_poly_bm(), blender::draw::extract_lnor_iter_poly_mesh(), blender::draw::extract_pos_nor_init(), blender::draw::extract_tan_ex_init(), and GPU_normal_convert_v3().
BLI_INLINE void GPU_normal_convert_v3 | ( | GPUNormal * | gpu_normal, |
const float | data[3], | ||
const bool | do_hq_normals | ||
) |
Definition at line 221 of file GPU_vertex_format.h.
References data, GPU_normal_convert_i10_v3(), GPUNormal::high, GPUNormal::low, and normal_float_to_short_v3().
Referenced by curve_create_edit_curves_nor(), DRW_displist_vertbuf_create_pos_and_nor(), and drw_volume_wireframe_cb().
void GPU_vertformat_alias_add | ( | GPUVertFormat * | format, |
const char * | alias | ||
) |
Definition at line 166 of file gpu_vertex_format.cc.
References copy_attr_name(), GPU_VERT_ATTR_MAX_NAMES, GPU_VERT_FORMAT_MAX_NAMES, GPUVertAttr::name_len, and GPUVertAttr::names.
Referenced by curves_batch_cache_ensure_procedural_pos(), draw_subdiv_get_pos_nor_format(), DRW_cache_fullscreen_quad_get(), DRW_cdlayer_attr_aliases_add(), blender::draw::extract_edituv_data_init_common(), blender::draw::extract_fdots_uv_init(), blender::draw::extract_lnor_hq_init(), blender::draw::extract_lnor_init(), blender::draw::extract_pos_nor_hq_init(), blender::draw::extract_pos_nor_init(), blender::draw::extract_tan_init_common(), blender::draw::get_custom_normals_format(), blender::draw::get_edit_data_format(), blender::draw::get_normals_format(), blender::draw::get_subdiv_lnor_format(), GPU_pbvh_attribute_names_update(), blender::draw::init_vbo_for_attribute(), blender::draw::mesh_extract_uv_format_init(), particle_batch_cache_ensure_pos_and_seg(), and pointcloud_batch_cache_ensure_geom().
uint GPU_vertformat_attr_add | ( | GPUVertFormat * | format, |
const char * | name, | ||
GPUVertCompType | comp_type, | ||
uint | comp_len, | ||
GPUVertFetchMode | fetch_mode | ||
) |
Definition at line 116 of file gpu_vertex_format.cc.
References attr_id, attr_size(), GPUVertAttr::comp_len, GPUVertAttr::comp_type, copy_attr_name(), ELEM, GPUVertAttr::fetch_mode, GPU_COMP_F32, GPU_COMP_I10, GPU_FETCH_FLOAT, GPU_FETCH_INT_TO_FLOAT_UNIT, GPU_VERT_ATTR_MAX_LEN, GPU_VERT_FORMAT_MAX_NAMES, GPUVertAttr::name_len, GPUVertAttr::names, GPUVertAttr::offset, and GPUVertAttr::size.
Referenced by acf_generic_channel_backdrop(), acf_generic_dataexpand_backdrop(), ANIM_channel_draw(), ANIM_draw_action_framerange(), ANIM_draw_cfra(), ANIM_draw_framerange(), ANIM_draw_previewrange(), annotation_draw_eraser(), annotation_draw_stabilizer(), annotation_draw_stroke_2d(), annotation_draw_stroke_3d(), annotation_draw_stroke_buffer(), annotation_draw_stroke_point(), arrow_draw_geom(), batch_screen_edges_get(), blf_batch_draw_init(), brush_drawcursor(), button2d_draw_intern(), button2d_geom_draw_backdrop(), cage2d_draw_box_corners(), cage2d_draw_box_interaction(), cage2d_draw_circle_handles(), cage2d_draw_circle_wire(), cage3d_draw_box_corners(), cage3d_draw_box_interaction(), cage3d_draw_circle_handles(), cage3d_draw_circle_wire(), clip_draw_dopesheet_channels(), clip_draw_dopesheet_main(), clip_draw_graph(), clip_draw_sfra_efra(), console_textview_draw_cursor(), cursor_box_draw(), curve_create_curves_pos(), curve_create_edit_curves_nor(), curve_create_edit_data_and_handles(), curve_draw_stroke_3d(), curves_batch_cache_ensure_procedural_final_points(), curves_batch_cache_ensure_procedural_indices(), curves_batch_cache_ensure_procedural_pos(), curves_batch_cache_ensure_procedural_strand_data(), curves_batch_ensure_attribute(), dial_geom_draw(), dial_ghostarc_draw(), dial_ghostarc_draw_helpline(), dial_ghostarc_draw_incremental_angle(), draw_anti_tria(), draw_azone_arrow(), draw_background(), draw_cache_view(), draw_channel_strips(), draw_columnheader_background(), draw_columnheader_columns(), draw_current_frame(), draw_disk_shaded(), draw_display_buffer(), draw_distortion(), draw_dividers(), draw_effect_inputs_highlight(), draw_fcurve(), draw_fcurve_handles(), draw_fcurve_modifier_controls_envelope(), draw_fcurve_samples(), draw_fcurve_vertices(), draw_image_cache(), draw_image_sample_line(), draw_line_bounds(), draw_line_loop(), draw_line_pairs(), draw_marker_areas(), draw_marker_line(), draw_markers_background(), draw_mouse_position(), draw_movieclip_cache(), draw_movieclip_muted(), draw_nla_main_data(), blender::ed::space_node::draw_nodespace_back_pix(), draw_overlap_frame_indicator(), draw_overshoot_triangle(), draw_parallel_lines(), draw_plane_marker_ex(), draw_plane_marker_image(), draw_render_info(), draw_seq_fcurve_overlay(), draw_seq_in_view(), draw_seq_invalid(), draw_seq_locked(), draw_seq_strip(), draw_seq_strips(), draw_seq_timeline_channels(), draw_single_handle(), draw_spline_points(), blender::ed::spreadsheet::draw_spreadsheet_in_region(), draw_stabilization_border(), draw_subdiv_cache_update_extra_coarse_face_data(), draw_subdiv_get_pos_nor_format(), draw_track_path(), draw_tracking_tracks(), draw_view_axis(), draw_waveform_segment(), drawConstraint(), drawEdgeSlide(), drawFlyPixel(), drawLine(), drawmeta_contents(), drawPropCircle(), drawrenderborder(), drawSnapping(), drawVertSlide(), drawviewborder(), drawWalkPixel(), DRW_cache_bone_box_get(), DRW_cache_bone_dof_lines_get(), DRW_cache_bone_dof_sphere_get(), DRW_cache_bone_envelope_outline_get(), DRW_cache_bone_envelope_solid_get(), DRW_cache_bone_octahedral_get(), DRW_cache_bone_point_get(), DRW_cache_bone_point_wire_outline_get(), DRW_cache_bone_stick_get(), DRW_cache_cursor_get(), DRW_cache_empty_capsule_body_get(), DRW_cache_empty_capsule_cap_get(), DRW_cache_fullscreen_quad_get(), DRW_cache_grid_get(), DRW_cache_normal_arrow_get(), drw_cache_procedural_lines_get(), drw_cache_procedural_points_get(), drw_cache_procedural_triangles_get(), DRW_cache_speaker_get(), DRW_cache_sphere_get(), DRW_curves_init(), drw_debug_draw_lines(), DRW_displist_vertbuf_create_pos_and_nor(), DRW_draw_cursor(), DRW_gpencil_dummy_buffer_get(), DRW_hair_init(), DRW_shgroup_call_buffer(), DRW_shgroup_call_buffer_instance(), DRW_shgroup_instance_format_array(), DRW_vertbuf_create_wiredata(), drw_volume_selection_surface_cb(), drw_volume_wireframe_cb(), dyntopo_detail_size_edit_draw(), ED_draw_object_facemap(), ED_gpencil_brush_draw_eraser(), ED_image_draw_cursor(), ED_image_draw_info(), ED_imbuf_sample_draw(), ED_keylist_draw_list_draw_keys(), ED_mask_draw_frames(), ED_node_socket_draw(), ED_region_cache_draw_background(), ED_region_cache_draw_cached_segments(), ED_region_cache_draw_curfra_label(), ED_region_do_draw(), ED_region_draw_mouse_line_cb(), ED_region_grid_draw(), ED_region_image_metadata_draw(), ED_region_info_draw_multiline(), ED_time_scrub_channel_search_draw(), ED_view3d_cursor_snap_draw_util(), EDBM_preselect_edgering_draw(), EDBM_preselect_elem_draw(), edit_points_vert_format_get(), extra_vert_format(), blender::draw::extract_attr_init_subdiv(), blender::draw::extract_edge_fac_finish(), blender::draw::extract_edge_fac_init(), blender::draw::extract_edituv_data_init_common(), blender::draw::extract_edituv_stretch_angle_init(), blender::draw::extract_edituv_stretch_area_init(), blender::draw::extract_edituv_stretch_area_init_subdiv(), blender::draw::extract_fdots_edituv_data_init(), blender::draw::extract_fdots_nor_hq_init(), blender::draw::extract_fdots_nor_init(), blender::draw::extract_fdots_uv_init(), blender::draw::extract_lines_loose_geom_subdiv(), blender::draw::extract_lnor_hq_init(), blender::draw::extract_lnor_init(), blender::draw::extract_mesh_analysis_init(), blender::draw::extract_orco_init(), blender::draw::extract_pos_nor_hq_init(), blender::draw::extract_pos_nor_init(), blender::draw::extract_pos_nor_init_subdiv(), blender::draw::extract_sculpt_data_init_subdiv(), blender::draw::extract_select_idx_init_impl(), blender::draw::extract_skin_roots_init(), blender::draw::extract_tan_init_common(), blender::draw::extract_weights_init(), blender::draw::extract_weights_init_subdiv(), file_draw_preview(), get_blender_patch_coords_format(), blender::draw::get_coarse_tan_format(), blender::draw::get_custom_normals_format(), blender::draw::get_edit_data_format(), blender::draw::get_edituv_stretch_angle_format_subdiv(), blender::draw::get_fdots_nor_format_subdiv(), blender::draw::get_fdots_pos_format(), blender::draw::get_normals_format(), get_origindex_format(), get_patch_array_format(), get_patch_handle_format(), get_patch_index_format(), get_patch_param_format(), get_quadtree_format(), blender::draw::get_sculpt_data_format(), blender::draw::get_subdiv_edge_fac_format(), blender::draw::get_subdiv_lnor_format(), get_subdiv_vertex_format(), get_uvs_format(), gizmo_axis_draw(), gizmo_cage2d_draw_intern(), gizmo_cage3d_draw_intern(), gizmo_primitive_draw_geom(), gizmo_ruler_draw(), gpencil_brush_cursor_draw(), gpencil_color_format(), gpencil_draw_basic_stroke(), gpencil_draw_eraser(), gpencil_draw_stroke_3d(), gpencil_draw_stroke_volumetric_3d(), gpencil_edit_curve_format(), gpencil_edit_stroke_format(), gpencil_stroke_format(), GPU_batch_tris_from_poly_2d_encoded(), GPU_batch_wire_from_poly_2d_encoded(), GPU_pbvh_attribute_names_update(), gpu_viewport_batch_format(), GPU_viewport_stereo_composite(), blender::ed::sculpt_paint::image::ops::paint::gradient_draw_line(), graph_draw_driver_debug(), graph_draw_ghost_curves(), graph_main_region_draw(), imm_draw_box_checker_2d_ex(), immDrawPixelsTexSetupAttributes(), blender::draw::init_vbo_for_attribute(), knifetool_draw(), knifetool_draw_angle(), knifetool_draw_angle_snapping(), knifetool_draw_orientation_locking(), knifetool_draw_visible_distances(), lattice_batch_cache_create_overlay_batches(), lattice_batch_cache_get_pos(), mask_draw_curve_type(), blender::draw::mesh_extract_uv_format_init(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_draw(), move_geom_draw(), mpath_vbo_get(), nla_action_draw_keyframes(), nla_actionclip_draw_markers(), nla_draw_strip(), nla_draw_use_dashed_outlines(), blender::ed::space_node::node_composit_backdrop_boxmask(), blender::ed::space_node::node_composit_backdrop_ellipsemask(), blender::ed::space_node::node_composit_backdrop_viewer(), blender::ed::space_node::node_draw_hidden(), blender::ed::space_node::node_draw_preview(), blender::ed::space_node::node_draw_preview_background(), blender::ed::space_node::node_draw_sockets(), blender::ed::space_node::nodelink_batch_init(), outliner_back(), outliner_draw_hierarchy_lines(), outliner_draw_highlights(), outliner_draw_separator(), outliner_draw_struct_marks(), paint_cursor_setup_2D_drawing(), paint_cursor_setup_3D_drawing(), paint_draw_cursor_overlay(), paint_draw_curve_cursor(), paint_draw_line_cursor(), paint_draw_smooth_cursor(), paint_draw_tex_overlay(), particle_batch_cache_ensure_pos(), particle_batch_cache_ensure_pos_and_seg(), particle_batch_cache_ensure_procedural_final_points(), particle_batch_cache_ensure_procedural_indices(), particle_batch_cache_ensure_procedural_pos(), particle_batch_cache_ensure_procedural_strand_data(), playanim_toscreen(), pointcloud_batch_cache_ensure_geom(), pointcloud_batch_cache_ensure_pos(), preset_2d_format(), preset_3d_format(), radial_control_paint_cursor(), radial_control_paint_tex(), region_draw_emboss(), screen_draw_join_highlight(), screen_draw_split_preview(), screen_preview_draw_areas(), seq_draw_image_origin_and_outline(), seq_draw_sfra_efra(), sequencer_draw_borders_overlay(), sequencer_draw_display_buffer(), stitch_draw(), blender::gpu::tests::test_gpu_shader_compute_vbo(), textview_draw_sel(), textview_draw_string(), timeline_draw_cache(), transform_draw_cursor_draw(), UI_draw_box_shadow(), ui_draw_but_COLORBAND(), ui_draw_but_CURVE(), ui_draw_but_CURVEPROFILE(), ui_draw_but_HISTOGRAM(), ui_draw_but_HSVCIRCLE(), ui_draw_but_HSVCUBE(), ui_draw_but_TAB_outline(), ui_draw_but_UNITVEC(), ui_draw_gradient(), ui_draw_pie_center(), ui_draw_popover_back_impl(), ui_draw_separator(), UI_draw_text_underline(), ui_hsv_cursor(), UI_panel_category_draw_all(), UI_view2d_dot_grid_draw(), UI_view2d_multi_grid_draw(), v3d_cursor_plane_draw_grid(), blender::gpu::GLShader::vertformat_from_shader(), vflag_format(), vicon_colorset_draw(), vicon_gplayer_color_draw(), vicon_keytype_draw_wrapper(), voxel_size_edit_draw(), waveform_draw_one(), widget_draw_extra_mask(), widget_draw_text(), widget_softshadow(), widget_swatch(), wm_gesture_draw_circle(), wm_gesture_draw_cross(), wm_gesture_draw_lasso(), wm_gesture_draw_line(), wm_gesture_draw_line_active_side(), wm_gesture_draw_rect(), wm_gizmo_geometryinfo_draw(), wm_software_cursor_draw_bitmap(), wm_software_cursor_draw_crosshair(), wm_stereo3d_draw_sidebyside(), wm_stereo3d_draw_topbottom(), wm_xr_controller_aim_draw(), wm_xr_controller_model_batch_create(), and wm_xr_raycast_draw().
int GPU_vertformat_attr_id_get | ( | const GPUVertFormat * | format, |
const char * | name | ||
) |
Definition at line 207 of file gpu_vertex_format.cc.
References GPU_vertformat_attr_name_get(), GPUVertAttr::name_len, and STREQ.
Referenced by EEVEE_motion_blur_cache_finish(), and EEVEE_motion_blur_swap_data().
BLI_INLINE const char* GPU_vertformat_attr_name_get | ( | const GPUVertFormat * | format, |
const GPUVertAttr * | attr, | ||
uint | n_idx | ||
) |
Definition at line 131 of file GPU_vertex_format.h.
References GPUVertAttr::names.
Referenced by GPU_vertformat_attr_id_get(), GPU_vertformat_attr_rename(), GPU_vertformat_multiload_enable(), and blender::gpu::vbo_bind().
void GPU_vertformat_attr_rename | ( | GPUVertFormat * | format, |
int | attr, | ||
const char * | new_name | ||
) |
Definition at line 221 of file gpu_vertex_format.cc.
References attr_id, BLI_assert, GPU_vertformat_attr_name_get(), and GPUVertAttr::name_len.
Referenced by EEVEE_motion_blur_cache_finish(), and EEVEE_motion_blur_swap_data().
void GPU_vertformat_clear | ( | GPUVertFormat * | format | ) |
Definition at line 29 of file gpu_vertex_format.cc.
References GPU_VERT_ATTR_MAX_LEN.
Referenced by curves_batch_cache_ensure_procedural_indices(), ED_region_grid_draw(), GPU_pbvh_attribute_names_update(), immVertexFormat(), particle_batch_cache_ensure_pos_and_seg(), particle_batch_cache_ensure_procedural_indices(), and blender::gpu::GLShader::vertformat_from_shader().
void GPU_vertformat_copy | ( | GPUVertFormat * | dest, |
const GPUVertFormat * | src | ||
) |
Definition at line 46 of file gpu_vertex_format.cc.
Referenced by blender::gpu::VertBuf::init().
void GPU_vertformat_deinterleave | ( | GPUVertFormat * | format | ) |
Make attribute layout non-interleaved. Warning! This does not change data layout! Use direct buffer access to fill the data. This is for advanced usage.
De-interleaved data means all attribute data for each attribute is stored continuously like this: 000011112222 instead of: 012012012012
Definition at line 280 of file gpu_vertex_format.cc.
Referenced by curves_batch_ensure_attribute(), blender::draw::extract_tan_init_common(), blender::draw::init_vbo_for_attribute(), and blender::draw::mesh_extract_uv_format_init().
void GPU_vertformat_from_shader | ( | GPUVertFormat * | format, |
const struct GPUShader * | shader | ||
) |
Definition at line 341 of file gpu_vertex_format.cc.
References blender::gpu::Shader::vertformat_from_shader().
void GPU_vertformat_multiload_enable | ( | GPUVertFormat * | format, |
int | load_count | ||
) |
Makes vertex attribute from the next vertices to be accessible in the vertex shader. For an attribute named "attr" you can access the next nth vertex using "attr{number}". Use this function after specifying all the attributes in the format.
NOTE: This does NOT work when using indexed rendering. NOTE: Only works for first attribute name. (this limitation can be changed if needed)
WARNING: this function creates a lot of aliases/attributes, make sure to keep the attribute name short to avoid overflowing the name-buffer.
Definition at line 177 of file gpu_vertex_format.cc.
References BLI_assert, BLI_snprintf(), copy_attr_name(), GPU_VERT_ATTR_MAX_LEN, GPU_VERT_ATTR_NAMES_BUF_LEN, GPU_VERT_FORMAT_MAX_NAMES, GPU_vertformat_attr_name_get(), GPUVertAttr::name_len, GPUVertAttr::names, GPUVertAttr::offset, and VertexFormat_pack().
Referenced by gpencil_color_format(), and gpencil_stroke_format().
Referenced by attr_input_name(), DRW_cdlayer_attr_aliases_add(), drw_curves_get_attribute_sampler_name(), blender::draw::extract_tan_init_common(), blender::draw::init_vbo_for_attribute(), blender::draw::mesh_extract_uv_format_init(), particle_batch_cache_ensure_pos_and_seg(), and particle_batch_cache_ensure_procedural_strand_data().