Beispiel #1
0
        /// <summary>
        /// Function to compile the shader.
        /// </summary>
        /// <param name="macros">[Optional] A list of conditional compilation macro defintions to send to the shader.</param>
        /// <remarks>Whenever a shader is changed (i.e. its <see cref="GorgonLibrary.Graphics.GorgonShader.SourceCode">SourceCode</see> parameter is modified), this method should be called to build the shader.
        /// <para>If the <paramref name="macros"/> parameter is not NULL (Nothing in VB.Net), then a list of conditional compilation macro #define symbols will be sent to the shader.  This
        /// is handy when you wish to exclude parts of a shader upon compilation.  Please note that this parameter is only used if the <see cref="SourceCode"/> property is not NULL or empty.</para>
        /// </remarks>
        /// <exception cref="System.NotSupportedException">Thrown when the shader is not supported by the current supported feature level for the video hardware.</exception>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when the shader fails to compile.</exception>
        public void Compile(IList <GorgonShaderMacro> macros = null)
        {
            if (D3DByteCode != null)
            {
                D3DByteCode.Dispose();
                D3DByteCode = null;
            }

            if (!string.IsNullOrEmpty(SourceCode))
            {
                if (macros != null)
                {
                    _shaderMacros = new Common.ShaderMacro[macros.Count];

                    for (int i = 0; i < _shaderMacros.Length; i++)
                    {
                        _shaderMacros[i] = macros[i].Convert();
                    }
                }

                D3DByteCode = CompileFromSource(IsDebug);
            }

            Initialize();
        }
Beispiel #2
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                if (D3DByteCode != null)
                {
                    D3DByteCode.Dispose();
                }

                Graphics.RemoveTrackedObject(this);
            }

            D3DByteCode = null;
            _disposed   = true;
        }