Пример #1
0
        //private GltfTextureContainer AllocateTextures(int bucketSize, Texture[] textures, GltfImageData[] images)
        //{
        //    return new GltfTextureContainer
        //    {
        //        BucketSize = bucketSize,
        //    };
        //}

        private IMgSampler[] ExtractSamplers(IMgDevice device, Sampler[] samplers)
        {
            var noOfSamplers = samplers != null ? samplers.Length : 0;

            var output = new IMgSampler[noOfSamplers];

            for (var i = 0; i < noOfSamplers; i += 1)
            {
                var src = samplers[i];

                var createInfo = new MgSamplerCreateInfo
                {
                    AddressModeU = GetAddressModeU(src.WrapS),
                    AddressModeV = GetAddressModeV(src.WrapT),
                    MinFilter    = GetMinFilter(src.MinFilter),
                    MagFilter    = GetMagFilter(src.MagFilter),
                    MipmapMode   = GetMipmapMode(src.MinFilter),
                };

                var err = device.CreateSampler(createInfo, null, out IMgSampler pSampler);
                if (err != Result.SUCCESS)
                {
                    throw new InvalidOperationException();
                }
                output[i] = pSampler;
            }
            return(output);
        }
Пример #2
0
        public void Destroy(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            if (Blocks != null)
            {
                foreach (var block in Blocks)
                {
                    if (block != null)
                    {
                        if (block.DeviceMemory != null)
                        {
                            block.DeviceMemory.FreeMemory(device, allocator);
                        }

                        if (block.Buffer != null)
                        {
                            block.Buffer.DestroyBuffer(device, allocator);
                        }
                    }
                }
            }

            mIsDisposed = true;
        }
Пример #3
0
        public BufferInfo(IMgThreadPartition partition, MgBufferUsageFlagBits usage, MgMemoryPropertyFlagBits propertyFlags, uint bufferSize)
        {
            Debug.Assert(partition != null);

            mDevice = partition.Device;
            Debug.Assert(mDevice != null);

            mUsageFlags = usage;

            mMemoryPropertyFlags = propertyFlags;

            var bufferCreateInfo = new MgBufferCreateInfo
            {
                Usage = usage,
                Size  = bufferSize,
            };

            IMgBuffer buffer;

            var device = partition.Device;

            var result = device.CreateBuffer(bufferCreateInfo, null, out buffer);

            Debug.Assert(result == Result.SUCCESS);

            MgMemoryRequirements memReqs;

            device.GetBufferMemoryRequirements(buffer, out memReqs);
            mAlignment  = memReqs.Alignment;
            mBufferSize = memReqs.Size;

            uint memoryTypeIndex;

            partition.GetMemoryType(memReqs.MemoryTypeBits, mMemoryPropertyFlags, out memoryTypeIndex);

            var memAlloc = new MgMemoryAllocateInfo
            {
                MemoryTypeIndex = memoryTypeIndex,
                AllocationSize  = memReqs.Size,
            };

            IMgDeviceMemory deviceMemory;

            result = device.AllocateMemory(memAlloc, null, out deviceMemory);
            Debug.Assert(result == Result.SUCCESS);

            buffer.BindBufferMemory(device, deviceMemory, 0);


            mBuffer       = buffer;
            mDeviceMemory = deviceMemory;

            mDescriptor = new MgDescriptorBufferInfo
            {
                Buffer = mBuffer,
                Offset = 0,
                Range  = mBufferSize,
            };
        }
Пример #4
0
 public MgQueueInfo(uint queueIndex, IMgPhysicalDevice gpu, IMgDevice device, uint queueFamilyIndex, IMgQueue queue)
 {
     QueueIndex       = queueIndex;
     QueueFamilyIndex = queueFamilyIndex;
     mParent          = gpu;
     Device           = device;
     Queue            = queue;
 }
Пример #5
0
 internal void Initialize(IMgDevice device, SceneMeshPrimitive[] meshPrimitives, MgtfMaterial[] materials)
 {
     Variants = new EffectPipelineDictionary();
     foreach (var eff in Effects)
     {
         InitializeVariants(device, eff, meshPrimitives, materials);
     }
 }
