diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2022-01-28 00:52:50 +0100 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2022-02-18 21:09:23 +0100 |
| commit | 0db0fd5a7fd910db4fbb0105cbe85cc7f5d16ed0 (patch) | |
| tree | 38193719de613c06ad8078271c98bff5dd515ccd /src | |
| parent | 20e612502f0c988fa6b690c1651fc4be189a5aa4 (diff) | |
-t option for test: thread aware
Diffstat (limited to 'src')
| -rw-r--r-- | src/vkvg_context_internal.h | 214 |
1 files changed, 107 insertions, 107 deletions
diff --git a/src/vkvg_context_internal.h b/src/vkvg_context_internal.h index 5f5017c..bbce0e8 100644 --- a/src/vkvg_context_internal.h +++ b/src/vkvg_context_internal.h @@ -65,10 +65,10 @@ #define CreateRgbaf(r, g, b, a) (((int)(a * 255.0f) << 24) | ((int)(b * 255.0f) << 16) | ((int)(g * 255.0f) << 8) | (int)(r * 255.0f)) #endif -typedef struct{ - vec2 pos; - uint32_t color; - vec3 uv; +typedef struct { + vec2 pos; + uint32_t color; + vec3 uv; }Vertex; typedef struct { @@ -96,31 +96,30 @@ typedef enum { vkvg_clip_state_clear = 0x01, vkvg_clip_state_clip = 0x02, vkvg_clip_state_clip_saved = 0x06, -} vkvg_clip_state_t; +}vkvg_clip_state_t; -typedef struct _vkvg_context_save_t{ +typedef struct _vkvg_context_save_t { struct _vkvg_context_save_t* pNext; - float lineWidth; - uint32_t dashCount; //value count in dash array, 0 if dash not set. - float dashOffset; //an offset for dash - float* dashes; //an array of alternate lengths of on and off stroke. - + float lineWidth; + uint32_t dashCount; //value count in dash array, 0 if dash not set. + float dashOffset; //an offset for dash + float* dashes; //an array of alternate lengths of on and off stroke. - vkvg_operator_t curOperator; - vkvg_line_cap_t lineCap; - vkvg_line_join_t lineJoint; - vkvg_fill_rule_t curFillRule; + vkvg_operator_t curOperator; + vkvg_line_cap_t lineCap; + vkvg_line_join_t lineJoint; + vkvg_fill_rule_t curFillRule; - long selectedCharSize; /* Font size*/ - char selectedFontName[FONT_NAME_MAX_SIZE]; - _vkvg_font_identity_t selectedFont; //hold current face and size before cache addition - _vkvg_font_identity_t* currentFont; //font ready for lookup - vkvg_direction_t textDirection; - push_constants pushConsts; - uint32_t curColor; - VkvgPattern pattern; - vkvg_clip_state_t clippingState; + long selectedCharSize; /* Font size*/ + char selectedFontName[FONT_NAME_MAX_SIZE]; + _vkvg_font_identity_t selectedFont; //hold current face and size before cache addition + _vkvg_font_identity_t* currentFont; //font ready for lookup + vkvg_direction_t textDirection; + push_constants pushConsts; + uint32_t curColor; + VkvgPattern pattern; + vkvg_clip_state_t clippingState; }vkvg_context_save_t; @@ -155,50 +154,50 @@ typedef struct _vkvg_context_t { #if VKVG_FILL_NZ_GLUTESS void (*vertex_cb)(VKVG_IBO_INDEX_TYPE, VkvgContext);//tesselator vertex callback VKVG_IBO_INDEX_TYPE tesselator_fan_start; - uint32_t tesselator_idx_counter; + uint32_t tesselator_idx_counter; #endif #if VKVG_RECORDING vkvg_recording_t* recording; #endif - vkvg_buff uboGrad; //uniform buff obj holdings gradient infos + vkvg_buff uboGrad; //uniform buff obj holdings gradient infos //vk buffers, holds data until flush - vkvg_buff indices; //index buffer with persistent map memory - uint32_t sizeIBO; //size of vk ibo - uint32_t sizeIndices; //reserved size - uint32_t indCount; //current indice count + vkvg_buff indices; //index buffer with persistent map memory + uint32_t sizeIBO; //size of vk ibo + uint32_t sizeIndices; //reserved size + uint32_t indCount; //current indice count - uint32_t curIndStart; //last index recorded in cmd buff + uint32_t curIndStart; //last index recorded in cmd buff VKVG_IBO_INDEX_TYPE curVertOffset; //vertex offset in draw indexed command - vkvg_buff vertices; //vertex buffer with persistent mapped memory - uint32_t sizeVBO; //size of vk vbo size - uint32_t sizeVertices; //reserved size - uint32_t vertCount; //effective vertices count + vkvg_buff vertices; //vertex buffer with persistent mapped memory + uint32_t sizeVBO; //size of vk vbo size + uint32_t sizeVertices; //reserved size + uint32_t vertCount; //effective vertices count - Vertex* vertexCache; + Vertex* vertexCache; VKVG_IBO_INDEX_TYPE* indexCache; //pathes, exists until stroke of fill - vec2* points; //points array - uint32_t sizePoints; //reserved size - uint32_t pointCount; //effective points count + vec2* points; //points array + uint32_t sizePoints; //reserved size + uint32_t pointCount; //effective points count //pathes array is a list of point count per segment - uint32_t pathPtr; //pointer in the path array - uint32_t* pathes; - uint32_t sizePathes; + uint32_t pathPtr; //pointer in the path array + uint32_t* pathes; + uint32_t sizePathes; - uint32_t segmentPtr; //current segment count in current path having curves - uint32_t subpathCount; //store count of subpath, not straight forward to retrieve from segmented path array - bool simpleConvex; //true if path is single rect or concave closed curve. + uint32_t segmentPtr; //current segment count in current path having curves + uint32_t subpathCount; //store count of subpath, not straight forward to retrieve from segmented path array + bool simpleConvex; //true if path is single rect or concave closed curve. - float lineWidth; - uint32_t dashCount; //value count in dash array, 0 if dash not set. - float dashOffset; //an offset for dash - float* dashes; //an array of alternate lengths of on and off stroke. + float lineWidth; + uint32_t dashCount; //value count in dash array, 0 if dash not set. + float dashOffset; //an offset for dash + float* dashes; //an array of alternate lengths of on and off stroke. vkvg_operator_t curOperator; vkvg_line_cap_t lineCap; @@ -225,24 +224,25 @@ typedef struct _vkvg_context_t { VkRenderPassBeginInfo renderPassBeginInfo; }vkvg_context; -typedef struct _ear_clip_point{ - vec2 pos; - VKVG_IBO_INDEX_TYPE idx; - struct _ear_clip_point* next; +typedef struct _ear_clip_point { + vec2 pos; + VKVG_IBO_INDEX_TYPE idx; + struct _ear_clip_point* next; }ear_clip_point; typedef struct { - bool dashOn; - uint32_t curDash; //current dash index - float curDashOffset; //cur dash offset between defined path point and last dash segment(on/off) start - float totDashLength; //total length of dashes - vec2 normal; + bool dashOn; + uint32_t curDash; //current dash index + float curDashOffset; //cur dash offset between defined path point and last dash segment(on/off) start + float totDashLength; //total length of dashes + vec2 normal; }dash_context_t; typedef struct { - uint32_t iL; - uint32_t iR; - uint32_t cp;//current point + uint32_t iL; + uint32_t iR; + uint32_t cp;//current point + VKVG_IBO_INDEX_TYPE firstIdx;//save first point idx for closed path }stroke_context_t; @@ -254,64 +254,64 @@ void _check_index_cache_size (VkvgContext ctx); void _ensure_index_cache_size (VkvgContext ctx, uint32_t addedIndicesCount); void _resize_index_cache (VkvgContext ctx, uint32_t newSize); -bool _check_pathes_array (VkvgContext ctx); +bool _check_pathes_array (VkvgContext ctx); -bool _current_path_is_empty (VkvgContext ctx); -void _finish_path (VkvgContext ctx); -void _clear_path (VkvgContext ctx); -void _remove_last_point (VkvgContext ctx); -bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath); -void _set_curve_start (VkvgContext ctx); -void _set_curve_end (VkvgContext ctx); -bool _path_has_curves (VkvgContext ctx, uint32_t ptrPath); +bool _current_path_is_empty (VkvgContext ctx); +void _finish_path (VkvgContext ctx); +void _clear_path (VkvgContext ctx); +void _remove_last_point (VkvgContext ctx); +bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath); +void _set_curve_start (VkvgContext ctx); +void _set_curve_end (VkvgContext ctx); +bool _path_has_curves (VkvgContext ctx, uint32_t ptrPath); -float _normalizeAngle (float a); -float _get_arc_step (VkvgContext ctx, float radius); +float _normalizeAngle (float a); +float _get_arc_step (VkvgContext ctx, float radius); -vec2 _get_current_position (VkvgContext ctx); -void _add_point (VkvgContext ctx, float x, float y); +vec2 _get_current_position (VkvgContext ctx); +void _add_point (VkvgContext ctx, float x, float y); -void _resetMinMax (VkvgContext ctx); -void _vkvg_path_extents (VkvgContext ctx, bool transformed, float *x1, float *y1, float *x2, float *y2); -void _draw_stoke_cap (VkvgContext ctx, float hw, vec2 p0, vec2 n, bool isStart); -void _draw_segment (VkvgContext ctx, float hw, stroke_context_t* str, dash_context_t* dc, bool isCurve); -float _draw_dashed_segment (VkvgContext ctx, float hw, stroke_context_t *str, dash_context_t* dc, bool isCurve); +void _resetMinMax (VkvgContext ctx); +void _vkvg_path_extents (VkvgContext ctx, bool transformed, float *x1, float *y1, float *x2, float *y2); +void _draw_stoke_cap (VkvgContext ctx, float hw, vec2 p0, vec2 n, bool isStart); +void _draw_segment (VkvgContext ctx, float hw, stroke_context_t* str, dash_context_t* dc, bool isCurve); +float _draw_dashed_segment (VkvgContext ctx, float hw, stroke_context_t *str, dash_context_t* dc, bool isCurve); -void _poly_fill (VkvgContext ctx); -void _fill_non_zero (VkvgContext ctx); -void _draw_full_screen_quad (VkvgContext ctx, bool useScissor); +void _poly_fill (VkvgContext ctx); +void _fill_non_zero (VkvgContext ctx); +void _draw_full_screen_quad (VkvgContext ctx, bool useScissor); -void _create_gradient_buff (VkvgContext ctx); -void _create_vertices_buff (VkvgContext ctx); -void _add_vertex (VkvgContext ctx, Vertex v); -void _add_vertexf (VkvgContext ctx, float x, float y); -void _set_vertex (VkvgContext ctx, uint32_t idx, Vertex v); -void _add_triangle_indices (VkvgContext ctx, VKVG_IBO_INDEX_TYPE i0, VKVG_IBO_INDEX_TYPE i1, VKVG_IBO_INDEX_TYPE i2); +void _create_gradient_buff (VkvgContext ctx); +void _create_vertices_buff (VkvgContext ctx); +void _add_vertex (VkvgContext ctx, Vertex v); +void _add_vertexf (VkvgContext ctx, float x, float y); +void _set_vertex (VkvgContext ctx, uint32_t idx, Vertex v); +void _add_triangle_indices (VkvgContext ctx, VKVG_IBO_INDEX_TYPE i0, VKVG_IBO_INDEX_TYPE i1, VKVG_IBO_INDEX_TYPE i2); void _add_tri_indices_for_rect (VkvgContext ctx, VKVG_IBO_INDEX_TYPE i); -bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t *str, bool isCurve); +bool _build_vb_step (vkvg_context* ctx, float hw, stroke_context_t *str, bool isCurve); -void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float height); +void _vao_add_rectangle (VkvgContext ctx, float x, float y, float width, float height); -void _bind_draw_pipeline (VkvgContext ctx); -void _create_cmd_buff (VkvgContext ctx); -void _check_vao_size (VkvgContext ctx); -void _ensure_renderpass_is_started (VkvgContext ctx); -void _flush_cmd_buff (VkvgContext ctx); -void _emit_draw_cmd_undrawn_vertices(VkvgContext ctx); -void _flush_cmd_until_vx_base (VkvgContext ctx); -bool _wait_flush_fence (VkvgContext ctx); -bool _wait_and_submit_cmd (VkvgContext ctx); -void _update_push_constants (VkvgContext ctx); -void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat); +void _bind_draw_pipeline (VkvgContext ctx); +void _create_cmd_buff (VkvgContext ctx); +void _check_vao_size (VkvgContext ctx); +void _flush_cmd_buff (VkvgContext ctx); +void _ensure_renderpass_is_started (VkvgContext ctx); +void _emit_draw_cmd_undrawn_vertices (VkvgContext ctx); +void _flush_cmd_until_vx_base (VkvgContext ctx); +bool _wait_flush_fence (VkvgContext ctx); +bool _wait_and_submit_cmd (VkvgContext ctx); +void _update_push_constants (VkvgContext ctx); +void _update_cur_pattern (VkvgContext ctx, VkvgPattern pat); void _set_mat_inv_and_vkCmdPush (VkvgContext ctx); void _start_cmd_for_render_pass (VkvgContext ctx); -void _createDescriptorPool (VkvgContext ctx); -void _init_descriptor_sets (VkvgContext ctx); -void _update_descriptor_set (VkvgContext ctx, VkhImage img, VkDescriptorSet ds); -void _update_gradient_desc_set(VkvgContext ctx); -void _free_ctx_save (vkvg_context_save_t* sav); -void _release_context_ressources (VkvgContext ctx); +void _createDescriptorPool (VkvgContext ctx); +void _init_descriptor_sets (VkvgContext ctx); +void _update_descriptor_set (VkvgContext ctx, VkhImage img, VkDescriptorSet ds); +void _update_gradient_desc_set (VkvgContext ctx); +void _free_ctx_save (vkvg_context_save_t* sav); +void _release_context_ressources(VkvgContext ctx); static inline float vec2_zcross (vec2 v1, vec2 v2){ return v1.x*v2.y-v1.y*v2.x; |