Ejemplo n.º 1
0
        Program()
        {
            //UpdateFrequency = 20;

            camera.SetPosition(0, 0, 5);

            vkvgDev = new vkvg.Device(instance.Handle, phy.Handle, dev.VkDev.Handle, presentQueue.qFamIndex,
                                      vkvg.SampleCount.Sample_4, presentQueue.index);

            initUISurface();

            pbrPipeline = new PBRPipeline(presentQueue,
                                          new RenderPass(dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat(), samples), uiImage);

            initUIPipeline();

            modelAABB = pbrPipeline.model.DefaultScene.AABB;

            //camera.Model = Matrix4x4.CreateScale (1f/ Math.Max (Math.Max (modelAABB.max.X, modelAABB.max.Y), modelAABB.max.Z));

#if PIPELINE_STATS
            statPool = new PipelineStatisticsQueryPool(dev,
                                                       VkQueryPipelineStatisticFlags.InputAssemblyVertices |
                                                       VkQueryPipelineStatisticFlags.InputAssemblyPrimitives |
                                                       VkQueryPipelineStatisticFlags.ClippingInvocations |
                                                       VkQueryPipelineStatisticFlags.ClippingPrimitives |
                                                       VkQueryPipelineStatisticFlags.FragmentShaderInvocations);

            timestampQPool = new TimestampQueryPool(dev);
#endif
        }
Ejemplo n.º 2
0
        protected override void initVulkan()
        {
            base.initVulkan();

#if DEBUG
            dbgRepport = new DebugReport(instance,
                                         VkDebugReportFlagsEXT.ErrorEXT
                                         | VkDebugReportFlagsEXT.DebugEXT
                                         | VkDebugReportFlagsEXT.WarningEXT
                                         | VkDebugReportFlagsEXT.PerformanceWarningEXT
                                         );
#endif

            camera = new Camera(Utils.DegreesToRadians(45f), 1f, 0.1f, 16f);
            camera.SetPosition(0, 0, 2);

            renderer = new DeferredPbrRenderer(dev, swapChain, presentQueue, cubemapPathes[2], camera.NearPlane, camera.FarPlane);
            renderer.LoadModel(transferQ, modelPathes[curModelIndex]);
            camera.Model = Matrix4x4.CreateScale(1f / Math.Max(Math.Max(renderer.modelAABB.Width, renderer.modelAABB.Height), renderer.modelAABB.Depth));

            statPool = new PipelineStatisticsQueryPool(dev,
                                                       VkQueryPipelineStatisticFlags.InputAssemblyVertices |
                                                       VkQueryPipelineStatisticFlags.InputAssemblyPrimitives |
                                                       VkQueryPipelineStatisticFlags.ClippingInvocations |
                                                       VkQueryPipelineStatisticFlags.ClippingPrimitives |
                                                       VkQueryPipelineStatisticFlags.FragmentShaderInvocations);

            timestampQPool = new TimestampQueryPool(dev);

            init_crow_commands();

            crow.Load("#deferred.menu.crow").DataSource = this;
        }
Ejemplo n.º 3
0
        Program() : base(true)
        {
            camera.Model = Matrix4x4.CreateRotationX(Utils.DegreesToRadians(-90)) * Matrix4x4.CreateRotationY(Utils.DegreesToRadians(180));
            camera.SetRotation(-0.1f, -0.4f);
            camera.SetPosition(0, 0, -3);

            init();

#if DEBUG
            statPool = new PipelineStatisticsQueryPool(dev,
                                                       VkQueryPipelineStatisticFlags.InputAssemblyVertices |
                                                       VkQueryPipelineStatisticFlags.InputAssemblyPrimitives |
                                                       VkQueryPipelineStatisticFlags.ClippingInvocations |
                                                       VkQueryPipelineStatisticFlags.ClippingPrimitives |
                                                       VkQueryPipelineStatisticFlags.FragmentShaderInvocations);

            timestampQPool = new TimestampQueryPool(dev);
#endif
        }