Пример #6
0
 public void DestroySemaphore(IMgDevice device, IMgAllocationCallbacks allocator)
 {
     if (ObjectPtr != IntPtr.Zero)
     {
         GL.DeleteSync(ObjectPtr);
         ObjectPtr = IntPtr.Zero;
     }
 }
Пример #7
0
 public void Clear(IMgDevice device)
 {
     foreach (var entry in mVariants.Values)
     {
         entry.Pipeline.DestroyPipeline(device, null);
     }
     mVariants.Clear();
 }
Пример #8
0
 public Result ResetDescriptorPool(IMgDevice device, uint flags)
 {
     for (var i = 0; i < PoolSize; ++i)
     {
         AttachedSets[i].Reset();
     }
     return(Result.SUCCESS);
 }
Пример #9
0
 public Result ResetCommandPool(IMgDevice device, MgCommandPoolResetFlagBits flags)
 {
     foreach (var buffer in mBuffers)
     {
         buffer.ResetAllData();
     }
     return(Result.SUCCESS);
 }
Пример #10
0
        public EffectLayout CreateEffectLayout(IMgDevice device)
        {
            var pDsCreateInfo = new MgDescriptorSetLayoutCreateInfo
            {
                Bindings = new[]
                {
                    // WORLD DATA
                    // CAMERAS
                    // LIGHTS
                    new MgDescriptorSetLayoutBinding
                    {
                        Binding         = 0,
                        DescriptorType  = MgDescriptorType.UNIFORM_BUFFER,
                        DescriptorCount = 1,
                        StageFlags      = MgShaderStageFlagBits.VERTEX_BIT,
                    },
                    // MATERIALS
                    new MgDescriptorSetLayoutBinding
                    {
                        Binding         = 1,
                        DescriptorType  = MgDescriptorType.UNIFORM_BUFFER,
                        DescriptorCount = mSettings.NoOfMaterialsPerGroup,
                        StageFlags      = MgShaderStageFlagBits.FRAGMENT_BIT,
                    },
                    // TEXTURES
                    new MgDescriptorSetLayoutBinding
                    {
                        Binding         = 5,
                        DescriptorType  = MgDescriptorType.COMBINED_IMAGE_SAMPLER,
                        DescriptorCount = mSettings.NoOfTexturesPerGroup,
                        StageFlags      = MgShaderStageFlagBits.FRAGMENT_BIT,
                    },
                }
            };

            var err = device.CreateDescriptorSetLayout(pDsCreateInfo, null, out IMgDescriptorSetLayout dsLayout);

            if (err != Result.SUCCESS)
            {
                throw new InvalidOperationException("CreateDescriptorSetLayout failed");
            }

            var pCreateInfo = new MgPipelineLayoutCreateInfo
            {
                SetLayouts = new[]
                {
                    dsLayout,
                }
            };

            err = device.CreatePipelineLayout(pCreateInfo, null, out IMgPipelineLayout layout);
            if (err != Result.SUCCESS)
            {
                throw new InvalidOperationException("CreatePipelineLayout failed");
            }

            return(new EffectLayout(dsLayout, layout));
        }
Пример #11
0
        public void DestroyCommandPool(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mIsDisposed = true;
        }
Пример #12
0
        public void DestroyDescriptorSetLayout(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mIsDisposed = true;
        }
Пример #13
0
        public Result ResetDescriptorPool(IMgDevice device, UInt32 flags)
        {
            Debug.Assert(!mIsDisposed);

            var bDevice = device as VkDevice;

            Debug.Assert(bDevice != null);

            return(Interops.vkResetDescriptorPool(bDevice.Handle, this.Handle, flags));
        }
Пример #14
0
        public Result BindImageMemory(IMgDevice device, IMgDeviceMemory memory, ulong memoryOffset)
        {
            var deviceMemory = memory as IGLDeviceMemory;

            if (deviceMemory != null)
            {
                mMemory = IntPtr.Add(deviceMemory.Handle, (int)memoryOffset);
            }
            return(Result.SUCCESS);
        }
