Exemple #1
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectImplementation"/>.
        /// </summary>
        /// <param name="renderer">The D3D10 renderer.</param>
        /// <param name="shaderByteCode">The compiled shader byte code.</param>
        /// <param name="profileName">Name of the shader profile.</param>
        /// <param name="sFlags">The shader flags.</param>
        /// <param name="eFlags">The effect flags.</param>
        internal D3D10EffectImplementation(D3D10Renderer renderer, byte[] shaderByteCode, String profileName, D3DC.ShaderFlags sFlags, D3DC.EffectFlags eFlags)
        {
            _cachedByteCode = shaderByteCode;
            _renderer       = renderer;
            _graphicsDevice = _renderer.GraphicsDevice;
            _profileName    = profileName;
            _sFlags         = sFlags;
            _eFlags         = eFlags;
            _effect         = D3D.Effect.FromMemory(_graphicsDevice, _cachedByteCode, _profileName, _sFlags, _eFlags, null, null, null);

            //Add to resource tracker
            _renderer.Resources.AddTrackedObject(_effect.ComPointer, this);

            int techCount = _effect.Description.TechniqueCount;
            D3D10EffectTechniqueCollection techniques = new D3D10EffectTechniqueCollection();
            D3D10EffectParameterCollection parameters = new D3D10EffectParameterCollection();

            base.SetTechniques(techniques);
            base.SetParameters(parameters);

            for (int i = 0; i < techCount; i++)
            {
                D3D10EffectTechnique tech = new D3D10EffectTechnique(this, _effect, _effect.GetTechniqueByIndex(i));
                ((D3D10EffectTechniqueCollection)techniques).Add(tech);
            }

            //Set the current technique, the first one by default
            _currentTechnique = (D3D10EffectTechnique)techniques[0];
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of <see cref="D3D10EffectImplementation"/>. Used for cloning.
        /// </summary>
        /// <param name="cloneSource">The implementation source to clone from</param>
        /// <param name="profileName">Name of the shader profile.</param>
        /// <param name="sFlags">The shader flags.</param>
        /// <param name="eFlags">The effect flags.</param>
        internal D3D10EffectImplementation(D3D10EffectImplementation cloneSource, String profileName, D3DC.ShaderFlags sFlags, D3DC.EffectFlags eFlags)
        {
            _cachedByteCode = cloneSource._cachedByteCode;
            _renderer       = cloneSource._renderer;
            _graphicsDevice = cloneSource._graphicsDevice;
            _profileName    = profileName;
            _sFlags         = sFlags;
            _eFlags         = eFlags;
            _effect         = D3D.Effect.FromMemory(_graphicsDevice, _cachedByteCode, _profileName, _sFlags, _eFlags, null, null, null);

            //Add to resource tracker
            _renderer.Resources.AddTrackedObject(_effect.ComPointer, this);

            //Clone techniques and parameters
            D3D10EffectTechniqueCollection techniques = cloneSource.Techniques as D3D10EffectTechniqueCollection;
            D3D10EffectParameterCollection parameters = cloneSource.Parameters as D3D10EffectParameterCollection;

            base.SetTechniques(techniques.Clone(_effect, this));
            base.SetParameters(parameters.Clone(_effect));
            _currentTechnique = (D3D10EffectTechnique)base.Techniques[0];
        }