diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/VkChess.cs | 76 | ||||
| -rw-r--r-- | src/deferredPbrRenderer.cs | 11 |
2 files changed, 45 insertions, 42 deletions
diff --git a/src/VkChess.cs b/src/VkChess.cs index 3264f60..5ac5da8 100644 --- a/src/VkChess.cs +++ b/src/VkChess.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -37,16 +37,17 @@ namespace vkChess System.Runtime.Loader.AssemblyLoadContext.Default.ResolvingUnmanagedDll+=resolveUnmanaged; } #endif + VkChess(){} static void Main (string [] args) { Instance.VALIDATION = true; //Instance.RENDER_DOC_CAPTURE = true; //SwapChain.PREFERED_FORMAT = VkFormat.B8g8r8a8Unorm; DeferredPbrRenderer.NUM_SAMPLES = VkSampleCountFlags.SampleCount1; DeferredPbrRenderer.MAX_MATERIAL_COUNT = 5; - DeferredPbrRenderer.MRT_FORMAT = VkFormat.R32g32b32a32Sfloat; - DeferredPbrRenderer.HDR_FORMAT = VkFormat.R32g32b32a32Sfloat; - PbrModelTexArray.TEXTURE_DIM = 1024; - ShadowMapRenderer.SHADOWMAP_SIZE = 1024; + DeferredPbrRenderer.MRT_FORMAT = VkFormat.R16g16b16a16Sfloat; + DeferredPbrRenderer.HDR_FORMAT = VkFormat.R16g16b16a16Sfloat; + PbrModelTexArray.TEXTURE_DIM = 256; + ShadowMapRenderer.SHADOWMAP_SIZE = 512; using (VkChess app = new VkChess ()) app.Run (); @@ -190,7 +191,7 @@ namespace vkChess #else renderer.recordDraw (cmds [i], i, instanceBuff, instancedCmds?.ToArray ()); - this.recordUICmd (cmds[i], i); + recordUICmd (cmds[i], i); #endif cmds [i].End (); } @@ -411,9 +412,10 @@ namespace vkChess break; case Glfw.Key.F2: /*loadWindow (@"ui/board.crow", this); - NotifyValueChanged ("board", board);*/ + */ //loadWindow (@"ui/scene.crow", this.renderer.model); - loadWindow (@"ui/debug.crow", this); + loadWindow (@"ui/board.crow", this); + NotifyValueChanged ("board", board); break; case Glfw.Key.F3: checkBoardIntegrity (); @@ -492,6 +494,9 @@ namespace vkChess Close (); } void onUndoClick (object sender, MouseButtonEventArgs e) { + undo(); + } + void undo() { lock (movesMutex) { bool hintIsEnabled = EnableHint; EnableHint = false; @@ -507,35 +512,27 @@ namespace vkChess EnableHint = hintIsEnabled; } } - public string StockfishDirectory { - get { - try - { - return System.IO.Path.GetDirectoryName(StockfishPath); - } - catch - { - return Directory.GetCurrentDirectory(); - } - - } - } void onFindStockfishPath (object sender, MouseButtonEventArgs e) { - /*loadIMLFragment (@" - <FileDialog Caption='Select SDK Folder' CurrentDirectory='/home' - ShowFiles='true' ShowHidden='true' OkClicked='onSelectStockfishPath'/> - ",this);*/ + string stockfishDir = string.IsNullOrEmpty(StockfishPath) ? + Directory.GetCurrentDirectory() : System.IO.Path.GetDirectoryName(StockfishPath); + string stockfishExe = string.IsNullOrEmpty(StockfishPath) ? + "" : System.IO.Path.GetFileName(StockfishPath); - loadIMLFragment (@" - <FileDialog/> - ",this); - } - public void onSelectStockfishPath (object sender, EventArgs e) - { - StockfishPath = (sender as FileDialog).SelectedFileFullPath; + loadIMLFragment<FileDialog> (@" + <FileDialog Caption='Select SDK Folder' CurrentDirectory='" + stockfishDir + @"' SelectedFile='" + stockfishExe + @"' + ShowFiles='true' ShowHidden='true'/>",this) + .OkClicked += (sender, e) => { + StockfishPath = (sender as FileDialog).SelectedFileFullPath; + }; } + public CommandGroup Commands => new CommandGroup ( + new Command (()=>loadWindow ("ui/newGame.crow", this)) {Caption = "New Game"}, + new Command (()=>loadWindow ("ui/main.crow", this)) {Caption = "Options"}, + new Command (()=>undo()) {Caption = "Undo"}, + new Command (()=>Close()) {Caption = "Quit"} + ); void onNewGameClick (object sender, MouseButtonEventArgs e) { loadWindow ("ui/newGame.crow", this); } @@ -1662,7 +1659,7 @@ namespace vkChess new BezierPath ( pCaptured.Position, pCapLastPos, Vector3.UnitZ),animationSteps)); - + NotifyValueChanged ("board", board); } void replaySilently () { string [] moves = StockfishMoves.ToArray (); @@ -1676,6 +1673,7 @@ namespace vkChess void startTurn () { syncStockfish (); + NotifyValueChanged ("board", board); bool kingIsSafe = checkKingIsSafe (); if (getLegalMoves ().Length == 0) { @@ -1693,17 +1691,19 @@ namespace vkChess // BlacksAreAI = false; //} - if (playerIsAi (CurrentPlayer)) - sendToStockfish ("go movetime " + AISearchTime.ToString()); - else if (enableHint) + if (playerIsAi (CurrentPlayer)) { + if (AISearchTime > 0) + sendToStockfish ("go movetime " + AISearchTime.ToString()); + else + sendToStockfish ("go depth 1"); + }else if (enableHint) sendToStockfish ("go infinite"); } void switchPlayer () { BestMove = null; CurrentState = GameState.Play; - CurrentPlayer = Opponent; - + CurrentPlayer = Opponent; startTurn (); } diff --git a/src/deferredPbrRenderer.cs b/src/deferredPbrRenderer.cs index ac9dfc9..1337089 100644 --- a/src/deferredPbrRenderer.cs +++ b/src/deferredPbrRenderer.cs @@ -79,7 +79,7 @@ namespace vkChess } }; - public DescriptorSetWrites UiImageUpdate => new DescriptorSetWrites (dsMain, descLayoutMain.Bindings [8]); + //public DescriptorSetWrites UiImageUpdate => new DescriptorSetWrites (dsMain, descLayoutMain.Bindings [8]); const float lightMoveSpeed = 0.1f; @@ -210,8 +210,9 @@ namespace vkChess new VkDescriptorSetLayoutBinding (4, VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer),//lights new VkDescriptorSetLayoutBinding (5, VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer),//materials new VkDescriptorSetLayoutBinding (6, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),//shadow map - new VkDescriptorSetLayoutBinding (7, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),//texture array - new VkDescriptorSetLayoutBinding (8, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler));//uiImage + new VkDescriptorSetLayoutBinding (7, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)//texture array + //new VkDescriptorSetLayoutBinding (8, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler) + );//uiImage descLayoutGBuff = new DescriptorSetLayout (dev, new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.InputAttachment),//color + roughness @@ -224,7 +225,9 @@ namespace vkChess descLayoutGBuff.SetName ("GBuff"); using (GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault (VkPrimitiveTopology.TriangleList, NUM_SAMPLES)) { - cfg.rasterizationState.cullMode = VkCullModeFlags.Back; + + cfg.rasterizationState.cullMode = VkCullModeFlags.None; + if (NUM_SAMPLES != VkSampleCountFlags.SampleCount1) { cfg.multisampleState.sampleShadingEnable = true; cfg.multisampleState.minSampleShading = 0.5f; |