public void CreateComputePipeline() { var descriptorSetLayoutCreateInfo = new DescriptorSetLayoutCreateInfo( new DescriptorSetLayoutBinding(0, DescriptorType.StorageBuffer, 1, ShaderStages.Compute), new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStages.Compute)); using (DescriptorSetLayout descriptorSetLayout = Device.CreateDescriptorSetLayout(descriptorSetLayoutCreateInfo)) using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout(new PipelineLayoutCreateInfo(new[] { descriptorSetLayout }))) using (ShaderModule shader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.comp.spv")))) using (PipelineCache cache = Device.CreatePipelineCache()) { var pipelineCreateInfo = new ComputePipelineCreateInfo( new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"), pipelineLayout); using (Device.CreateComputePipelines(new[] { pipelineCreateInfo })[0]) { } using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, cache)[0]) { } using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, allocator: CustomAllocator)[0]) { } using (Device.CreateComputePipelines(new[] { pipelineCreateInfo }, cache, CustomAllocator)[0]) { } using (Device.CreateComputePipeline(pipelineCreateInfo)) { } using (Device.CreateComputePipeline(pipelineCreateInfo, allocator: CustomAllocator)) { } using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { } using (Device.CreateComputePipeline(pipelineCreateInfo, cache, CustomAllocator)) { } } }
public void GetData() { var descriptorSetLayoutCreateInfo = new DescriptorSetLayoutCreateInfo( new DescriptorSetLayoutBinding(0, DescriptorType.StorageBuffer, 1, ShaderStages.Compute), new DescriptorSetLayoutBinding(1, DescriptorType.StorageBuffer, 1, ShaderStages.Compute)); using (DescriptorSetLayout descriptorSetLayout = Device.CreateDescriptorSetLayout(descriptorSetLayoutCreateInfo)) using (PipelineLayout pipelineLayout = Device.CreatePipelineLayout(new PipelineLayoutCreateInfo(new[] { descriptorSetLayout }))) using (ShaderModule shader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.comp.spv")))) { var pipelineCreateInfo = new ComputePipelineCreateInfo( new PipelineShaderStageCreateInfo(ShaderStages.Compute, shader, "main"), pipelineLayout); byte[] cacheBytes; // Populate cache. using (PipelineCache cache = Device.CreatePipelineCache()) { using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { } cacheBytes = cache.GetData(); } Assert.False(cacheBytes.All(x => x == 0)); // Recreate pipeline from cache. using (PipelineCache cache = Device.CreatePipelineCache(new PipelineCacheCreateInfo(cacheBytes))) { using (Device.CreateComputePipeline(pipelineCreateInfo, cache)) { } } } }
public DeferredPbrRenderer(Queue gQueue, string cubemapPath, uint width, uint height, float nearPlane, float farPlane) { this.gQueue = gQueue; this.dev = gQueue.Dev; this.cubemapPath = cubemapPath; this.width = width; this.height = height; DrawComplete = dev.CreateSemaphore(); pipelineCache = new PipelineCache(dev); descriptorPool = new DescriptorPool(dev, 5, new VkDescriptorPoolSize(VkDescriptorType.UniformBuffer, 3), new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler, 6), new VkDescriptorPoolSize(VkDescriptorType.InputAttachment, 5), new VkDescriptorPoolSize(VkDescriptorType.StorageImage, 4) ); uboMatrices = new HostBuffer(dev, VkBufferUsageFlags.UniformBuffer, matrices, true); uboLights = new HostBuffer <Light> (dev, VkBufferUsageFlags.UniformBuffer, lights, true); #if WITH_SHADOWS shadowMapRenderer = new ShadowMapRenderer(gQueue, this); #endif init(nearPlane, farPlane); }
public Pipeline(ITreeBuilder treeBuilder) { _treeBuilder = treeBuilder; _buildCache = new PipelineCache <IBuild>(); _branchCache = new PipelineCache <IBranch>(); _definitionCache = new PipelineCache <IBuildDefinition>(); _pipelineNotifier = new PipelineNotifier(); }
public void MergePipelines() { using (PipelineCache dstCache = Device.CreatePipelineCache()) using (PipelineCache srcCache = Device.CreatePipelineCache()) { dstCache.MergeCache(srcCache); dstCache.MergeCaches(srcCache); } }
public Pipeline(ITreeBuilder treeBuilder, IConfiguration configuration) { _treeBuilder = treeBuilder; _configuration = configuration; _buildCache = new PipelineCache <IBuild>(); _branchCache = new PipelineCache <IBranch>(); _definitionCache = new PipelineCache <IBuildDefinition>(); _pipelineNotifier = new PipelineNotifier(); }
public ShaderManager(DescriptorSetPoolManager myDescriptorPool) { this.DescriptorPool = myDescriptorPool; if (myPipelineCache != null) { throw new Exception("Pipeline cache was initialized twice without prior instance being destroyed."); } myPipelineCache = VulkanRenderer.SelectedLogicalDevice.CreatePipelineCache(new PipelineCacheCreateInfo()); LoadShaderFiles(); }
public void AddShouldReturnAddWhenNewItemWasAdded() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); // Act var actual = sut.AddOrReplace(key, "hello world"); // Assert Assert.Equal(CacheAction.Add, actual); }
public void ContainsShouldReturnFalseWhenItemIsNotContained() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); // Act var actual = sut.Contains(key); // Assert Assert.False(actual); }
public void ContainsShouldDoNothingWhenItemIsNotContained() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); // Act var ex = Record.Exception(() => sut.Remove(key)); // Assert Assert.Null(ex); }
public Pipeline(ITreeBuilder treeBuilder, IConfiguration configuration, IUserIdentityList userIdentityList) { _treeBuilder = treeBuilder; _configuration = configuration; _userIdentityList = userIdentityList; _buildCache = new PipelineCache <IBuild>(); _branchCache = new PipelineCache <IBranch>(); _definitionCache = new PipelineCache <IBuildDefinition>(); _notificationFactory = new NotificationFactory(configuration, userIdentityList); _pipelineNotifier = new PipelineNotifier(); _currentSearch = new EmptySearch(); }
public StartableEndpoint(SettingsHolder settings, IBuilder builder, FeatureActivator featureActivator, PipelineConfiguration pipelineConfiguration, IEventAggregator eventAggregator, TransportInfrastructure transportInfrastructure, CriticalError criticalError) { this.criticalError = criticalError; this.settings = settings; this.builder = builder; this.featureActivator = featureActivator; this.pipelineConfiguration = pipelineConfiguration; this.eventAggregator = eventAggregator; this.transportInfrastructure = transportInfrastructure; pipelineCache = new PipelineCache(builder, settings); messageSession = new MessageSession(new RootContext(builder, pipelineCache, eventAggregator)); }
public void AddShouldReturnUpdateWhenItemWasAlreadyAddedAndModified() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); sut.AddOrReplace(key, "hello world"); // Act var actual = sut.AddOrReplace(key, "hello world 123"); // Assert Assert.Equal(CacheAction.Update, actual); }
public void ContainsShouldReturnTrueWhenItemIsContained() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); sut.AddOrReplace(key, "hello world"); // Act var actual = sut.Contains(key); // Assert Assert.True(actual); }
public unsafe byte[] GetPipelineCacheData(PipelineCache pipelineCache) { PointerSize count = 0; GetPipelineCacheData(pipelineCache, ref count, IntPtr.Zero); var result = new byte[count]; if (count > 0) { fixed (byte* resultPtr = &result[0]) GetPipelineCacheData(pipelineCache, ref count, new IntPtr(resultPtr)); } return result; }
public void ClearShouldClearCacheContent() { // Arrange var sut = new PipelineCache <string>(); sut.AddOrReplace("1", "1", "test"); sut.AddOrReplace("1", "2", "test"); sut.AddOrReplace("1", "3", "test"); // Act sut.Clear(); // Assert Assert.Empty(sut.ContentCopy()); }
public void ValuesShouldOnlyReturnMatchingValues() { // Arrange var sut = new PipelineCache <string>(); sut.AddOrReplace("1", "1", "test"); sut.AddOrReplace("2", "1", "wrong"); sut.AddOrReplace("1", "2", "test"); // Act var actual = sut.Values("1"); // Assert Assert.All(actual, x => Assert.Equal("test", x)); }
public void AddShouldReplaceExistingItem() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); sut.AddOrReplace(key, "hello world"); // Act sut.AddOrReplace(key, "test"); // Assert var content = sut.ContentCopy().ToList(); Assert.Collection(content, str => Assert.Equal("test", str)); }
public unsafe byte[] GetPipelineCacheData(PipelineCache pipelineCache) { PointerSize count = 0; GetPipelineCacheData(pipelineCache, ref count, IntPtr.Zero); var result = new byte[count]; if (count > 0) { fixed(byte *resultPtr = &result[0]) GetPipelineCacheData(pipelineCache, ref count, new IntPtr(resultPtr)); } return(result); }
public void RemoveShouldRemoveItemFromCache() { // Arrange var sut = new PipelineCache <string>(); var key = new CacheKey(1, 2); sut.AddOrReplace(key, "hello world"); // Act var before = sut.Contains(key); sut.Remove(key); var after = sut.Contains(key); // Assert Assert.True(before); Assert.False(after); }
public DeferredPbrRenderer(Device dev, SwapChain swapChain, PresentQueue presentQueue, string cubemapPath, float nearPlane, float farPlane) { this.dev = dev; this.swapChain = swapChain; this.presentQueue = presentQueue; pipelineCache = new PipelineCache(dev); descriptorPool = new DescriptorPool(dev, 3, new VkDescriptorPoolSize(VkDescriptorType.UniformBuffer, 3), new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler, 6), new VkDescriptorPoolSize(VkDescriptorType.InputAttachment, 5) ); uboMatrices = new HostBuffer(dev, VkBufferUsageFlags.UniformBuffer, matrices, true); uboLights = new HostBuffer <Light> (dev, VkBufferUsageFlags.UniformBuffer, lights, true); shadowMapRenderer = new ShadowMapRenderer(dev, this, 32); init(nearPlane, farPlane, cubemapPath); }
public void ContentCopyShouldReturnCopyOfStoredElements() { // Arrange var sut = new PipelineCache <string>(); sut.AddOrReplace("1", "1", "test1"); sut.AddOrReplace("1", "2", "test2"); sut.AddOrReplace("1", "3", "test3"); // Act var actual = sut.ContentCopy(); // Assert var expectedSubset = new HashSet <string> { "test1", "test2", "test3" }; var actualSet = actual.ToHashSet(); Assert.Subset(expectedSubset, actualSet); }
public void RemoveValueShouldOnlyRemoveMatchingEntries() { // Arrange var sut = new PipelineCache <string>(); sut.AddOrReplace("1", "1", "test1"); sut.AddOrReplace("1", "2", "test2"); sut.AddOrReplace("1", "3", "test3"); // Act sut.RemoveValue("test2"); // Assert var expectedSubset = new HashSet <string> { "test1", "test3" }; var actualSet = sut.ContentCopy().ToHashSet(); Assert.Subset(expectedSubset, actualSet); }
internal static unsafe extern Result vkMergePipelineCaches(Device device, PipelineCache dstCache, UInt32 srcCacheCount, IntPtr pSrcCaches);
internal static unsafe extern void vkDestroyPipelineCache(Device device, PipelineCache pipelineCache, AllocationCallbacks* allocator);
internal static unsafe extern Result vkCreatePipelineCache(Device device, PipelineCacheCreateInfo* createInfo, AllocationCallbacks* allocator, PipelineCache* pipelineCache);
internal static unsafe extern Result vkGetPipelineCacheData(Device device, PipelineCache pipelineCache, PointerSize* dataSize, IntPtr data);
/// <summary>To be documented.</summary> public static unsafe Result CreateRayTracingPipelines(this NVRayTracing thisApi, [Count(Count = 0)] Device device, [Count(Count = 0)] PipelineCache pipelineCache, [Count(Count = 0)] uint createInfoCount, [Count(Parameter = "createInfoCount"), Flow(FlowDirection.In)] RayTracingPipelineCreateInfoNV *pCreateInfos, [Count(Count = 0), Flow(FlowDirection.In)] ReadOnlySpan <AllocationCallbacks> pAllocator, [Count(Parameter = "createInfoCount"), Flow(FlowDirection.Out)] Pipeline *pPipelines) { // SpanOverloader return(thisApi.CreateRayTracingPipelines(device, pipelineCache, createInfoCount, pCreateInfos, in pAllocator.GetPinnableReference(), pPipelines)); }
public unsafe void GetPipelineCacheData(PipelineCache pipelineCache, ref PointerSize dataSize, IntPtr data) { fixed (PointerSize* __dataSize__ = &dataSize) { vkGetPipelineCacheData(this, pipelineCache, __dataSize__, data).CheckError(); } }
/// <summary>To be documented.</summary> public static unsafe Result CreateRayTracingPipelines(this NVRayTracing thisApi, [Count(Count = 0)] Device device, [Count(Count = 0)] PipelineCache pipelineCache, [Count(Count = 0)] uint createInfoCount, [Count(Computed = "createInfoCount"), Flow(FlowDirection.In)] RayTracingPipelineCreateInfoNV *pCreateInfos, [Count(Count = 0), Flow(FlowDirection.In)] AllocationCallbacks *pAllocator, [Count(Computed = "createInfoCount"), Flow(FlowDirection.Out)] Span <Pipeline> pPipelines) { // SpanOverloader return(thisApi.CreateRayTracingPipelines(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, out pPipelines.GetPinnableReference())); }
public void CreateGraphicsPipeline() { var attachment = new AttachmentDescription { Samples = SampleCounts.Count1, Format = Format.B8G8R8A8UNorm, InitialLayout = ImageLayout.Undefined, FinalLayout = ImageLayout.PresentSrcKhr, LoadOp = AttachmentLoadOp.Clear, StoreOp = AttachmentStoreOp.Store, StencilLoadOp = AttachmentLoadOp.DontCare, StencilStoreOp = AttachmentStoreOp.DontCare }; var subpass = new SubpassDescription(new[] { new AttachmentReference(0, ImageLayout.ColorAttachmentOptimal) }); var createInfo = new RenderPassCreateInfo(new[] { subpass }, new[] { attachment }); using (PipelineCache cache = Device.CreatePipelineCache()) using (RenderPass renderPass = Device.CreateRenderPass(createInfo)) using (PipelineLayout layout = Device.CreatePipelineLayout()) using (ShaderModule vertexShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.vert.spv")))) using (ShaderModule fragmentShader = Device.CreateShaderModule(new ShaderModuleCreateInfo(ReadAllBytes("Shader.frag.spv")))) { var shaderStageCreateInfos = new[] { new PipelineShaderStageCreateInfo(ShaderStages.Vertex, vertexShader, "main"), new PipelineShaderStageCreateInfo(ShaderStages.Fragment, fragmentShader, "main") }; var vertexInputStateCreateInfo = new PipelineVertexInputStateCreateInfo(); var inputAssemblyStateCreateInfo = new PipelineInputAssemblyStateCreateInfo(PrimitiveTopology.TriangleList); var viewportStateCreateInfo = new PipelineViewportStateCreateInfo( new Viewport(0, 0, 32, 32), new Rect2D(0, 0, 32, 32)); var rasterizationStateCreateInfo = new PipelineRasterizationStateCreateInfo { PolygonMode = PolygonMode.Fill, CullMode = CullModes.Back, FrontFace = FrontFace.CounterClockwise, LineWidth = 1.0f }; var tessellationStateCreateInfo = new PipelineTessellationStateCreateInfo(4); var multisampleStateCreateInfo = new PipelineMultisampleStateCreateInfo { RasterizationSamples = SampleCounts.Count1, MinSampleShading = 1.0f }; var colorBlendAttachmentState = new PipelineColorBlendAttachmentState { SrcColorBlendFactor = BlendFactor.One, DstColorBlendFactor = BlendFactor.Zero, ColorBlendOp = BlendOp.Add, SrcAlphaBlendFactor = BlendFactor.One, DstAlphaBlendFactor = BlendFactor.Zero, AlphaBlendOp = BlendOp.Add, ColorWriteMask = ColorComponents.All }; var depthStencilStateCreateInfo = new PipelineDepthStencilStateCreateInfo(); var colorBlendStateCreateInfo = new PipelineColorBlendStateCreateInfo( new[] { colorBlendAttachmentState }); var dynamicStateCreateInfo = new PipelineDynamicStateCreateInfo(DynamicState.LineWidth); var pipelineCreateInfo = new GraphicsPipelineCreateInfo( layout, renderPass, 0, shaderStageCreateInfos, inputAssemblyStateCreateInfo, vertexInputStateCreateInfo, rasterizationStateCreateInfo, tessellationStateCreateInfo, viewportStateCreateInfo, multisampleStateCreateInfo, depthStencilStateCreateInfo, colorBlendStateCreateInfo, dynamicStateCreateInfo); using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo })[0]) { } using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, cache)[0]) { } using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, allocator: CustomAllocator)[0]) { } using (Device.CreateGraphicsPipelines(new[] { pipelineCreateInfo }, cache, CustomAllocator)[0]) { } using (Device.CreateGraphicsPipeline(pipelineCreateInfo)) { } using (Device.CreateGraphicsPipeline(pipelineCreateInfo, allocator: CustomAllocator)) { } using (Device.CreateGraphicsPipeline(pipelineCreateInfo, cache)) { } using (Device.CreateGraphicsPipeline(pipelineCreateInfo, cache, CustomAllocator)) { } } }
internal static unsafe extern Result vkMergePipelineCaches(Device device, PipelineCache destinationCache, uint sourceCacheCount, PipelineCache* srcCaches);
public unsafe void DestroyPipelineCache(PipelineCache pipelineCache, AllocationCallbacks* allocator = null) { vkDestroyPipelineCache(this, pipelineCache, allocator); }
public unsafe void MergePipelineCaches(PipelineCache destinationCache, uint sourceCacheCount, PipelineCache srcCaches) { vkMergePipelineCaches(this, destinationCache, sourceCacheCount, &srcCaches).CheckError(); }
internal static unsafe extern Result vkGetPipelineCacheData(Device device, PipelineCache pipelineCache, out UIntPtr *DataSize, out IntPtr Data);
internal static unsafe extern void vkDestroyPipelineCache(Device device, PipelineCache pipelineCache, AllocationCallbacks *Allocator);
public abstract Result CreateRayTracingPipelines([Count(Count = 0)] Device device, [Count(Count = 0)] PipelineCache pipelineCache, [Count(Count = 0)] uint createInfoCount, [Count(Computed = "createInfoCount"), Flow(FlowDirection.In)] ref RayTracingPipelineCreateInfoNV pCreateInfos, [Count(Count = 0), Flow(FlowDirection.In)] ref AllocationCallbacks pAllocator, [Count(Computed = "createInfoCount"), Flow(FlowDirection.Out)] out Pipeline pPipelines);
public abstract unsafe Result CreateRayTracingPipelines([Count(Count = 0)] Device device, [Count(Count = 0)] PipelineCache pipelineCache, [Count(Count = 0)] uint createInfoCount, [Count(Computed = "createInfoCount"), Flow(FlowDirection.In)] RayTracingPipelineCreateInfoNV *pCreateInfos, [Count(Count = 0), Flow(FlowDirection.In)] AllocationCallbacks *pAllocator, [Count(Computed = "createInfoCount"), Flow(FlowDirection.Out)] Pipeline *pPipelines);
public unsafe Pipeline CreateGraphicsPipelines(PipelineCache pipelineCache, uint createInfoCount, GraphicsPipelineCreateInfo* createInfos, AllocationCallbacks* allocator = null) { Pipeline pipelines; vkCreateGraphicsPipelines(this, pipelineCache, createInfoCount, createInfos, allocator, &pipelines).CheckError(); return pipelines; }
internal static unsafe extern Result vkCreateComputePipelines(Device device, PipelineCache pipelineCache, UInt32 createInfoCount, ComputePipelineCreateInfo *CreateInfos, AllocationCallbacks *Allocator, out IntPtr pPipelines);
internal static unsafe extern Result vkCreateGraphicsPipelines(Device device, PipelineCache pipelineCache, uint createInfoCount, GraphicsPipelineCreateInfo* createInfos, AllocationCallbacks* allocator, Pipeline* pipelines);