Exemple #1
0
 void CreateDepthStencilImageView()
 {
     Debug.Assert(mApplicationView != null);
     mDepthStencilView = new AmtImageView(mApplicationView.DepthStencilTexture);
 }
Exemple #2
0
 public Result CreateImageView(MgImageViewCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImageView pView)
 {
     pView = new AmtImageView(pCreateInfo);
     return(Result.SUCCESS);
 }
Exemple #3
0
        public Result CreateImageView(MgImageViewCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImageView pView)
        {
            if (pCreateInfo == null)
            {
                throw new ArgumentNullException("pCreateInfo");
            }

            if (pCreateInfo.Image == null)
            {
                throw new ArgumentNullException("pCreateInfo.Image", "pCreateInfo.Image is null");
            }

            var originalImage = (IGLImage)pCreateInfo.Image;

            if (originalImage == null)
            {
                throw new InvalidCastException("pCreateInfo.Image is not GLImage");
            }

            if (pCreateInfo.SubresourceRange == null)
            {
                throw new ArgumentNullException("pCreateInfo.SubresourceRange", "pCreateInfo.SubresourceRange is null");
            }

            int textureId = mEntrypoint.ImageView.CreateImageView(originalImage, pCreateInfo);

            pView = new GLImageView(textureId, mEntrypoint.ImageView);
            return(Result.SUCCESS);
        }
Exemple #4
0
 public Result CreateImageView(MgImageViewCreateInfo pCreateInfo, IMgAllocationCallbacks allocator, out IMgImageView pView)
 {
     throw new NotImplementedException();
 }
Exemple #5
0
        void CreateDepthStencil(IMgCommandBuffer setupCmdBuffer, MgGraphicsDeviceCreateInfo createInfo)
        {
            // WILL ignore user-supplied depth
            if (!GetSupportedDepthFormat(out MgFormat depthFormat))
            {
                throw new InvalidOperationException("No depth format available");
            }

            var image = new MgImageCreateInfo {
                ImageType = MgImageType.TYPE_2D,
                Format    = depthFormat,
                Extent    = new MgExtent3D {
                    Width  = createInfo.Width,
                    Height = createInfo.Height,
                    Depth  = 1
                },
                MipLevels   = 1,
                ArrayLayers = 1,
                Samples     = createInfo.Samples,
                Tiling      = MgImageTiling.OPTIMAL,
                // TODO : multisampled uses MgImageUsageFlagBits.TRANSIENT_ATTACHMENT_BIT | MgImageUsageFlagBits.DEPTH_STENCIL_ATTACHMENT_BIT;
                Usage = MgImageUsageFlagBits.DEPTH_STENCIL_ATTACHMENT_BIT | MgImageUsageFlagBits.TRANSFER_SRC_BIT,
                Flags = 0,
            };
            var mem_alloc = new MgMemoryAllocateInfo {
                AllocationSize  = 0,
                MemoryTypeIndex = 0,
            };
            MgMemoryRequirements memReqs;

            Debug.Assert(mGraphicsConfiguration.Partition != null);

            Result err;

            {
                IMgImage dsImage;
                err = mGraphicsConfiguration.Partition.Device.CreateImage(image, null, out dsImage);
                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
                mImage = dsImage;
            }
            mGraphicsConfiguration.Partition.Device.GetImageMemoryRequirements(mImage, out memReqs);
            mem_alloc.AllocationSize = memReqs.Size;
            uint memTypeIndex;
            bool memoryTypeFound = mGraphicsConfiguration.Partition.GetMemoryType(memReqs.MemoryTypeBits, MgMemoryPropertyFlagBits.DEVICE_LOCAL_BIT, out memTypeIndex);

            Debug.Assert(memoryTypeFound);
            mem_alloc.MemoryTypeIndex = memTypeIndex;
            {
                IMgDeviceMemory dsDeviceMemory;
                err = mGraphicsConfiguration.Partition.Device.AllocateMemory(mem_alloc, null, out dsDeviceMemory);
                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
                mDeviceMemory = dsDeviceMemory;
            }
            err = mImage.BindImageMemory(mGraphicsConfiguration.Partition.Device, mDeviceMemory, 0);
            Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
            mImageTools.SetImageLayout(setupCmdBuffer, mImage, MgImageAspectFlagBits.DEPTH_BIT | MgImageAspectFlagBits.STENCIL_BIT, MgImageLayout.UNDEFINED, MgImageLayout.DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
            var depthStencilView = new MgImageViewCreateInfo {
                Image            = mImage,
                ViewType         = MgImageViewType.TYPE_2D,
                Format           = createInfo.DepthStencil,
                Flags            = 0,
                SubresourceRange = new MgImageSubresourceRange {
                    AspectMask     = MgImageAspectFlagBits.DEPTH_BIT | MgImageAspectFlagBits.STENCIL_BIT,
                    BaseMipLevel   = 0,
                    LevelCount     = 1,
                    BaseArrayLayer = 0,
                    LayerCount     = 1,
                },
            };
            {
                IMgImageView dsView;
                err = mGraphicsConfiguration.Partition.Device.CreateImageView(depthStencilView, null, out dsView);
                Debug.Assert(err == Result.SUCCESS, err + " != Result.SUCCESS");
                mDepthStencilImageView = dsView;
            }
        }