]> O.S.I.I.S - jp/crow.git/commitdiff
first working version
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 13 Jul 2021 18:56:10 +0000 (20:56 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 13 Jul 2021 18:56:10 +0000 (20:56 +0200)
Crow/Default.style
Crow/src/Fill/SvgPicture.cs
Crow/src/GraphicBackends/vkvg/Surface.cs
Crow/src/GraphicBackends/vkvg/VulkanContext.cs
Crow/src/Interface.cs
Directory.Build.props
Samples/BasicTests/BasicTests.cs

index 8a6d3e6e0cdb220f966825b585f997e3fd9b1bc1..46de42c963951b9a6360bd9f2779cf7d4b611b88 100644 (file)
@@ -328,6 +328,6 @@ MessageBox, Popper, Slider, Spinner, TextBox, NumericControl {
        Margin="0";
        BubbleMouseEvent="MouseWheel|Keyboard";
 }
-TemplatedControl, GenericStack {
-       CacheEnabled="true";
-}
\ No newline at end of file
+//TemplatedControl, GenericStack {
+//     CacheEnabled="true";
+//}
\ No newline at end of file
index cd5757675909252d2046f683d4106dd57938cfba..1f1bb12e31f39c90b15bbd76dd00f7fe182a7b16 100644 (file)
@@ -126,7 +126,7 @@ namespace Crow
                                        widthRatio = heightRatio;
                        }
                                
-                       gr.Save ();
+                       /*gr.Save ();
 
                        gr.Translate (rect.Left,rect.Top);
                        gr.Scale (widthRatio, heightRatio);
@@ -140,7 +140,7 @@ namespace Crow
                                        hSVG.RenderCairoSub (gr, "#" + subPart);
                        }
                        
-                       gr.Restore ();                  
+                       gr.Restore ();  */              
                }
        }
 }
