public void CreateSampler(VkFilter minFilter = VkFilter.Linear, VkFilter magFilter = VkFilter.Linear, VkSamplerMipmapMode mipmapMode = VkSamplerMipmapMode.Linear, VkSamplerAddressMode addressMode = VkSamplerAddressMode.Repeat, float maxAnisotropy = 1.0f, float minLod = 0.0f, float maxLod = -1f) { VkSampler sampler; VkSamplerCreateInfo sampInfo = VkSamplerCreateInfo.New(); sampInfo.maxAnisotropy = maxAnisotropy; sampInfo.maxAnisotropy = 1.0f; // device->enabledFeatures.samplerAnisotropy ? device->properties.limits.maxSamplerAnisotropy : 1.0f; //samplerInfo.anisotropyEnable = device->enabledFeatures.samplerAnisotropy; sampInfo.addressModeU = addressMode; sampInfo.addressModeV = addressMode; sampInfo.addressModeW = addressMode; sampInfo.magFilter = magFilter; sampInfo.minFilter = minFilter; sampInfo.mipmapMode = mipmapMode; sampInfo.minLod = minLod; sampInfo.maxLod = maxLod < 0f ? info.mipLevels : maxLod; Utils.CheckResult(vkCreateSampler(Dev.VkDev, ref sampInfo, IntPtr.Zero, out sampler)); if (Descriptor.sampler.Handle != 0) { Dev.DestroySampler(Descriptor.sampler); } Descriptor.sampler = sampler; }
internal static void GetFilterParams( SamplerFilter filter, out VkFilter minFilter, out VkFilter magFilter, out VkSamplerMipmapMode mipmapMode) { switch (filter) { case SamplerFilter.Anisotropic: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipmapMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinPoint_MagPoint_MipPoint: minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipmapMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinPoint_MagPoint_MipLinear: minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipmapMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinPoint_MagLinear_MipPoint: minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipmapMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinPoint_MagLinear_MipLinear: minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipmapMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinLinear_MagPoint_MipPoint: minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipmapMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinLinear_MagPoint_MipLinear: minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipmapMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinLinear_MagLinear_MipPoint: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipmapMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinLinear_MagLinear_MipLinear: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipmapMode = VkSamplerMipmapMode.Linear; break; default: throw Illegal.Value<SamplerFilter>(); } }
public static extern void CmdBlitImage( VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint regionCount, IntPtr pRegions, VkFilter filter );
public void CmdBlitImage( [FromProperty("this")] GenCommandBuffer commandBuffer, GenImage srcImage, VkImageLayout srcImageLayout, GenImage dstImage, VkImageLayout dstImageLayout, [CountFor("regions")] int regionCount, [IsArray] VkImageBlit *pRegions, VkFilter filter) { }
/// <summary> /// Blit this image into another. /// </summary> /// <param name="cmd">a command buffer to handle the blit operation.</param> /// <param name="dest">the destination image to blit to.</param> /// <param name="filter">filtering for the blit operation.</param> public void BlitTo(CommandBuffer cmd, Image dest, VkFilter filter = VkFilter.Linear) { VkImageBlit imageBlit = new VkImageBlit { srcSubresource = new VkImageSubresourceLayers(VkImageAspectFlags.Color, info.arrayLayers, 0), srcOffsets_1 = new VkOffset3D((int)info.extent.width, (int)info.extent.height, 1), dstSubresource = new VkImageSubresourceLayers(VkImageAspectFlags.Color, info.arrayLayers, 0), dstOffsets_1 = new VkOffset3D((int)dest.info.extent.width, (int)dest.info.extent.height, 1) }; vkCmdBlitImage(cmd.Handle, handle, VkImageLayout.TransferSrcOptimal, dest.handle, VkImageLayout.TransferDstOptimal, 1, ref imageBlit, filter); }
public SamplerDescription(float maxLod, float minLod, VkCompareOp compareOp, bool compareEnable, float mipLodBias, VkSamplerAddressMode addressModeW, VkSamplerAddressMode addressModeV, VkSamplerAddressMode addressModeU, VkSamplerMipmapMode mipmapMode, VkFilter minFilter, VkFilter magFilter, VkBorderColor borderColor, bool unNormalizedCoordinates) { MaxLod = maxLod; MinLod = minLod; CompareOp = compareOp; CompareEnable = compareEnable; MipLodBias = mipLodBias; AddressModeW = addressModeW; AddressModeV = addressModeV; AddressModeU = addressModeU; MipmapMode = mipmapMode; MinFilter = minFilter; MagFilter = magFilter; BorderColor = borderColor; UnNormalizedCoordinates = unNormalizedCoordinates; }
public Sampler(VkFilter filter, VkSamplerMipmapMode mipmapMode, VkSamplerAddressMode addressMode, uint mipLevels, bool anisotropyEnable, VkBorderColor borderColor = VkBorderColor.FloatOpaqueWhite) { // Create sampler var samplerCreateInfo = new VkSamplerCreateInfo { sType = VkStructureType.SamplerCreateInfo, magFilter = filter, minFilter = filter, mipmapMode = mipmapMode, addressModeU = addressMode, addressModeV = addressMode, addressModeW = addressMode, mipLodBias = 0.0f, compareOp = VkCompareOp.Never, minLod = 0.0f, maxLod = mipLevels, borderColor = borderColor, maxAnisotropy = anisotropyEnable ? Device.Properties.limits.maxSamplerAnisotropy : 1, anisotropyEnable = anisotropyEnable }; handle = Device.CreateSampler(ref samplerCreateInfo); }
private void ConvertMinFilter(TextureFilter filter, out VkFilter minFilter, out VkFilter magFilter, out VkSamplerMipmapMode mipmapMode, out VkBool32 enableComparison, out VkBool32 enableAnisotropy) { minFilter = magFilter = VkFilter.Nearest; mipmapMode = VkSamplerMipmapMode.Nearest; enableComparison = false; enableAnisotropy = false; switch (filter) { // Mip point case TextureFilter.Point: break; case TextureFilter.MinLinearMagMipPoint: minFilter = VkFilter.Linear; break; case TextureFilter.MinPointMagLinearMipPoint: magFilter = VkFilter.Linear; break; case TextureFilter.MinMagLinearMipPoint: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; // Mip linear case TextureFilter.MinMagPointMipLinear: mipmapMode = VkSamplerMipmapMode.Linear; break; case TextureFilter.MinLinearMagPointMipLinear: mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; break; case TextureFilter.MinPointMagMipLinear: mipmapMode = VkSamplerMipmapMode.Linear; magFilter = VkFilter.Linear; break; case TextureFilter.Linear: mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; case TextureFilter.Anisotropic: enableAnisotropy = true; mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; // Comparison mip point case TextureFilter.ComparisonPoint: enableComparison = true; break; case TextureFilter.ComparisonMinLinearMagMipPoint: enableComparison = true; minFilter = VkFilter.Linear; break; case TextureFilter.ComparisonMinPointMagLinearMipPoint: enableComparison = true; magFilter = VkFilter.Linear; break; case TextureFilter.ComparisonMinMagLinearMipPoint: enableComparison = true; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; // Comparison mip linear case TextureFilter.ComparisonMinMagPointMipLinear: enableComparison = true; mipmapMode = VkSamplerMipmapMode.Linear; break; case TextureFilter.ComparisonMinLinearMagPointMipLinear: enableComparison = true; mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; break; case TextureFilter.ComparisonMinPointMagMipLinear: enableComparison = true; mipmapMode = VkSamplerMipmapMode.Linear; magFilter = VkFilter.Linear; break; case TextureFilter.ComparisonLinear: enableComparison = true; mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; case TextureFilter.ComparisonAnisotropic: enableComparison = true; enableAnisotropy = true; mipmapMode = VkSamplerMipmapMode.Linear; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; break; default: throw new ArgumentOutOfRangeException(); } }
internal extern static void vkCmdBlitImage(IntPtr commandBuffer, UInt64 srcImage, MgImageLayout srcImageLayout, UInt64 dstImage, MgImageLayout dstImageLayout, UInt32 regionCount, [In] MgImageBlit[] pRegions, VkFilter filter);
public static void GetFilterProperties( SamplerFilter filter, out VkFilter minFilter, out VkFilter magFilter, out VkSamplerMipmapMode mipMode, out bool anisotropyEnable, out bool compareEnable) { anisotropyEnable = false; compareEnable = false; switch (filter) { case SamplerFilter.MinMagMipPoint: minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinMagPointMipLinear: minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinPointMagLinearMipPoint: minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinPointMagMipLinear: minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinLinearMagMipPoint: minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinLinearMagPointMipLinear: minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.MinMagLinearMipPoint: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.MinMagMipLinear: minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.Anisotropic: anisotropyEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.ComparisonMinMagMipPoint: compareEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.ComparisonMinMagPointMipLinear: compareEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.ComparisonMinPointMagLinearMipPoint: compareEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.ComparisonMinPointMagMipLinear: compareEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.ComparisonMinLinearMagMipPoint: compareEnable = true; minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.ComparisonMinLinearMagPointMipLinear: compareEnable = true; minFilter = VkFilter.Linear; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.ComparisonMinMagLinearMipPoint: compareEnable = true; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Nearest; break; case SamplerFilter.ComparisonMinMagMipLinear: compareEnable = true; minFilter = VkFilter.Linear; magFilter = VkFilter.Linear; mipMode = VkSamplerMipmapMode.Linear; break; case SamplerFilter.ComparisonAnisotropic: compareEnable = true; anisotropyEnable = true; minFilter = VkFilter.Nearest; magFilter = VkFilter.Nearest; mipMode = VkSamplerMipmapMode.Nearest; break; default: throw Illegal.Value <SamplerFilter>(); } }
private VideoFilters(VkFilter left, VkFilter right) : base(left, right) { }
public void CmdBlitImage(IVkImage srcImage, VkImageLayout srcImageLayout, IVkImage dstImage, VkImageLayout dstImageLayout, IReadOnlyList <VkImageBlit> regions, VkFilter filter) { var unmanagedSize = regions.SizeOfMarshalDirect(); var unmanagedArray = new byte[unmanagedSize]; fixed(byte *unmanagedStart = unmanagedArray) { var unmanaged = unmanagedStart; var _commandBuffer = Handle; var _srcImage = srcImage?.Handle ?? VkImage.HandleType.Null; var _srcImageLayout = srcImageLayout; var _dstImage = dstImage?.Handle ?? VkImage.HandleType.Null; var _dstImageLayout = dstImageLayout; var _regionCount = regions?.Count ?? 0; var _pRegions = regions.MarshalDirect(ref unmanaged); var _filter = filter; Direct.CmdBlitImage(_commandBuffer, _srcImage, _srcImageLayout, _dstImage, _dstImageLayout, _regionCount, _pRegions, _filter); } }
public void CmdBlitImage( [FromProperty("this")] GenCommandBuffer commandBuffer, GenImage srcImage, VkImageLayout srcImageLayout, GenImage dstImage, VkImageLayout dstImageLayout, [CountFor("regions")] int regionCount, [IsArray] VkImageBlit* pRegions, VkFilter filter) { }
public void CreateSampler(VkSamplerAddressMode addressMode, VkFilter minFilter = VkFilter.Linear, VkFilter magFilter = VkFilter.Linear, VkSamplerMipmapMode mipmapMode = VkSamplerMipmapMode.Linear, float maxAnisotropy = 1.0f, float minLod = 0.0f, float maxLod = -1f) { CreateSampler(minFilter, magFilter, mipmapMode, addressMode, maxAnisotropy, minLod, maxLod); }
public void CmdBlitImage(IVkImage srcImage, VkImageLayout srcImageLayout, IVkImage dstImage, VkImageLayout dstImageLayout, IReadOnlyList<VkImageBlit> regions, VkFilter filter) { var unmanagedSize = regions.SizeOfMarshalDirect(); var unmanagedArray = new byte[unmanagedSize]; fixed (byte* unmanagedStart = unmanagedArray) { var unmanaged = unmanagedStart; var _commandBuffer = Handle; var _srcImage = srcImage?.Handle ?? VkImage.HandleType.Null; var _srcImageLayout = srcImageLayout; var _dstImage = dstImage?.Handle ?? VkImage.HandleType.Null; var _dstImageLayout = dstImageLayout; var _regionCount = regions?.Count ?? 0; var _pRegions = regions.MarshalDirect(ref unmanaged); var _filter = filter; Direct.CmdBlitImage(_commandBuffer, _srcImage, _srcImageLayout, _dstImage, _dstImageLayout, _regionCount, _pRegions, _filter); } }