internal static BlendingFactorSrc ConvertBlendSrc(Blend blend)
        {
            switch (blend)
            {
            case Blend.Zero:
                return(BlendingFactorSrc.Zero);

            case Blend.One:
                return(BlendingFactorSrc.One);

            case Blend.SourceAlpha:
                return(BlendingFactorSrc.SrcAlpha);

            case Blend.InverseSourceAlpha:
                return(BlendingFactorSrc.OneMinusSrcAlpha);

            case Blend.DestinationAlpha:
                return(BlendingFactorSrc.DstAlpha);

            case Blend.InverseDestinationAlpha:
                return(BlendingFactorSrc.OneMinusDstAlpha);

            case Blend.SourceColor:
                return(BlendingFactorSrc.SrcColor);

            case Blend.InverseSourceColor:
                return(BlendingFactorSrc.OneMinusSrcColor);

            case Blend.DestinationColor:
                return(BlendingFactorSrc.DstColor);

            case Blend.InverseDestinationColor:
                return(BlendingFactorSrc.OneMinusDstColor);

            case Blend.BlendFactor:
                return(BlendingFactorSrc.ConstantColor);

            case Blend.InverseBlendFactor:
                return(BlendingFactorSrc.OneMinusConstantColor);

            default:
                throw Illegal.Value <Blend>();
            }
        }
示例#2
0
        public static BlendOption ConvertBlend(Blend blendFactor)
        {
            switch (blendFactor)
            {
            case Blend.Zero:
                return(BlendOption.Zero);

            case Blend.One:
                return(BlendOption.One);

            case Blend.SourceAlpha:
                return(BlendOption.SourceAlpha);

            case Blend.InverseSourceAlpha:
                return(BlendOption.InverseSourceAlpha);

            case Blend.DestinationAlpha:
                return(BlendOption.DestinationAlpha);

            case Blend.InverseDestinationAlpha:
                return(BlendOption.InverseDestinationAlpha);

            case Blend.SourceColor:
                return(BlendOption.SourceColor);

            case Blend.InverseSourceColor:
                return(BlendOption.InverseSourceColor);

            case Blend.DestinationColor:
                return(BlendOption.DestinationColor);

            case Blend.InverseDestinationColor:
                return(BlendOption.InverseDestinationColor);

            case Blend.BlendFactor:
                return(BlendOption.BlendFactor);

            case Blend.InverseBlendFactor:
                return(BlendOption.InverseBlendFactor);

            default:
                throw Illegal.Value <Blend>();
            }
        }
示例#3
0
        internal static MTLBlendFactor VdToMTLBlendFactor(BlendFactor vdFactor)
        {
            switch (vdFactor)
            {
            case BlendFactor.Zero:
                return(MTLBlendFactor.Zero);

            case BlendFactor.One:
                return(MTLBlendFactor.One);

            case BlendFactor.SourceAlpha:
                return(MTLBlendFactor.SourceAlpha);

            case BlendFactor.InverseSourceAlpha:
                return(MTLBlendFactor.OneMinusSourceAlpha);

            case BlendFactor.DestinationAlpha:
                return(MTLBlendFactor.DestinationAlpha);

            case BlendFactor.InverseDestinationAlpha:
                return(MTLBlendFactor.OneMinusDestinationAlpha);

            case BlendFactor.SourceColor:
                return(MTLBlendFactor.SourceColor);

            case BlendFactor.InverseSourceColor:
                return(MTLBlendFactor.OneMinusSourceColor);

            case BlendFactor.DestinationColor:
                return(MTLBlendFactor.DestinationColor);

            case BlendFactor.InverseDestinationColor:
                return(MTLBlendFactor.OneMinusDestinationColor);

            case BlendFactor.BlendFactor:
                return(MTLBlendFactor.BlendColor);

            case BlendFactor.InverseBlendFactor:
                return(MTLBlendFactor.OneMinusBlendColor);

            default:
                throw Illegal.Value <BlendFactor>();
            }
        }
