コード例 #1
0
        internal static Filter VeldridToD3DSamplerFilter(SamplerFilter filter)
        {
            switch (filter)
            {
            case SamplerFilter.MinMagMipPoint:
                return(Filter.MinMagMipPoint);

            case SamplerFilter.MinMagPointMipLinear:
                return(Filter.MinMagPointMipLinear);

            case SamplerFilter.MinPointMagLinearMipPoint:
                return(Filter.MinPointMagLinearMipPoint);

            case SamplerFilter.MinPointMagMipLinear:
                return(Filter.MinPointMagMipLinear);

            case SamplerFilter.MinLinearMagMipPoint:
                return(Filter.MinLinearMagMipPoint);

            case SamplerFilter.MinLinearMagPointMipLinear:
                return(Filter.MinLinearMagPointMipLinear);

            case SamplerFilter.MinMagLinearMipPoint:
                return(Filter.MinMagLinearMipPoint);

            case SamplerFilter.MinMagMipLinear:
                return(Filter.MinMagMipLinear);

            case SamplerFilter.Anisotropic:
                return(Filter.Anisotropic);

            case SamplerFilter.ComparisonMinMagMipPoint:
                return(Filter.ComparisonMinMagMipPoint);

            case SamplerFilter.ComparisonMinMagPointMipLinear:
                return(Filter.ComparisonMinMagPointMipLinear);

            case SamplerFilter.ComparisonMinPointMagLinearMipPoint:
                return(Filter.ComparisonMinPointMagLinearMipPoint);

            case SamplerFilter.ComparisonMinPointMagMipLinear:
                return(Filter.ComparisonMinPointMagMipLinear);

            case SamplerFilter.ComparisonMinLinearMagMipPoint:
                return(Filter.ComparisonMinLinearMagMipPoint);

            case SamplerFilter.ComparisonMinLinearMagPointMipLinear:
                return(Filter.ComparisonMinLinearMagPointMipLinear);

            case SamplerFilter.ComparisonMinMagLinearMipPoint:
                return(Filter.ComparisonMinMagLinearMipPoint);

            case SamplerFilter.ComparisonMinMagMipLinear:
                return(Filter.ComparisonMinMagMipLinear);

            case SamplerFilter.ComparisonAnisotropic:
                return(Filter.ComparisonAnisotropic);

            default:
                throw Illegal.Value <SamplerFilter>();
            }
        }
コード例 #2
0
ファイル: VkFormats.cs プロジェクト: SomeAnonDev/veldrid
        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>();
            }
        }
コード例 #3
0
        internal static void VeldridToGLTextureMinMagFilter(SamplerFilter filter, bool mip, out TextureMinFilter min, out TextureMagFilter mag)
        {
            switch (filter)
            {
            case SamplerFilter.MinMagMipPoint:
            case SamplerFilter.ComparisonMinMagMipPoint:
                min = mip ? TextureMinFilter.NearestMipmapNearest : TextureMinFilter.Nearest;
                mag = TextureMagFilter.Nearest;
                break;

            case SamplerFilter.MinMagPointMipLinear:
            case SamplerFilter.ComparisonMinMagPointMipLinear:
                min = mip ? TextureMinFilter.NearestMipmapLinear : TextureMinFilter.Nearest;
                mag = TextureMagFilter.Nearest;
                break;

            case SamplerFilter.MinPointMagLinearMipPoint:
            case SamplerFilter.ComparisonMinPointMagLinearMipPoint:
                min = mip ? TextureMinFilter.NearestMipmapNearest : TextureMinFilter.Nearest;
                mag = TextureMagFilter.Linear;
                break;

            case SamplerFilter.MinPointMagMipLinear:
            case SamplerFilter.ComparisonMinPointMagMipLinear:
                min = mip ? TextureMinFilter.NearestMipmapLinear : TextureMinFilter.Nearest;
                mag = TextureMagFilter.Linear;
                break;

            case SamplerFilter.MinLinearMagMipPoint:
            case SamplerFilter.ComparisonMinLinearMagMipPoint:
                min = mip ? TextureMinFilter.LinearMipmapNearest : TextureMinFilter.Linear;
                mag = TextureMagFilter.Nearest;
                break;

            case SamplerFilter.MinLinearMagPointMipLinear:
            case SamplerFilter.ComparisonMinLinearMagPointMipLinear:
                min = mip ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Linear;
                mag = TextureMagFilter.Nearest;
                break;

            case SamplerFilter.MinMagLinearMipPoint:
            case SamplerFilter.ComparisonMinMagLinearMipPoint:
                min = mip ? TextureMinFilter.LinearMipmapNearest : TextureMinFilter.Linear;
                mag = TextureMagFilter.Linear;
                break;

            case SamplerFilter.MinMagMipLinear:
            case SamplerFilter.ComparisonMinMagMipLinear:
                min = mip ? TextureMinFilter.LinearMipmapLinear : TextureMinFilter.Linear;
                mag = TextureMagFilter.Linear;
                break;

            case SamplerFilter.Anisotropic:
            case SamplerFilter.ComparisonAnisotropic:
                // TODO: This doesn't map to a min/mag filtering mode.
                min = TextureMinFilter.Nearest;
                mag = TextureMagFilter.Nearest;
                break;

            default:
                throw Illegal.Value <SamplerFilter>();
            }
        }
