public EffectData Rebuild()
        {
            // assemble the source text
            var source = GetSource();

            // compile the library
            var compilationResult = ShaderBytecode.Compile(source, "lib_5_0", ShaderFlags.OptimizationLevel3, EffectFlags.None);

            // if compilation failed - try to reset to the initial data and rebuild again
            if (compilationResult.HasErrors)
            {
                if (_isRebuildingAfterReset)
                    // something is messed up, we alraedy tried to rebuild once
                    throw new InvalidOperationException();

                try
                {
                    _isRebuildingAfterReset = true;

                    // reset the data
                    _data.Reset();
                    // rebuild
                    return Rebuild();
                }
                finally
                {
                    _isRebuildingAfterReset = false;
                }
            }

            var bytecode = compilationResult.Bytecode;

            // create the shader library module
            var shaderLibrary = new Module(bytecode);
            // create the shader library module instance
            var shaderLibraryInstance = new ModuleInstance(shaderLibrary);

            // mark the implicit constant buffer (for single parameter) as bindable
            shaderLibraryInstance.BindConstantBuffer(0, 0, 0);

            // assemble vertex shader
            var vertexShaderBytecode = AssembleVertexShader(shaderLibrary, shaderLibraryInstance);
            // assemble pixel shader
            var pixelShaderBytecode = AssemblePixelShader(shaderLibrary, shaderLibraryInstance);

            try
            {
                // assemble the effect data from the bytecodes
                return _effectCompiler.Compile(vertexShaderBytecode, pixelShaderBytecode);
            }
            finally
            {
                _data.IsDirty = false;
            }
        }