예제 #1
0
        /// <summary>
        /// Creates a new sampler state implementation.
        /// </summary>
        /// <returns>
        /// Sampler state implementation
        /// </returns>
        public SamplerStateImplementation CreateSamplerStateImplementation()
        {
            D3D10SamplerStateImplementation impl = new D3D10SamplerStateImplementation(_renderer);

            SetGraphicsID(impl);
            return(impl);
        }
        /// <summary>
        /// Flushes the collection's state to the device, only samplers that have been
        /// changed since the last draw call will get sent.
        /// </summary>
        internal void FlushState()
        {
            //Return if we haven't even touched these states, so we don't have to loop over them.
            if (!_shortCircuitUpdate)
            {
                return;
            }
            for (int i = 0; i < _maxSamplers; i++)
            {
                if (_dirtyMark[i])
                {
                    _dirtyMark[i] = false;

                    D3D.SamplerState ss    = null;
                    SamplerState     value = _samplers[i];
                    if (value != null)
                    {
                        D3D10SamplerStateImplementation impl = value.Implementation as D3D10SamplerStateImplementation;
                        ss = impl.D3D10SamplerState;
                    }

                    if (_vertexSamplers)
                    {
                        _graphicsDevice.VertexShader.SetSampler(ss, i);
                    }
                    else
                    {
                        _graphicsDevice.PixelShader.SetSampler(ss, i);
                    }
                }
            }
            _shortCircuitUpdate = false;
        }