Ejemplo n.º 4
0
        void init(VkSampleCountFlags samples = VkSampleCountFlags.SampleCount4)
        {
            descriptorPool = new DescriptorPool(dev, 2,
                                                new VkDescriptorPoolSize(VkDescriptorType.UniformBuffer),
                                                new VkDescriptorPoolSize(VkDescriptorType.CombinedImageSampler)
                                                );

            descLayoutMatrix = new DescriptorSetLayout(dev,
                                                       new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Vertex | VkShaderStageFlags.Fragment, VkDescriptorType.UniformBuffer),
                                                       new VkDescriptorSetLayoutBinding(1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                                                       );

            descLayoutTextures = new DescriptorSetLayout(dev,
                                                         new VkDescriptorSetLayoutBinding(0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                         new VkDescriptorSetLayoutBinding(1, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                         new VkDescriptorSetLayoutBinding(2, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                         new VkDescriptorSetLayoutBinding(3, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler),
                                                         new VkDescriptorSetLayoutBinding(4, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler)
                                                         );

            dsMats = descriptorPool.Allocate(descLayoutMatrix);

            GraphicPipelineConfig cfg = GraphicPipelineConfig.CreateDefault(VkPrimitiveTopology.TriangleList, samples);

            cfg.Layout = new PipelineLayout(dev, descLayoutMatrix, descLayoutTextures);
            cfg.Layout.AddPushConstants(
                new VkPushConstantRange(VkShaderStageFlags.Vertex, (uint)Marshal.SizeOf <Matrix4x4> ()),
                new VkPushConstantRange(VkShaderStageFlags.Fragment, (uint)Marshal.SizeOf <Model.PbrMaterial> (), 64)
                );
            cfg.RenderPass = new RenderPass(dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat(), samples);

            cfg.AddVertexBinding <Model.Vertex> (0);
            cfg.SetVertexAttributes(0, VkFormat.R32g32b32Sfloat, VkFormat.R32g32b32Sfloat, VkFormat.R32g32Sfloat);

            cfg.AddShader(VkShaderStageFlags.Vertex, "shaders/pbrtest.vert.spv");
            cfg.AddShader(VkShaderStageFlags.Fragment, "shaders/pbrtest.frag.spv");

            pipeline = new GraphicPipeline(cfg);

            cfg.ResetShadersAndVerticesInfos();
            cfg.AddShader(VkShaderStageFlags.Vertex, "shaders/FullScreenQuad.vert.spv");
            cfg.AddShader(VkShaderStageFlags.Fragment, "shaders/simpletexture.frag.spv");

            cfg.blendAttachments[0] = new VkPipelineColorBlendAttachmentState(true);

            uiPipeline = new GraphicPipeline(cfg);

            uboMats = new HostBuffer(dev, VkBufferUsageFlags.UniformBuffer, (ulong)Marshal.SizeOf <Matrices>());
            uboMats.Map();             //permanent map

            DescriptorSetWrites uboUpdate = new DescriptorSetWrites(dsMats, descLayoutMatrix.Bindings[0]);

            uboUpdate.Write(dev, uboMats.Descriptor);

            cfg.Layout.SetName("Main Pipeline layout");
            uboMats.SetName("uboMats");
            descriptorPool.SetName("main pool");
            descLayoutTextures.SetName("descLayoutTextures");

            statPool = new PipelineStatisticsQueryPool(dev,
                                                       VkQueryPipelineStatisticFlags.InputAssemblyVertices |
                                                       VkQueryPipelineStatisticFlags.InputAssemblyPrimitives |
                                                       VkQueryPipelineStatisticFlags.ClippingInvocations |
                                                       VkQueryPipelineStatisticFlags.ClippingPrimitives |
                                                       VkQueryPipelineStatisticFlags.FragmentShaderInvocations);

            timestampQPool = new TimestampQueryPool(dev);
        }