]> O.S.I.I.S - jp/vkvg.git/commitdiff
-t option for test: thread aware
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Thu, 27 Jan 2022 23:52:50 +0000 (00:52 +0100)
committerj-p <jp_bruyere@hotmail.com>
Fri, 18 Feb 2022 20:09:23 +0000 (21:09 +0100)
src/vkvg_context_internal.h
tests/common/test.c

index 5f5017c1208f7e26be7ebaab4346dc69ab659e49..bbce0e84e63d50b175d050ab9c41a401e0c8edfb 100644 (file)
        #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.
-
-
-       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;
+       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;
+
+       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 _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);
-
-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 _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);
+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);
+
+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);
+
+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 _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);
-
-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);
+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 _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;
index cc04584ed414f0e80d778c260d4f437f64a21ac1..3446d74c253c86df0924cc8abb63ccc0275a5d8b 100644 (file)
@@ -52,6 +52,7 @@ int           single_test = -1;       //if not < 0, contains the index of the single test to ru
 
 static bool paused = false;
 static bool offscreen = false;
+static bool threadAware = false;
 static VkSampleCountFlags samples = VK_SAMPLE_COUNT_1_BIT;
 static VkPhysicalDeviceType preferedPhysicalDeviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU;
 static vk_engine_t* e;
@@ -210,6 +211,7 @@ void _print_usage_and_exit(void) {
        printf("\t-d:\t\tenable dashes.\n");
        printf("\t-n index:\tRun only a single test, zero based index.\n");
        printf("\t-q:\t\tQuiet, don't print measures table head row, usefull for batch tests.\n");
+       printf("\t-t:\t\tThread aware, set device in multithreading aware mode.\n");
        printf("\t-p:\t\tPrint test details and exit without performing test, usefull to print details in logs.\n");
        printf("\t-vsync:\t\tEnable VSync, disabled by default.\n");
        printf("\t-o:\t\tPerform test offscreen.\n");
@@ -262,7 +264,7 @@ void _print_details_and_exit(void) {
 void _parse_args (int argc, char* argv[]) {
        int opt = 0;
        bool printTestDetailsAndExit = false;
-       while ((opt = getopt(argc, argv, "+c:df:g:i:j:l:n:opqS:s:v:w:x:y:")) != -1) {
+       while ((opt = getopt(argc, argv, "+c:df:g:i:j:l:n:opqtS:s:v:w:x:y:")) != -1) {
                switch (opt) {
                case 'c':
                        switch (optarg[0]) {
@@ -323,6 +325,9 @@ void _parse_args (int argc, char* argv[]) {
                case 'q':
                        quiet = true;
                        break;
+               case 't':
+                       threadAware = true;
+                       break;
                case 'S':
                        samples = (VkSampleCountFlags)atoi (optarg);
                        break;
@@ -557,6 +562,8 @@ void perform_test_onscreen (void(*testfunc)(void), const char *testName, int arg
        device  = vkvg_device_create_from_vk_multisample(vkh_app_get_inst(e->app), r->dev->phy, r->dev->dev, r->qFam, 0, samples, deferredResolve);
 
        vkvg_device_set_dpy(device, 96, 96);
+       if (threadAware)
+               vkvg_device_set_thread_aware (device, 1);
 
 #ifdef VKVG_TEST_DIRECT_DRAW
        surfaces = (VkvgSurface*)malloc(r->imgCount * sizeof (VkvgSurface));