예제 #1
0
    public static byte[]? Compile(string source, ShaderStage stage, string entryPoint = "", string fileName = "")
    {
        if (string.IsNullOrEmpty(entryPoint))
        {
            entryPoint = GetDefaultEntryPoint(stage);
        }

        uint   flags         = 0;
        string shaderProfile = $"{GetShaderProfile(stage)}_5_0";
        Result hr            = D3DCompiler.D3DCompile(
            source,
            source.Length,
            fileName,
            null,
            0,
            entryPoint,
            shaderProfile,
            flags,
            0,
            out IDxcBlob blob,
            out IDxcBlob? errorMsgs);

        if (hr.Failure)
        {
            if (errorMsgs != null)
            {
                var errorText = GetStringFromBlob(errorMsgs);
            }
        }
        else
        {
            return(GetBytesFromBlob(blob));
        }

        return(null);
    }