From 04d94de392b6e5ca4f82acc233df7b3f97abca36 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bruyère Date: Fri, 5 Apr 2019 14:13:20 +0200 Subject: Activable pattern wip --- vke/src/ShaderInfo.cs | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 vke/src/ShaderInfo.cs (limited to 'vke/src/ShaderInfo.cs') diff --git a/vke/src/ShaderInfo.cs b/vke/src/ShaderInfo.cs new file mode 100644 index 0000000..f346195 --- /dev/null +++ b/vke/src/ShaderInfo.cs @@ -0,0 +1,69 @@ +// +// FrameBuffer.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2019 jp +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Vulkan; +using static Vulkan.VulkanNative; + +namespace VKE { + public class ShaderInfo : IDisposable { + public VkShaderStageFlags StageFlags; + public string SpirvPath; + public FixedUtf8String EntryPoint; + + public ShaderInfo (VkShaderStageFlags _stageFlags, string _spirvPath, string _entryPoint = "main") { + StageFlags = _stageFlags; + SpirvPath = _spirvPath; + EntryPoint = new FixedUtf8String (_entryPoint); + } + + public VkPipelineShaderStageCreateInfo GetStageCreateInfo (Device dev) { + return new VkPipelineShaderStageCreateInfo { + sType = VkStructureType.PipelineShaderStageCreateInfo, + stage = StageFlags, + pName = EntryPoint, + module = dev.LoadSPIRVShader (SpirvPath), + }; + } + + #region IDisposable Support + private bool disposedValue = false; // Pour détecter les appels redondants + + protected virtual void Dispose (bool disposing) { + if (!disposedValue) { + if (disposing) + EntryPoint.Dispose (); + + disposedValue = true; + } + } + public void Dispose () { + Dispose (true); + } + #endregion + } +} -- cgit v1.3.1-4-g156e