示例#4
0
        internal static BlendOption ToD3D11BlendOption(BlendFactor factor)
        {
            switch (factor)
            {
            case BlendFactor.Zero:
                return(BlendOption.Zero);

            case BlendFactor.One:
                return(BlendOption.One);

            case BlendFactor.SourceAlpha:
                return(BlendOption.SourceAlpha);

            case BlendFactor.InverseSourceAlpha:
                return(BlendOption.InverseSourceAlpha);

            case BlendFactor.DestinationAlpha:
                return(BlendOption.DestinationAlpha);

            case BlendFactor.InverseDestinationAlpha:
                return(BlendOption.InverseDestinationAlpha);

            case BlendFactor.SourceColor:
                return(BlendOption.SourceColor);

            case BlendFactor.InverseSourceColor:
                return(BlendOption.InverseSourceColor);

            case BlendFactor.DestinationColor:
                return(BlendOption.DestinationColor);

            case BlendFactor.InverseDestinationColor:
                return(BlendOption.InverseDestinationColor);

            case BlendFactor.BlendFactor:
                return(BlendOption.BlendFactor);

            case BlendFactor.InverseBlendFactor:
                return(BlendOption.BlendFactor);

            default:
                throw Illegal.Value <BlendFactor>();
            }
        }
示例#5
0
        internal static BlendingFactorDest VdToGLBlendFactorDest(BlendFactor factor)
        {
            switch (factor)
            {
            case BlendFactor.Zero:
                return(BlendingFactorDest.Zero);

            case BlendFactor.One:
                return(BlendingFactorDest.One);

            case BlendFactor.SourceAlpha:
                return(BlendingFactorDest.SrcAlpha);

            case BlendFactor.InverseSourceAlpha:
                return(BlendingFactorDest.OneMinusSrcAlpha);

            case BlendFactor.DestinationAlpha:
                return(BlendingFactorDest.DstAlpha);

            case BlendFactor.InverseDestinationAlpha:
                return(BlendingFactorDest.OneMinusDstAlpha);

            case BlendFactor.SourceColor:
                return(BlendingFactorDest.SrcColor);

            case BlendFactor.InverseSourceColor:
                return(BlendingFactorDest.OneMinusSrcColor);

            case BlendFactor.DestinationColor:
                return(BlendingFactorDest.DstColor);

            case BlendFactor.InverseDestinationColor:
                return(BlendingFactorDest.OneMinusDstColor);

            case BlendFactor.BlendFactor:
                return(BlendingFactorDest.ConstantColor);

            case BlendFactor.InverseBlendFactor:
                return(BlendingFactorDest.OneMinusConstantColor);

            default:
                throw Illegal.Value <BlendFactor>();
            }
        }
示例#6
0
        internal static VertexAttribPointerType VdToGLVertexAttribPointerType(VertexElementFormat format)
        {
            switch (format)
            {
            case VertexElementFormat.Float1:
            case VertexElementFormat.Float2:
            case VertexElementFormat.Float3:
            case VertexElementFormat.Float4:
                return(VertexAttribPointerType.Float);

            case VertexElementFormat.Byte1:
            case VertexElementFormat.Byte2:
            case VertexElementFormat.Byte4:
                return(VertexAttribPointerType.UnsignedByte);

            default:
                throw Illegal.Value <VertexElementFormat>();
            }
        }
示例#7
0
 internal static VkDescriptorType VdToVkDescriptorType(ResourceKind kind)
 {
     switch (kind)
     {
         case ResourceKind.UniformBuffer:
             return VkDescriptorType.UniformBuffer;
         case ResourceKind.StructuredBufferReadWrite:
         case ResourceKind.StructuredBufferReadOnly:
             return VkDescriptorType.StorageBuffer;
         case ResourceKind.TextureReadOnly:
             return VkDescriptorType.SampledImage;
         case ResourceKind.TextureReadWrite:
             return VkDescriptorType.StorageImage;
         case ResourceKind.Sampler:
             return VkDescriptorType.Sampler;
         default:
             throw Illegal.Value<ResourceKind>();
     }
 }
