示例#1
0
 void IShaderCompiler.Compile(string text, string function, ref ShaderHandle result)
 {
     if(!result.IsValid || result.Reference != this)
     {
         Compile(text, function, out result);
     }
 }
示例#2
0
        public PixelShader Resolve(ShaderHandle shader)
        {
            if(shader.IsValid && shader.Reference == this)
            {
                return _Shaders[shader.Index];
            }

            return null;
        }
示例#3
0
        private void Compile(string text, string function, out ShaderHandle result)
        {
            Contract.Requires(!String.IsNullOrEmpty(text));
            Contract.Requires(!String.IsNullOrEmpty(function));

            const ShaderFlags flags = ShaderFlags.OptimizationLevel3;

            text = text.Insert(0, PredefinedConstants.ShaderText);

            using(var byteCode = ShaderBytecode.Compile(text, function, "ps_4_0", flags))
            {
                PixelShader shader = new PixelShader(_Device3D, byteCode);

                try
                {
                    _Shaders.Add(shader);
                }
                catch
                {
                    shader.Dispose();

                    throw;
                }

                _CachedShaderCount.Value = _Shaders.Count;
            }

            result = new ShaderHandle(_Shaders.Count - 1, this);
        }
示例#4
0
 public void Compile(string text, string function, ref ShaderHandle result)
 {
     Contract.Requires(!string.IsNullOrEmpty(text));
     Contract.Requires(!string.IsNullOrEmpty(function));
 }