Example #1
0
        public VulkanExample
        (
            IMgGraphicsConfiguration configuration,
            IMgSwapchainCollection swapchains,
            IMgGraphicsDevice graphicsDevice,
            IMgPresentationLayer presentationLayer,
            ITriangleDemoShaderPath shaderPath
        )
        {
            mConfiguration     = configuration;
            mSwapchains        = swapchains;
            mGraphicsDevice    = graphicsDevice;
            mPresentationLayer = presentationLayer;
            mTrianglePath      = shaderPath;

            mWidth  = 1280U;
            mHeight = 720U;

            try
            {
                mConfiguration.Initialize(mWidth, mHeight);
                InitSwapchain(mWidth, mHeight);
                Prepare();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
 public MgGraphicsConfigurationManager(
     IMgGraphicsConfiguration configuration,
     IMgSwapchainCollection swapchains,
     IMgGraphicsDevice graphicsDevice,
     IMgPresentationLayer presentationLayer
     )
 {
     mConfiguration     = configuration;
     mSwapchains        = swapchains;
     mGraphicsDevice    = graphicsDevice;
     mPresentationLayer = presentationLayer;
 }
Example #3
0
        public SpinningCube(
            IMgGraphicsConfiguration configuration,
            IMgSwapchainCollection swapchains,
            IMgGraphicsDevice graphicsDevice,
            IMgPresentationLayer presentationLayer
            )
        {
            mConfiguration     = configuration;
            mSwapchains        = swapchains;
            mGraphicsDevice    = graphicsDevice;
            mPresentationLayer = presentationLayer;

            mWidth  = 640;
            mHeight = 480;

            mConfiguration.Initialize(mWidth, mHeight);
            SetupGraphicsDevice();

            InitializeMesh();
            InitializeUniforms();
            InitializeRenderCommandBuffers();
            InitializeGraphicsPipeline();
        }
Example #4
0
        public void Prepare(IMgGraphicsConfiguration configuration, IMgGraphicsDevice screen)
        {
            var loader     = new Loader();
            var dataLoader = new DataLoader();
            var device     = configuration.Device;

            using (var fs = File.Open("Data/Triangle.gltf", FileMode.Open))
            {
                // load model file
                var model = glTFLoader.Interface.LoadModel(fs);
                // load meta data
                var metaData = loader.LoadMetaData(model);
                // load data
                var data = dataLoader.LoadData(".", model);

                var staticRequest = new MgStorageBlockAllocationRequest();
                // allocate partitions for static data
                // mesh
                var meshLocations = AllocateMeshes(staticRequest, metaData.Meshes, metaData.Accessors, metaData.BufferViews);

                var meshPrimitives = ExtractMeshPrimitives(metaData.Materials,
                                                           out MgtfMaterial[] sceneMaterials,
                                                           metaData.Meshes,
                                                           meshLocations);

                // images
                var images = ExamineImages(data.Images, data.Buffers);

                // initialize static data storage

                var staticCreateInfo = new MgOptimizedStorageCreateInfo
                {
                    Allocations = staticRequest.ToArray(),
                };

                mStaticStorage = mBuilder.Build(staticCreateInfo);

                // build static artifacts
                // render target
                // descriptor set layout + pipeline layout
                var pass = new ScenePass
                {
                    RenderTarget = screen,
                    Effects      = new[] {
                        new ScenePassEffect
                        {
                            Factory      = mPbrFactory,
                            EffectLayout = mPbrFactory.CreateEffectLayout(configuration.Device),
                        }
                    }
                };

                pass.Initialize(
                    configuration.Device,
                    meshPrimitives,
                    sceneMaterials);

                // allocate dynamic data
                var dynamicRequest = new MgStorageBlockAllocationRequest();

                var limits    = new MgPhysicalDeviceLimits();
                var worldData = AllocateWorldData(dynamicRequest, limits.MaxUniformBufferRange);

                var storageIndices = AllocateMaterials(sceneMaterials, dynamicRequest, limits);

                // per instance data

                // build dynamic artifacts
                // semaphores
                // fences
                // descriptor sets

                // initialize dynamic data storage

                // copy data across
                // buffers
                // images

                // map dynamic data

                // build command buffers
            }
        }