public Sampler(SamplerCreateInfo info) { Handle = GL.GenSampler(); GL.SamplerParameter(Handle, SamplerParameterName.TextureMinFilter, (int)info.MinFilter.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureMagFilter, (int)info.MagFilter.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureWrapS, (int)info.AddressU.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureWrapT, (int)info.AddressV.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureWrapR, (int)info.AddressP.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureCompareMode, (int)info.CompareMode.Convert()); GL.SamplerParameter(Handle, SamplerParameterName.TextureCompareFunc, (int)info.CompareOp.Convert()); unsafe { float *borderColor = stackalloc float[4] { info.BorderColor.Red, info.BorderColor.Green, info.BorderColor.Blue, info.BorderColor.Alpha }; GL.SamplerParameter(Handle, SamplerParameterName.TextureBorderColor, borderColor); } GL.SamplerParameter(Handle, SamplerParameterName.TextureMinLod, info.MinLod); GL.SamplerParameter(Handle, SamplerParameterName.TextureMaxLod, info.MaxLod); GL.SamplerParameter(Handle, SamplerParameterName.TextureLodBias, info.MipLodBias); GL.SamplerParameter(Handle, SamplerParameterName.TextureMaxAnisotropyExt, info.MaxAnisotropy); }
public unsafe Sampler(Api api, SamplerConfig config) { _api = api; // Wrap textures // TODO: make texture-specific config.AddressModeU = SamplerAddressMode.Repeat; config.AddressModeV = SamplerAddressMode.Repeat; config.AddressModeW = SamplerAddressMode.Repeat; var samplerInfo = new SamplerCreateInfo(); samplerInfo.SType = StructureType.SamplerCreateInfo; samplerInfo.MagFilter = config.MagFilter; samplerInfo.MinFilter = config.MinFilter; samplerInfo.AddressModeU = config.AddressModeU; samplerInfo.AddressModeV = config.AddressModeV; samplerInfo.AddressModeW = config.AddressModeW; samplerInfo.AnisotropyEnable = config.AnisotropyEnable; samplerInfo.MaxAnisotropy = config.MaxAnisotropy; samplerInfo.BorderColor = config.BorderColor; samplerInfo.UnnormalizedCoordinates = config.UnnormalizedCoordinates; samplerInfo.CompareEnable = config.CompareEnable; samplerInfo.CompareOp = config.CompareOp; samplerInfo.MipmapMode = config.MipmapMode; samplerInfo.MipLodBias = config.MipLodBias; samplerInfo.MinLod = config.MinLod; samplerInfo.MaxLod = config.MaxLod; Util.Verify(_api.Vk.CreateSampler(_api.Device.VkDevice, samplerInfo, default, out _vkSampler), $"{nameof(Sampler)}: Failed to create sampler");
public void CreateSampler() { var createInfo = new SamplerCreateInfo(); using (Device.CreateSampler(createInfo)) { } using (Device.CreateSampler(createInfo, CustomAllocator)) { } }
Sampler CreateSampler() { var createInfo = new SamplerCreateInfo(); createInfo.MagFilter = Filter.Linear; createInfo.MinFilter = Filter.Linear; createInfo.MipmapMode = SamplerMipmapMode.Linear; createInfo.MaxLod = 1; createInfo.AnisotropyEnable = true; createInfo.BorderColor = BorderColor.FloatOpaqueWhite; return(device.CreateSampler(createInfo)); }
public Sampler(Filter magFilter, Filter minFilter, SamplerMipmapMode mipmapMode, SamplerAddressMode addressModeU, SamplerAddressMode addressModeV, SamplerAddressMode addressModeW, float mipLodBias, float maxAnisotropy, float minLod, float maxLod, BorderColor aBorderColor) { SamplerCreateInfo sampler = new SamplerCreateInfo(); sampler.MagFilter = magFilter; sampler.MinFilter = minFilter; sampler.MipmapMode = mipmapMode; sampler.AddressModeU = addressModeU; sampler.AddressModeV = addressModeV; sampler.AddressModeW = addressModeW; sampler.MipLodBias = mipLodBias; sampler.MaxAnisotropy = maxAnisotropy; sampler.MinLod = minLod; sampler.MaxLod = maxLod; sampler.BorderColor = aBorderColor; VulkanRenderer.SelectedLogicalDevice.CreateSampler(this, sampler); }
private unsafe void CreateNativeSampler() { var createInfo = new SamplerCreateInfo { StructureType = StructureType.SamplerCreateInfo, AddressModeU = ConvertAddressMode(Description.AddressU), AddressModeV = ConvertAddressMode(Description.AddressV), AddressModeW = ConvertAddressMode(Description.AddressW), MipLodBias = Description.MipMapLevelOfDetailBias, MaxAnisotropy = Description.MaxAnisotropy, CompareOperation = VulkanConvertExtensions.ConvertComparisonFunction(Description.CompareFunction), MinLod = Description.MinMipLevel, MaxLod = Description.MaxMipLevel, BorderColor = BorderColor.FloatOpaqueBlack // TODO VULKAN: How to handle BorderColor }; ConvertMinFilter(Description.Filter, out createInfo.MinFilter, out createInfo.MagFilter, out createInfo.MipmapMode, out createInfo.CompareEnable, out createInfo.AnisotropyEnable); NativeSampler = GraphicsDevice.NativeDevice.CreateSampler(ref createInfo); }
protected void CreateTextureSampler() { var samplerInfo = new SamplerCreateInfo { MagFilter = Filter.Linear, MinFilter = Filter.Linear, AddressModeU = SamplerAddressMode.Repeat, AddressModeV = SamplerAddressMode.Repeat, AddressModeW = SamplerAddressMode.Repeat, AnisotropyEnable = true, MaxAnisotropy = 16, BorderColor = BorderColor.IntOpaqueBlack, UnnormalizedCoordinates = false, CompareEnable = false, CompareOp = CompareOp.Always, MipmapMode = SamplerMipmapMode.Linear, }; textureSampler = device.CreateSampler(samplerInfo); }
private Sampler CreateSampler() { var createInfo = new SamplerCreateInfo { MagFilter = Filter.Linear, MinFilter = Filter.Linear, MipmapMode = SamplerMipmapMode.Linear }; // We also enable anisotropic filtering. Because that feature is optional, it must be // checked if it is supported by the device. if (Context.Features.SamplerAnisotropy) { createInfo.AnisotropyEnable = true; createInfo.MaxAnisotropy = Context.Properties.Limits.MaxSamplerAnisotropy; } else { createInfo.MaxAnisotropy = 1.0f; } return(Context.Device.CreateSampler(createInfo)); }
public static Sampler CreateSampler(Context ctx, Filter magFilter, Filter minFilter, SamplerMipmapMode mipmapMode) { var createInfo = new SamplerCreateInfo { MagFilter = magFilter, MinFilter = minFilter, MipmapMode = mipmapMode }; // We also enable anisotropic filtering. Because that feature is optional, it must be // checked if it is supported by the device. if (ctx.Features.SamplerAnisotropy) { createInfo.AnisotropyEnable = true; createInfo.MaxAnisotropy = ctx.Properties.Limits.MaxSamplerAnisotropy; } else { createInfo.MaxAnisotropy = 1.0f; } return(ctx.Device.CreateSampler(createInfo)); }
public ISampler CreateSampler(SamplerCreateInfo info) { return(new Sampler(info)); }
public unsafe Sampler CreateSampler(ref SamplerCreateInfo createInfo, AllocationCallbacks* allocator = null) { Sampler sampler; fixed (SamplerCreateInfo* __createInfo__ = &createInfo) { vkCreateSampler(this, __createInfo__, allocator, &sampler).CheckError(); } return sampler; }
internal static unsafe extern Result vkCreateSampler(Device device, SamplerCreateInfo* createInfo, AllocationCallbacks* allocator, Sampler* sampler);
public void Set(TableRef <ThreadedSampler> sampler, SamplerCreateInfo info) { _sampler = sampler; _info = info; }