Exemplo n.º 1
0
        public void Create(IMgSwapchainCollection swapchains, IMgRenderPass pass, IMgImageView depthStencilView, uint width, uint height)
        {
            Debug.Assert(mGraphicsConfiguration.Partition != null);

            // Create frame buffers for every swap chain image
            var frameBuffers = new IMgFramebuffer[swapchains.Buffers.Length];

            for (uint i = 0; i < frameBuffers.Length; i++)
            {
                var frameBufferCreateInfo = new MgFramebufferCreateInfo
                {
                    RenderPass  = pass,
                    Attachments = new[]
                    {
                        swapchains.Buffers[i].View,
                        // Depth/Stencil attachment is the same for all frame buffers
                        depthStencilView,
                    },
                    Width  = width,
                    Height = height,
                    Layers = 1,
                };

                var err = mGraphicsConfiguration.Partition.Device.CreateFramebuffer(frameBufferCreateInfo, null, out frameBuffers[i]);
                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
            }

            mFramebuffers = frameBuffers;
        }
Exemplo n.º 2
0
        void CreateFramebuffers(IMgSwapchainCollection swapchains, MgGraphicsDeviceCreateInfo createInfo)
        {
            //IMgFramebuffer[] SetupFrameBuffers(IMgRenderPass renderPass, IMgDepthStencilBuffer depthStencil, IMgSwapchainCollection swapChain, uint width, uint height)
            //{
            // Create frame buffers for every swap chain image
            var frameBuffers = new IMgFramebuffer[swapchains.Buffers.Length];

            for (uint i = 0; i < frameBuffers.Length; i++)
            {
                var frameBufferCreateInfo = new MgFramebufferCreateInfo
                {
                    RenderPass  = mRenderpass,
                    Attachments = new []
                    {
                        swapchains.Buffers[i].View,
                        // Depth/Stencil attachment is the same for all frame buffers
                        mView,
                    },
                    Width  = createInfo.Width,
                    Height = createInfo.Height,
                    Layers = 1,
                };

                var err = mPartition.Device.CreateFramebuffer(frameBufferCreateInfo, null, out frameBuffers[i]);
                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
            }

            mFramebuffers = frameBuffers;
        }
Exemplo n.º 3
0
 public Result CreateFramebuffer(MgFramebufferCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgFramebuffer pFramebuffer)
 {
     // TODO : make sure everything is attached properly
     pFramebuffer = new AmtFramebuffer(pCreateInfo);
     return(Result.SUCCESS);
 }
Exemplo n.º 4
0
 public Result CreateFramebuffer(MgFramebufferCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgFramebuffer pFramebuffer)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 public Result CreateFramebuffer(MgFramebufferCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgFramebuffer pFramebuffer)
 {
     pFramebuffer = new GLFramebuffer();
     return(Result.SUCCESS);
 }