示例#8
0
        internal static PixelFormat ToVdFormat(Format format)
        {
            switch (format)
            {
            case Format.R8G8B8A8_UNorm:
                return(PixelFormat.R8_G8_B8_A8_UNorm);

            case Format.B8G8R8A8_UNorm:
                return(PixelFormat.B8_G8_R8_A8_UNorm);

            case Format.R8_UNorm:
                return(PixelFormat.R8_UNorm);

            case Format.R8G8_SNorm:
                return(PixelFormat.R8_G8_SNorm);

            case Format.R16_UNorm:
            case Format.D16_UNorm:
                return(PixelFormat.R16_UNorm);

            case Format.R32G32B32A32_Float:
                return(PixelFormat.R32_G32_B32_A32_Float);

            case Format.R32G32B32A32_UInt:
                return(PixelFormat.R32_G32_B32_A32_UInt);

            case Format.R32_Float:
                return(PixelFormat.R32_Float);

            case Format.D24_UNorm_S8_UInt:
                return(PixelFormat.D24_UNorm_S8_UInt);

            case Format.D32_Float_S8X24_UInt:
                return(PixelFormat.D32_Float_S8_UInt);

            case Format.D32_Float:
                return(PixelFormat.R32_Float);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
        internal static PixelInternalFormat MapPixelInternalFormat(PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R32_G32_B32_A32_Float:
                return(PixelInternalFormat.Rgba);

            case PixelFormat.R8_UInt:
                return(PixelInternalFormat.Alpha);

            case PixelFormat.R16_UInt:
                return(PixelInternalFormat.Alpha);

            case PixelFormat.R8_G8_B8_A8_UInt:
                return(PixelInternalFormat.Rgba);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#10
0
        private static string GetSemanticName(VertexSemanticType semanticType)
        {
            switch (semanticType)
            {
            case VertexSemanticType.Position:
                return("POSITION");

            case VertexSemanticType.TextureCoordinate:
                return("TEXCOORD");

            case VertexSemanticType.Normal:
                return("NORMAL");

            case VertexSemanticType.Color:
                return("COLOR");

            default:
                throw Illegal.Value <VertexSemanticType>();
            }
        }
示例#11
0
            public int GetAndIncrement(VertexSemanticType type)
            {
                switch (type)
                {
                case VertexSemanticType.Position:
                    return(_position++);

                case VertexSemanticType.TextureCoordinate:
                    return(_texCoord++);

                case VertexSemanticType.Normal:
                    return(_normal++);

                case VertexSemanticType.Color:
                    return(_color++);

                default:
                    throw Illegal.Value <VertexSemanticType>();
                }
            }
示例#12
0
        public static ShaderType VeldridToGLShaderType(ShaderStages type)
        {
            switch (type)
            {
            case ShaderStages.Vertex:
                return(ShaderType.VertexShader);

            case ShaderStages.Fragment:
                return(ShaderType.FragmentShader);

            case ShaderStages.TessellationControl:
            case ShaderStages.TessellationEvaluation:
            case ShaderStages.Geometry:
                // NOTE: OpenGL ES 3.2 supports Tessellation and Geometry shaders.
                throw new NotSupportedException($"Shaders of type {type} are not supported in OpenGL ES.");

            default:
                throw Illegal.Value <ShaderStages>();
            }
        }
示例#13
0
        internal static TextureAddressMode VdToD3D11AddressMode(SamplerAddressMode mode)
        {
            switch (mode)
            {
            case SamplerAddressMode.Wrap:
                return(TextureAddressMode.Wrap);

            case SamplerAddressMode.Mirror:
                return(TextureAddressMode.Mirror);

            case SamplerAddressMode.Clamp:
                return(TextureAddressMode.Clamp);

            case SamplerAddressMode.Border:
                return(TextureAddressMode.Border);

            default:
                throw Illegal.Value <SamplerAddressMode>();
            }
        }
示例#14
0
        public static VkSamplerAddressMode VeldridToVkSamplerAddressMode(SamplerAddressMode mode)
        {
            switch (mode)
            {
            case SamplerAddressMode.Wrap:
                return(VkSamplerAddressMode.Repeat);

            case SamplerAddressMode.Mirror:
                return(VkSamplerAddressMode.MirroredRepeat);

            case SamplerAddressMode.Clamp:
                return(VkSamplerAddressMode.ClampToEdge);

            case SamplerAddressMode.Border:
                return(VkSamplerAddressMode.ClampToBorder);

            default:
                throw Illegal.Value <SamplerAddressMode>();
            }
        }
示例#15
0
        /// <summary>
        /// Gets the size of an individual pixel data point for the given <see cref="PixelFormat"/>.
        /// </summary>
        /// <param name="format">The format of pixel data.</param>
        /// <returns>The size of an individual pixel in bytes.</returns>
        public static int GetSizeInBytes(this PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R32_G32_B32_A32_Float:
                return(sizeof(float) * 4);

            case PixelFormat.Alpha_UInt8:
                return(sizeof(byte));

            case PixelFormat.R8_G8_B8_A8:
                return(sizeof(byte) * 4);

            case PixelFormat.Alpha_UInt16:
                return(sizeof(ushort));

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#16
0
        private static WindowState OpenTKToVeldridState(OpenTK.WindowState openTKState, WindowBorder border)
        {
            switch (openTKState)
            {
            case OpenTK.WindowState.Normal:
                return(border == WindowBorder.Hidden ? WindowState.BorderlessFullScreen : WindowState.Normal);

            case OpenTK.WindowState.Minimized:
                return(WindowState.Minimized);

            case OpenTK.WindowState.Maximized:
                return(WindowState.Maximized);

            case OpenTK.WindowState.Fullscreen:
                return(WindowState.FullScreen);

            default:
                throw Illegal.Value <WindowState>();
            }
        }
示例#17
0
        private static OpenTK.WindowState VeldridToOpenTKState(WindowState state)
        {
            switch (state)
            {
            case WindowState.Normal:
                return(OpenTK.WindowState.Normal);

            case WindowState.FullScreen:
                return(OpenTK.WindowState.Fullscreen);

            case WindowState.Maximized:
                return(OpenTK.WindowState.Maximized);

            case WindowState.Minimized:
                return(OpenTK.WindowState.Minimized);

            default:
                throw Illegal.Value <WindowState>();
            }
        }
示例#18
0
        internal static SamplerAddressMode D3DToVeldridSamplerAddressMode(TextureAddressMode mode)
        {
            switch (mode)
            {
            case TextureAddressMode.Wrap:
                return(SamplerAddressMode.Wrap);

            case TextureAddressMode.Mirror:
                return(SamplerAddressMode.Mirror);

            case TextureAddressMode.Clamp:
                return(SamplerAddressMode.Clamp);

            case TextureAddressMode.Border:
                return(SamplerAddressMode.Border);

            default:
                throw Illegal.Value <TextureAddressMode>();
            }
        }
示例#19
0
 internal static VkSampleCountFlags VdToVkSampleCount(TextureSampleCount sampleCount)
 {
     switch (sampleCount)
     {
         case TextureSampleCount.Count1:
             return VkSampleCountFlags.Count1;
         case TextureSampleCount.Count2:
             return VkSampleCountFlags.Count2;
         case TextureSampleCount.Count4:
             return VkSampleCountFlags.Count4;
         case TextureSampleCount.Count8:
             return VkSampleCountFlags.Count8;
         case TextureSampleCount.Count16:
             return VkSampleCountFlags.Count16;
         case TextureSampleCount.Count32:
             return VkSampleCountFlags.Count32;
         default:
             throw Illegal.Value<TextureSampleCount>();
     }
 }
示例#20
0
        internal static TextureWrapMode VdToGLTextureWrapMode(SamplerAddressMode mode)
        {
            switch (mode)
            {
            case SamplerAddressMode.Wrap:
                return(TextureWrapMode.Repeat);

            case SamplerAddressMode.Mirror:
                return(TextureWrapMode.MirroredRepeat);

            case SamplerAddressMode.Clamp:
                return(TextureWrapMode.Clamp);

            case SamplerAddressMode.Border:
                return(TextureWrapMode.ClampToBorder);

            default:
                throw Illegal.Value <SamplerAddressMode>();
            }
        }
示例#21
0
            public static int GetAndIncrement(ref SemanticIndices si, VertexElementSemantic type)
            {
                switch (type)
                {
                case VertexElementSemantic.Position:
                    return(si._position++);

                case VertexElementSemantic.TextureCoordinate:
                    return(si._texCoord++);

                case VertexElementSemantic.Normal:
                    return(si._normal++);

                case VertexElementSemantic.Color:
                    return(si._color++);

                default:
                    throw Illegal.Value <VertexElementSemantic>();
                }
            }
示例#22
0
        private string GetSemanticString(VertexElementSemantic semantic)
        {
            switch (semantic)
            {
            case VertexElementSemantic.Position:
                return("POSITION");

            case VertexElementSemantic.Normal:
                return("NORMAL");

            case VertexElementSemantic.TextureCoordinate:
                return("TEXCOORD");

            case VertexElementSemantic.Color:
                return("COLOR");

            default:
                throw Illegal.Value <VertexElementSemantic>();
            }
        }
示例#23
0
        internal static MTLSamplerAddressMode VdToMTLAddressMode(SamplerAddressMode mode)
        {
            switch (mode)
            {
            case SamplerAddressMode.Border:
                return(MTLSamplerAddressMode.ClampToBorderColor);

            case SamplerAddressMode.Clamp:
                return(MTLSamplerAddressMode.ClampToEdge);

            case SamplerAddressMode.Mirror:
                return(MTLSamplerAddressMode.MirrorRepeat);

            case SamplerAddressMode.Wrap:
                return(MTLSamplerAddressMode.Repeat);

            default:
                throw Illegal.Value <SamplerAddressMode>();
            }
        }
示例#24
0
        internal static Format ConvertPixelFormat(PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R32_G32_B32_A32_Float:
                return(Format.R32G32B32A32_Float);

            case PixelFormat.R8_UInt:
                return(Format.R8_UInt);

            case PixelFormat.Alpha_UInt8:
                return(Format.A8_UNorm);

            case PixelFormat.R8_G8_B8_A8:
                return(Format.R8G8B8A8_UNorm);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#25
0
        public static int GetPixelSizeInBytes(PixelFormat veldridFormat)
        {
            switch (veldridFormat)
            {
            case PixelFormat.R32_G32_B32_A32_Float:
                return(16);

            case PixelFormat.R16_UInt:
                return(2);

            case PixelFormat.R8_G8_B8_A8_UInt:
            case PixelFormat.B8_G8_R8_A8_UInt:
                return(4);

            case PixelFormat.R8_UInt:
                return(1);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#26
0
        public static PixelType MapPixelType(PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R32_G32_B32_A32_Float:
                return(PixelType.Float);

            case PixelFormat.R8_UInt:
                return(PixelType.UnsignedByte);

            case PixelFormat.R16_UInt:
                return(PixelType.UnsignedShort);

            case PixelFormat.R8_G8_B8_A8_UInt:
            case PixelFormat.B8_G8_R8_A8_UInt:
                return(PixelType.UnsignedByte);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#27
0
        internal static TextureWrapMode VeldridToGLTextureWrapMode(SamplerAddressMode mode)
        {
            switch (mode)
            {
            case SamplerAddressMode.Wrap:
                return(TextureWrapMode.Repeat);

            case SamplerAddressMode.Mirror:
                Debug.WriteLine("SamplerAddressMode.Mirror is not supported on OpenGL ES.");
                return(TextureWrapMode.Clamp);

            case SamplerAddressMode.Clamp:
                return(TextureWrapMode.Clamp);

            case SamplerAddressMode.Border:
                return(TextureWrapMode.ClampToBorder);

            default:
                throw Illegal.Value <SamplerAddressMode>();
            }
        }
示例#28
0
        internal static GLPixelType VdToGLPixelType(PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R8_G8_B8_A8_UNorm:
            case PixelFormat.B8_G8_R8_A8_UNorm:
            case PixelFormat.R8_UNorm:
                return(GLPixelType.UnsignedByte);

            case PixelFormat.R8_G8_SNorm:
                return(GLPixelType.Byte);

            case PixelFormat.R16_UNorm:
                return(GLPixelType.UnsignedShort);

            case PixelFormat.R32_G32_B32_A32_Float:
                return(GLPixelType.Float);

            case PixelFormat.R32_G32_B32_A32_UInt:
                return(GLPixelType.UnsignedInt);

            case PixelFormat.R32_Float:
                return(GLPixelType.Float);

            case PixelFormat.BC1_Rgb_UNorm:
            case PixelFormat.BC1_Rgba_UNorm:
            case PixelFormat.BC2_UNorm:
            case PixelFormat.BC3_UNorm:
                return(GLPixelType.UnsignedByte);    // ?

            case PixelFormat.D32_Float_S8_UInt:
                return(GLPixelType.Float32UnsignedInt248Rev);

            case PixelFormat.D24_UNorm_S8_UInt:
                return(GLPixelType.UnsignedInt248);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }
示例#29
0
        /// <summary>
        /// Gets the number of individual vertex components from a given format.
        /// </summary>
        /// <param name="format">The vertex format.</param>
        /// <returns>The number of vertex components.</returns>
        public static byte GetElementCount(VertexElementFormat format)
        {
            switch (format)
            {
            case VertexElementFormat.Byte1:
            case VertexElementFormat.Float1:
                return(1);

            case VertexElementFormat.Float2:
                return(2);

            case VertexElementFormat.Float3:
                return(3);

            case VertexElementFormat.Float4:
            case VertexElementFormat.Byte4:
                return(4);

            default:
                throw Illegal.Value <VertexElementFormat>();
            }
        }
示例#30
0
        internal static GLPixelType VdToGLPixelType(PixelFormat format)
        {
            switch (format)
            {
            case PixelFormat.R8_G8_B8_A8_UNorm:
            case PixelFormat.B8_G8_R8_A8_UNorm:
            case PixelFormat.R8_UNorm:
                return(GLPixelType.UnsignedByte);

            case PixelFormat.R16_UNorm:
                return(GLPixelType.UnsignedShort);

            case PixelFormat.R32_G32_B32_A32_Float:
                return(GLPixelType.Float);

            case PixelFormat.R32_Float:
                return(GLPixelType.Float);

            default:
                throw Illegal.Value <PixelFormat>();
            }
        }