index 98a563c7173bad678d1596f75b476d06ab32de31..de7682cfd628424b16672455afbf57c4dced4561 100644 (file)
@@ -52,7 +52,7 @@ namespace vkvg
 //             }
 
                public void Flush () {
-                       throw new NotImplementedException ();
+                       //throw new NotImplementedException ();
                }
 
                public void WriteToPng (string path) {
index 39579129c1b0a6ec4625a9a83a1b258e02b53e74..8ca1eb6d0b72e8176478e61f330d426deba79002 100644 (file)
@@ -50,9 +50,13 @@ namespace vkvg {
                string[] EnabledDeviceExtensions => new string[] { Ext.D.VK_KHR_swapchain };
 
                uint width, height;
-
+               public void WaitIdle() => dev.WaitIdle ();
                public VulkanContext (IntPtr hWin, uint _width, uint _height, bool vsync = false) {
                        this.hWin = hWin;
+                       Instance.VALIDATION = true;
+                       /*Instance.RENDER_DOC_CAPTURE = true;*/
+
+                       SwapChain.IMAGES_USAGE = VkImageUsageFlags.ColorAttachment | VkImageUsageFlags.TransferDst;
 
                        List<string> instExts = new List<string> (Glfw3.GetRequiredInstanceExtensions ());
                        if (EnabledInstanceExtensions != null)
@@ -100,8 +104,9 @@ namespace vkvg {
                internal vke.Image blitSource;
                
                public void BuildBlitCommand (vkvg.Surface surf) {
+                       cmdPool.Reset();
                        
-                       blitSource = new vke.Image (dev, new VkImage((ulong)surf.VkImage.ToInt64()), Vulkan.VkFormat.R8g8b8a8Unorm,
+                       blitSource = new vke.Image (dev, new VkImage((ulong)surf.VkImage.ToInt64()), Vulkan.VkFormat.B8g8r8a8Unorm,
                                Vulkan.VkImageUsageFlags.TransferSrc | Vulkan.VkImageUsageFlags.TransferDst | Vulkan.VkImageUsageFlags.ColorAttachment,
                                width, height);
 
@@ -110,17 +115,31 @@ namespace vkvg {
                                vke.PrimaryCommandBuffer cmd = cmds[i];
                                cmd.Start();
                                
-                               blitDest.SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.TransferDstOptimal);
-                               blitSource.SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.TransferSrcOptimal);
+                               blitDest.SetLayout (cmd, VkImageAspectFlags.Color,
+                                       VkImageLayout.Undefined, VkImageLayout.TransferDstOptimal,
+                                       VkPipelineStageFlags.BottomOfPipe, VkPipelineStageFlags.Transfer);
+
+                               blitSource.SetLayout (cmd, VkImageAspectFlags.Color,
+                                       VkImageLayout.ColorAttachmentOptimal, VkImageLayout.TransferSrcOptimal,
+                                       VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.Transfer);
 
                                blitSource.BlitTo (cmd, blitDest, VkFilter.Nearest);
 
-                               blitDest.SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.PresentSrcKHR);
-                               blitSource.SetLayout (cmd, VkImageAspectFlags.Color, VkImageLayout.ColorAttachmentOptimal);
+                               blitDest.SetLayout (cmd, VkImageAspectFlags.Color,
+                                       VkImageLayout.TransferDstOptimal, VkImageLayout.PresentSrcKHR,
+                                       VkPipelineStageFlags.Transfer, VkPipelineStageFlags.BottomOfPipe);
+
+                               blitSource.SetLayout (cmd, VkImageAspectFlags.Color,
+                                       VkImageLayout.TransferSrcOptimal, VkImageLayout.ColorAttachmentOptimal,
+                                       VkPipelineStageFlags.Transfer, VkPipelineStageFlags.ColorAttachmentOutput);
 
                                cmd.End ();
                        }
                }
+               public void WaitAndResetDrawFence () {
+                       drawFence.Wait ();
+                       drawFence.Reset ();
+               }
                /// <summary>
                /// Main render method called each frame. get next swapchain image, process resize if needed, submit and present to the presentQueue.
                /// Wait QueueIdle after presenting.
@@ -135,9 +154,7 @@ namespace vkvg {
 
                        if (cmds[idx] == null)
                                return;
-
-                       drawFence.Wait ();
-                       drawFence.Reset ();
+                       WaitAndResetDrawFence();
 
                        presentQueue.Submit (cmds[idx], swapChain.presentComplete, drawComplete[idx], drawFence);
                        presentQueue.Present (swapChain, drawComplete[idx]);                    
index e23c7afa5b668c7b3c9f123de78d0c66fcc1b37a..5825661a9c5e0c63f4bf72665b065dc88d2f3337 100644 (file)
@@ -1044,6 +1044,14 @@ namespace Crow
                                                processDrawing (ctx);
                                }else
                                        processDrawing (ctx);
+
+#if VKVG
+                               if (IsDirty) {
+                                       IsDirty = false;
+                                       vkCtx.render ();
+                               }
+#endif
+                               
                        } finally {
 
                                PerformanceMeasure.End (PerformanceMeasure.Kind.Update);
@@ -1128,7 +1136,13 @@ namespace Crow
                /// <summary>Clipping Rectangles drive the drawing process. For compositing, each object under a clip rectangle should be
                /// repainted. If it contains also clip rectangles, its cache will be update, or if not cached a full redraw will take place</summary>
                protected virtual void processDrawing(Context ctx){
-
+                       /*ctx.Rectangle (0,0,100,100);
+                       ctx.SetSource (1,0,0,1);
+                       ctx.Fill();
+                       return;*/
+                       
+                       //ctx.Flush();
+                       //surf.WriteToPng ("/home/jp/test.png");*/
                        DbgLogger.StartEvent (DbgEvtType.ProcessDrawing);
 
                        if (DragImage != null)
@@ -1137,10 +1151,14 @@ namespace Crow
                        if (!clipping.IsEmpty) {
                                PerformanceMeasure.Begin (PerformanceMeasure.Kind.Drawing);                             
 
+#if VKVG                               
+                               clear (ctx);
+#else
                                ctx.PushGroup ();
 
                                if (SolidBackground)
                                        clear (ctx);
+#endif
                                
                                for (int i = GraphicTree.Count -1; i >= 0 ; i--){
                                        Widget p = GraphicTree[i];
@@ -1180,7 +1198,8 @@ namespace Crow
 #endif
 
 #if VKVG
-                               vkCtx.render ();
+                               //vkCtx.render ();
+                               vkCtx.WaitIdle();
 #else
                                ctx.PopGroupToSource ();
 
@@ -1198,10 +1217,6 @@ namespace Crow
                                IsDirty = true;
                        }
 
-#if VKVG
-                               vkCtx.render ();
-#endif
-
                        drawTextCursor (ctx);
 
                        debugHighlightFocus (ctx);
@@ -1383,6 +1398,7 @@ namespace Crow
                                clientRectangle = bounds;
 
 #if VKVG
+                               vkCtx.WaitIdle();
                                vkCtx.blitSource?.Dispose ();
                                surf?.Dispose ();
                                surf = new Surface (vkvgDevice, clientRectangle.Width, clientRectangle.Height);                         
index 8ef0496052d36311b689d8ef079a420e94c4a2ce..917e7dfc53c095f66dceb2d91bb99650def8513a 100644 (file)
@@ -11,7 +11,7 @@
                <CrowStbSharp>true</CrowStbSharp>
                <CrowDebugLogEnabled>false</CrowDebugLogEnabled>
                <CrowDebugStatsEnabled>true</CrowDebugStatsEnabled>
-               <CrowDesignModeEnabled>true</CrowDesignModeEnabled>
+               <CrowDesignModeEnabled>false</CrowDesignModeEnabled>
                <CrowVkvgBackend>true</CrowVkvgBackend>
                <GlfwSharpVersion>0.2.12-beta</GlfwSharpVersion>
        </PropertyGroup>
index 7e70491601546addd49628d46c60aac03faea6b5..11eed07e1f0956eeacd0e4365ace1a5a5746b21a 100644 (file)
@@ -38,16 +38,16 @@ namespace Samples
                        //testFiles = new string [] { @"Interfaces/Stack/StretchedInFit4.crow" };
                        //testFiles = new string [] { @"Interfaces/TemplatedGroup/1.crow" };
                        //testFiles = new string [] { @"Interfaces/Divers/colorPicker2.crow" };
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
+                       //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
+                       /*testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedContainer", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedGroup", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Wrapper", "*.crow")).ToArray ();
                        testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray ();
-                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/DragAndDrop", "*.crow")).ToArray ();
+                       testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/DragAndDrop", "*.crow")).ToArray ();*/
                        //testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Experimental", "*.crow")).ToArray ();
 
                        Load (testFiles [idx]).DataSource = this;