Beispiel #1
0
        public CPixelShader(ICDevice device, CShaderReflection reflection)
            : base(device, reflection)
        {
            profile = ParseProfile(reflection.Profile);

            var text = GenerateText();
            try
            {
                var bytecode = ShaderBytecode.Compile(text, "main", ProfileToString(profile), ShaderFlags.PackMatrixColumnMajor | ShaderFlags.OptimizationLevel3);
                d3dShader = new PixelShader(device.D3DDevice, bytecode);
                bytecode.Dispose();
            }
            catch (Exception e)
            {
                throw new ArgumentException(string.Format("Failed to compile a pixel shader '{0}'\r\n--- Code ---\r\n{1}\r\n--- Errors ---\r\n{2}", Name, text, e.Message), e);
            }
        }
Beispiel #2
0
 public static string ProfileToString(PixelShaderProfile profile)
 {
     switch (profile)
     {
         case PixelShaderProfile.ps_4_0: return "ps_4_0";
         case PixelShaderProfile.ps_4_1: return "ps_4_1";
         case PixelShaderProfile.ps_5_0: return "ps_5_0";
         default: throw new ArgumentOutOfRangeException("profile");
     }
 }