Beispiel #1
0
            public Attachment(uint index, uint outIdx, TexelFormat format, bool preserve, bool msaa, bool resolve, IEnumerable <byte> uses)
            {
                Index       = index;
                OutputIndex = outIdx;
                Format      = format;
                Preserve    = preserve;
                MSAA        = msaa;
                Resolve     = resolve;
                int uidx = 0;

                InputUse  = false;
                OutputUse = false;
                foreach (var u in uses)
                {
                    Uses[uidx++] = u;
                    if (u == (byte)AttachmentUse.Input)
                    {
                        InputUse = true;
                    }
                    if ((u == (byte)AttachmentUse.Output) || (u == RESOLVE))
                    {
                        OutputUse = true;
                    }
                }
            }
Beispiel #2
0
 /// <summary>
 /// Create a new filled texture with the given dimensions and format.
 /// </summary>
 /// <param name="width">The width of the texture.</param>
 /// <param name="format">The texel format.</param>
 /// <param name="data">The initial texture data. Must be large enough to fill entire texture.</param>
 /// <param name="usage">The texture usage policy.</param>
 public Texture1D(uint width, TexelFormat format, void *data, TextureUsage usage = TextureUsage.Static)
     : base(width, 1, 1, 1, 1, format, usage, ResourceType.Texture1D)
 {
     if (data == null)
     {
         throw new ArgumentException("Initial texture data pointer cannot be null", nameof(data));
     }
     SetDataImpl(data, new(0, 0, 0, width, 1, 1, 0, 1));
 }
Beispiel #3
0
        /// <summary>
        /// Gets if the format is a valid format for textures used as input attachments.
        /// </summary>
        /// <param name="fmt">The format to check.</param>
        /// <returns>If the format is valid for shader input attachments.</returns>
        public static bool IsValidInputFormat(this TexelFormat fmt)
        {
            string fStr = fmt.ToString();

            if (fStr[fStr.Length - 1] == '3')
            {
                return(false);                // No 3-component texel format is supported
            }
            if (fmt == TexelFormat.Srgb || fmt == TexelFormat.Srgb2)
            {
                return(false);                // Only 4-component sRGB is supported
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new render target texture for immediate use.
        /// </summary>
        /// <param name="width">The width of the render target.</param>
        /// <param name="height">The height of the render target.</param>
        /// <param name="format">The render target format.</param>
        /// <param name="name">An optional name for the render target for identification and debugging.</param>
        public RenderTarget(uint width, uint height, TexelFormat format, string name = null)
        {
            if ((width == 0) || (height == 0))
            {
                throw new ArgumentException($"Cannot create a render target with zero dimension ({width}x{height})");
            }
            if ((width > Device.Limits.MaxTextureSize2D) || (height > Device.Limits.MaxTextureSize2D))
            {
                throw new ArgumentException($"Cannot create a render target larger than the image size limits ({width}x{height} > {Device.Limits.MaxTextureSize2D})");
            }
            Format             = format;
            VkAspects          = HasDepth ? (Vk.ImageAspects.Depth | (HasStencil ? Vk.ImageAspects.Stencil : 0)) : Vk.ImageAspects.Color;
            DefaultImageLayout = HasDepth ? Vk.ImageLayout.DepthStencilAttachmentOptimal : Vk.ImageLayout.ColorAttachmentOptimal;
            Name = name;

            Rebuild(width, height);
        }
Beispiel #5
0
 /// <summary>
 /// Create a new blank texture with the given dimensions and format.
 /// </summary>
 /// <param name="width">The width of the texture.</param>
 /// <param name="format">The texel format.</param>
 /// <param name="usage">The texture usage policy.</param>
 public Texture1D(uint width, TexelFormat format, TextureUsage usage = TextureUsage.Static)
     : base(width, 1, 1, 1, 1, format, usage, ResourceType.Texture1D)
 {
 }
Beispiel #6
0
 // Sets the texture data by copying from a prepared host buffer
 // Pass null as imageType to signal a first-time copy that does not need pipeline barriers
 public void SetImageData(ResourceType imageType, TexelFormat format, bool discard,
                          HostBuffer srcBuffer, ulong srcOffset,
                          VkImage dstImage, in TextureRegion dstRegion)