コード例 #4
0
ファイル: MTLFormats.cs プロジェクト: SomeAnonDev/veldrid
        internal static void GetMinMagMipFilter(
            SamplerFilter filter,
            out MTLSamplerMinMagFilter min,
            out MTLSamplerMinMagFilter mag,
            out MTLSamplerMipFilter mip)
        {
            switch (filter)
            {
            case SamplerFilter.Anisotropic:
                min = mag = MTLSamplerMinMagFilter.Linear;
                mip = MTLSamplerMipFilter.Linear;
                break;

            case SamplerFilter.MinLinear_MagLinear_MipLinear:
                min = MTLSamplerMinMagFilter.Linear;
                mag = MTLSamplerMinMagFilter.Linear;
                mip = MTLSamplerMipFilter.Linear;
                break;

            case SamplerFilter.MinLinear_MagLinear_MipPoint:
                min = MTLSamplerMinMagFilter.Linear;
                mag = MTLSamplerMinMagFilter.Linear;
                mip = MTLSamplerMipFilter.Nearest;
                break;

            case SamplerFilter.MinLinear_MagPoint_MipLinear:
                min = MTLSamplerMinMagFilter.Linear;
                mag = MTLSamplerMinMagFilter.Nearest;
                mip = MTLSamplerMipFilter.Linear;
                break;

            case SamplerFilter.MinLinear_MagPoint_MipPoint:
                min = MTLSamplerMinMagFilter.Linear;
                mag = MTLSamplerMinMagFilter.Nearest;
                mip = MTLSamplerMipFilter.Nearest;
                break;

            case SamplerFilter.MinPoint_MagLinear_MipLinear:
                min = MTLSamplerMinMagFilter.Nearest;
                mag = MTLSamplerMinMagFilter.Linear;
                mip = MTLSamplerMipFilter.Linear;
                break;

            case SamplerFilter.MinPoint_MagLinear_MipPoint:
                min = MTLSamplerMinMagFilter.Nearest;
                mag = MTLSamplerMinMagFilter.Linear;
                mip = MTLSamplerMipFilter.Nearest;
                break;

            case SamplerFilter.MinPoint_MagPoint_MipLinear:
                min = MTLSamplerMinMagFilter.Nearest;
                mag = MTLSamplerMinMagFilter.Nearest;
                mip = MTLSamplerMipFilter.Nearest;
                break;

            case SamplerFilter.MinPoint_MagPoint_MipPoint:
                min = MTLSamplerMinMagFilter.Nearest;
                mag = MTLSamplerMinMagFilter.Nearest;
                mip = MTLSamplerMipFilter.Nearest;
                break;

            default:
                throw Illegal.Value <SamplerFilter>();
            }
        }
コード例 #5
0
 public SamplerStateDescription(SamplerFilter filter)
 {
     Filter        = filter;
     MaxAnisotropy = 0;
 }
コード例 #6
0
 public static SamplerDescription AsDescription(this SamplerAddressMode addressMode, SamplerFilter filter) => new SamplerDescription()
 {
     AddressModeU = addressMode,
     AddressModeV = addressMode,
     AddressModeW = addressMode,
     Filter       = filter
 };
コード例 #7
0
            public unsafe InternalSamplerState(
                SamplerAddressMode addressU,
                SamplerAddressMode addressV,
                SamplerAddressMode addressW,
                SamplerFilter filter,
                int maxAnisotropy,
                RgbaFloat borderColor,
                DepthComparison comparison,
                int minLod,
                int maxLod,
                int lodBias,
                bool mip)
            {
                _samplerID = GL.GenSampler();

                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapR, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressU));
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapS, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressV));
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureWrapT, (int)OpenGLESFormats.VeldridToGLTextureWrapMode(addressW));
                Utilities.CheckLastGLError();

                if (addressU == SamplerAddressMode.Border || addressV == SamplerAddressMode.Border || addressW == SamplerAddressMode.Border)
                {
#pragma warning disable CS0618 // TextureBorderColor is not exposed on SamplerParameterName
                    GL.SamplerParameter(_samplerID, All.TextureBorderColor, (float *)&borderColor);
#pragma warning restore CS0618
                    Utilities.CheckLastGLError();
                }

                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinLod, (float)minLod);
                Utilities.CheckLastGLError();
                GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMaxLod, (float)maxLod);
                Utilities.CheckLastGLError();

                if (filter == SamplerFilter.Anisotropic || filter == SamplerFilter.ComparisonAnisotropic)
                {
#pragma warning disable CS0618 // TextureMaxAnisotropyExt is not exposed on SamplerParameterName
                    GL.SamplerParameter(_samplerID, All.TextureMaxAnisotropyExt, (float)maxAnisotropy);
#pragma warning restore CS0618 // Type or member is obsolete
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinFilter, mip ? (int)TextureMinFilter.LinearMipmapLinear : (int)TextureMinFilter.Linear);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                    Utilities.CheckLastGLError();
                }
                else
                {
                    OpenGLESFormats.VeldridToGLTextureMinMagFilter(filter, mip, out TextureMinFilter min, out TextureMagFilter mag);
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMinFilter, (int)min);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureMagFilter, (int)mag);
                    Utilities.CheckLastGLError();
                }

                if (s_comparisonFilters.Contains(filter))
                {
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureCompareMode, (int)All.CompareRefToTexture);
                    Utilities.CheckLastGLError();
                    GL.SamplerParameter(_samplerID, SamplerParameterName.TextureCompareFunc, (int)OpenGLESFormats.ConvertDepthComparison(comparison));
                    Utilities.CheckLastGLError();
                }
            }