Пример #15
0
        public Result ResetEvent(IMgDevice device)
        {
            Debug.Assert(!mIsDisposed);

            var bDevice = (VkDevice)device;

            Debug.Assert(bDevice != null);

            return((Result)Interops.vkResetEvent(bDevice.Handle, this.Handle));
        }
Пример #16
0
        public void UnmapMemory(IMgDevice device)
        {
            if (!mIsHostCached && mIsMapped)
            {
                bool isValid = GL.Ext.UnmapNamedBuffer(mBufferId);

                mErrHandler.LogGLError("GL.Ext.UnmapNamedBuffer");
            }
            mIsMapped = false;
        }
Пример #17
0
        public void UnmapMemory(IMgDevice device)
        {
            Debug.Assert(!mIsDisposed);

            if (mRange.HasValue)
            {
                InternalBuffer.DidModify(mRange.Value);
                mRange = null;
            }
        }
Пример #18
0
 public void DestroyDescriptorPool(IMgDevice device, IMgAllocationCallbacks allocator)
 {
     foreach (var img in CombinedImageSamplers.Items)
     {
         if (img != null)
         {
             img.Destroy();
         }
     }
 }
Пример #19
0
        public void UnmapMemory(IMgDevice device)
        {
            Debug.Assert(!mIsDisposed);

            var bDevice = (VkDevice)device;

            Debug.Assert(bDevice != null);

            Interops.vkUnmapMemory(bDevice.Handle, this.Handle);
        }
Пример #20
0
        public Result GetEventStatus(IMgDevice device)
        {
            Debug.Assert(!mIsDisposed);

            var bDevice = (VkDevice)device;

            Debug.Assert(bDevice != null);

            return(Interops.vkGetEventStatus(bDevice.Handle, this.Handle));
        }
Пример #21
0
        public Result ResetCommandPool(IMgDevice device, MgCommandPoolResetFlagBits flags)
        {
            Debug.Assert(!mIsDisposed);

            var bDevice = (VkDevice)device;

            Debug.Assert(bDevice != null);

            return(Interops.vkResetCommandPool(bDevice.Handle, this.Handle, (VkCommandPoolResetFlags)flags));
        }
Пример #22
0
        public void DestroyImageView(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }


            mIsDisposed = true;
        }
Пример #23
0
        public void FreeMemory(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            InternalBuffer = null;

            mIsDisposed = true;
        }
Пример #24
0
        public void DestroyBuffer(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            VertexBuffer = null;

            mIsDisposed = true;
        }
Пример #25
0
        public void DestroySampler(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mEntrypoint.DeleteSampler(SamplerId);

            mIsDisposed = true;
        }
Пример #26
0
        public void DestroyImage(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mEntrypoint.DeleteImage(mTextureId);
            //GL.DeleteTexture (mTextureId);

            mIsDisposed = true;
        }
Пример #27
0
 public MgThreadPartition(
     IMgPhysicalDevice physicalDevice,
     IMgDevice device, IMgQueue queue,
     IMgCommandPool commandPool,
     MgPhysicalDeviceMemoryProperties deviceMemoryProperties)
 {
     mPhysicalDevice         = physicalDevice;
     mDevice                 = device;
     this.Queue              = queue;
     this.CommandPool        = commandPool;
     mDeviceMemoryProperties = deviceMemoryProperties;
 }
Пример #28
0
        public void DestroyPipeline(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mEntrypoint.DeleteProgram(ProgramID);
            //GL.DeleteProgram (ProgramID);

            mIsDisposed = true;
        }
Пример #29
0
        public void Destroy(IMgDevice device)
        {
            if (Layout != null)
            {
                Layout.DestroyPipelineLayout(device, null);
            }

            if (DescriptorSetLayout != null)
            {
                DescriptorSetLayout.DestroyDescriptorSetLayout(device, null);
            }
        }
Пример #30
0
        public void DestroyImageView(IMgDevice device, IMgAllocationCallbacks allocator)
        {
            if (mIsDisposed)
            {
                return;
            }

            mModule.DeleteImageView(TextureId);

//			int textureId = TextureId;
//			GL.DeleteTextures (1, ref textureId);

            mIsDisposed = true;
        }