Пример #1
0
        internal void Apply(bool hasMipmap, SamplerState oldSamplerState, TextureTarget target)
        {
            if (Description.MinMipLevel != oldSamplerState.Description.MinMipLevel)
            {
                GL.TexParameter(target, TextureParameterName.TextureMinLod, Description.MinMipLevel);
            }
            if (Description.MaxMipLevel != oldSamplerState.Description.MaxMipLevel)
            {
                GL.TexParameter(target, TextureParameterName.TextureMaxLod, Description.MaxMipLevel);
            }
            if (textureWrapR != oldSamplerState.textureWrapR)
            {
                GL.TexParameter(target, TextureParameterName.TextureWrapR, (int)textureWrapR);
            }
            if (compareMode != oldSamplerState.compareMode)
            {
                GL.TexParameter(target, TextureParameterName.TextureCompareMode, (int)compareMode);
            }
            if (compareFunc != oldSamplerState.compareFunc)
            {
                GL.TexParameter(target, TextureParameterName.TextureCompareFunc, (int)compareFunc);
            }

#if !XENKO_GRAPHICS_API_OPENGLES
            if (borderColor != oldSamplerState.borderColor)
            {
                GL.TexParameter(target, TextureParameterName.TextureBorderColor, borderColor);
            }
            if (Description.MipMapLevelOfDetailBias != oldSamplerState.Description.MipMapLevelOfDetailBias)
            {
                GL.TexParameter(target, TextureParameterName.TextureLodBias, Description.MipMapLevelOfDetailBias);
            }
            if (minFilter != oldSamplerState.minFilter)
            {
                GL.TexParameter(target, TextureParameterName.TextureMinFilter, (int)minFilter);
            }
#else
            // On OpenGL ES, we need to choose the appropriate min filter ourself if the texture doesn't contain mipmaps (done at PreDraw)
            if (minFilter != oldSamplerState.minFilter)
            {
                GL.TexParameter(target, TextureParameterName.TextureMinFilter, hasMipmap ? (int)minFilter : (int)minFilterNoMipmap);
            }
#endif

#if !XENKO_PLATFORM_IOS
            if (maxAnisotropy != oldSamplerState.maxAnisotropy && GraphicsDevice.HasAnisotropicFiltering)
            {
                GL.TexParameter(target, (TextureParameterName)OpenTK.Graphics.ES20.ExtTextureFilterAnisotropic.TextureMaxAnisotropyExt, Description.MaxAnisotropy);
            }
#endif
            if (magFilter != oldSamplerState.magFilter)
            {
                GL.TexParameter(target, TextureParameterName.TextureMagFilter, (int)magFilter);
            }
            if (textureWrapS != oldSamplerState.textureWrapS)
            {
                GL.TexParameter(target, TextureParameterName.TextureWrapS, (int)textureWrapS);
            }
            if (textureWrapT != oldSamplerState.textureWrapT)
            {
                GL.TexParameter(target, TextureParameterName.TextureWrapT, (int)textureWrapT);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets (or creates) an entry to the DescriptorSetLayout and gets its index.
        /// </summary>
        /// <returns>The future entry index.</returns>
        public void AddBinding(ParameterKey key, string logicalGroup, EffectParameterClass @class, EffectParameterType type, int arraySize = 1, SamplerState immutableSampler = null)
        {
            hashBuilder.Write(key.Name);
            hashBuilder.Write(@class);
            hashBuilder.Write(arraySize);

            ElementCount += arraySize;
            Entries.Add(new Entry {
                Key = key, LogicalGroup = logicalGroup, Class = @class, Type = type, ArraySize = arraySize, ImmutableSampler = immutableSampler
            });
        }