Exemplo n.º 6
0
        public void Preamble()
        {
            // PRIVATE IMPLEMENTATION UNIT TESTING
            mContainer = new Container();

            mContainer.Register <IMgQueue, GLCmdQueue>(Reuse.Singleton);
            mContainer.Register <IGLCmdStateRenderer, GLCmdStateRenderer>(Reuse.Singleton);

            mContainer.Register <IGLCmdBlendEntrypoint, MockGLCmdBlendEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdStencilEntrypoint, MockGLCmdStencilEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdRasterizationEntrypoint, MockGLCmdRasterizationEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdDepthEntrypoint, MockGLCmdDepthEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdScissorsEntrypoint, MockGLCmdScissorsEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdDrawEntrypoint, MockGLCmdDrawEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdClearEntrypoint, MockGLCmdClearEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLErrorHandler, MockGLErrorHandler>(Reuse.Singleton);


            mContainer.Register <IGLNextCmdShaderProgramCache, GLNextCmdShaderProgramCache>(Reuse.Singleton);
            mContainer.Register <IGLCmdShaderProgramEntrypoint, MockGLCmdShaderProgramEntrypoint>(Reuse.Singleton);


            mContainer.Register <IGLBlitOperationEntrypoint, MockGLBlitOperationEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLSemaphoreEntrypoint, MockGLSemaphoreEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLCmdImageEntrypoint, MockGLCmdImageEntrypoint>(Reuse.Singleton);

            mContainer.Register <IGLCmdBlitEncoder, GLCmdBlitEncoder>(Reuse.Singleton);
            mContainer.Register <GLCmdBlitBag>(Reuse.Singleton);
            mContainer.Register <IGLCmdComputeEncoder, GLCmdComputeEncoder>(Reuse.Singleton);
            mContainer.Register <IGLCmdGraphicsEncoder, GLCmdGraphicsEncoder>(Reuse.Singleton);

            mContainer.Register <GLCmdGraphicsBag>(Reuse.Singleton);
            mContainer.Register <IGLCmdVBOEntrypoint, MockGLCmdVBOEntrypoint>(Reuse.Singleton);
            mContainer.Register <IGLDescriptorSetBinder, GLNextDescriptorSetBinder>(Reuse.Singleton);


            mContainer.Register <IGLCmdEncoderContextSorter, GLCmdIncrementalContextSorter>(Reuse.Singleton);
            mContainer.Register <GLCmdCommandEncoder>(Reuse.Singleton);


            mContainer.Register <GLInternalCache>(Reuse.Singleton);
            mContainer.Register <IMgPipeline, GLGraphicsPipeline>(Reuse.Singleton);
            mContainer.Register <IGLGraphicsPipelineCompiler, MockGLGraphicsPipelineCompiler>(Reuse.Singleton);
            mContainer.Register <IGLGraphicsPipelineEntrypoint, MockGLGraphicsPipelineEntrypoint>(Reuse.Singleton);

            queue = mContainer.Resolve <IMgQueue>();
            var cmdEncoder = mContainer.Resolve <GLCmdCommandEncoder>();

            cmdBuf = new Magnesium.OpenGL.Internals.GLCmdCommandBuffer(true, cmdEncoder);

            framebuffer = new Magnesium.OpenGL.Internals.GLFramebuffer();
            renderpass  = new GLRenderPass(new MgAttachmentDescription[] { });

            vertexBuffer = new MockGLBuffer
            {
                BufferId = 1,
                Usage    = MgBufferUsageFlagBits.VERTEX_BUFFER_BIT,
            };
            indexBuffer = new MockGLBuffer
            {
                BufferId = 2,
                Usage    = MgBufferUsageFlagBits.INDEX_BUFFER_BIT,
            };

            var layout = new MockGLPipelineLayout
            {
            };

            mContainer.RegisterInstance <IGLPipelineLayout>(layout, Reuse.Singleton);

            var blockEntries = new GLUniformBlockEntry[]
            {
            };
            var arrayMapper = new Magnesium.OpenGL.Internals.GLInternalCacheArrayMapper(layout, blockEntries);

            mContainer.RegisterInstance <GLInternalCacheArrayMapper>(arrayMapper, Reuse.Singleton);

            var entrypoint    = mContainer.Resolve <IGLGraphicsPipelineEntrypoint>();
            var internalCache = mContainer.Resolve <GLInternalCache>();
            var info          = new MgGraphicsPipelineCreateInfo
            {
                VertexInputState = new MgPipelineVertexInputStateCreateInfo
                {
                    VertexAttributeDescriptions = new[]
                    {
                        new MgVertexInputAttributeDescription
                        {
                            Binding  = 0,
                            Location = 0,
                            Format   = MgFormat.R8G8B8A8_SNORM,
                        }
                    },
                    VertexBindingDescriptions = new[]
                    {
                        new MgVertexInputBindingDescription
                        {
                            Binding   = 0,
                            InputRate = MgVertexInputRate.VERTEX,
                            Stride    = 32,
                        }
                    }
                },
                RasterizationState = new MgPipelineRasterizationStateCreateInfo
                {
                    PolygonMode = MgPolygonMode.FILL,
                },
                InputAssemblyState = new MgPipelineInputAssemblyStateCreateInfo
                {
                    Topology = MgPrimitiveTopology.TRIANGLE_LIST,
                }
            };

            pipeline = new Magnesium.OpenGL.Internals.GLGraphicsPipeline(entrypoint, 1, info, internalCache, layout);


            var stateRenderer = mContainer.Resolve <IGLCmdStateRenderer>();

            stateRenderer.Initialize();
        }