예제 #1
0
        public D3D11Shader(ID3D11Device device, ShaderDescription description)
            : base(description.Stage, description.EntryPoint)
        {
            if (description.ShaderBytes.Length > 4 &&
                description.ShaderBytes[0] == 0x44 &&
                description.ShaderBytes[1] == 0x58 &&
                description.ShaderBytes[2] == 0x42 &&
                description.ShaderBytes[3] == 0x43)
            {
                Bytecode = Util.ShallowClone(description.ShaderBytes);
            }
            else
            {
                Bytecode = CompileCode(description);
            }

            switch (description.Stage)
            {
            case ShaderStages.Vertex:
                DeviceShader = device.CreateVertexShader(Bytecode);
                break;

            case ShaderStages.Geometry:
                DeviceShader = device.CreateGeometryShader(Bytecode);
                break;

            case ShaderStages.TessellationControl:
                DeviceShader = device.CreateHullShader(Bytecode);
                break;

            case ShaderStages.TessellationEvaluation:
                DeviceShader = device.CreateDomainShader(Bytecode);
                break;

            case ShaderStages.Fragment:
                DeviceShader = device.CreatePixelShader(Bytecode);
                break;

            case ShaderStages.Compute:
                DeviceShader = device.CreateComputeShader(Bytecode);
                break;

            default:
                throw Illegal.Value <ShaderStages>();
            }
        }