tint/cmd: Dump disassembly with --verbose

Change-Id: I2701117b6c253b632091a59fc1a63d97526d5ce2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97500
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/cmd/main.cc b/src/tint/cmd/main.cc
index 0c2bcdf..c38e6f9 100644
--- a/src/tint/cmd/main.cc
+++ b/src/tint/cmd/main.cc
@@ -868,9 +868,13 @@
         if (options.verbose) {
             if (fxc_found && !fxc_res.failed) {
                 std::cout << "Passed FXC validation" << std::endl;
+                std::cout << fxc_res.output;
+                std::cout << std::endl;
             }
             if (dxc_found && !dxc_res.failed) {
                 std::cout << "Passed DXC validation" << std::endl;
+                std::cout << dxc_res.output;
+                std::cout << std::endl;
             }
         }
     }
diff --git a/src/tint/val/hlsl.cc b/src/tint/val/hlsl.cc
index 18bded6..f1cfb05 100644
--- a/src/tint/val/hlsl.cc
+++ b/src/tint/val/hlsl.cc
@@ -114,13 +114,21 @@
         return result;
     }
 
-    pD3DCompile d3dCompile = reinterpret_cast<pD3DCompile>(
+    auto* d3dCompile = reinterpret_cast<pD3DCompile>(
         reinterpret_cast<void*>(GetProcAddress(fxcLib, "D3DCompile")));
+    auto* d3dDisassemble = reinterpret_cast<pD3DDisassemble>(
+        reinterpret_cast<void*>(GetProcAddress(fxcLib, "D3DDisassemble")));
+
     if (d3dCompile == nullptr) {
         result.output = "Couldn't load D3DCompile from FXC";
         result.failed = true;
         return result;
     }
+    if (d3dDisassemble == nullptr) {
+        result.output = "Couldn't load D3DDisassemble from FXC";
+        result.failed = true;
+        return result;
+    }
 
     for (auto ep : entry_points) {
         const char* profile = "";
@@ -147,21 +155,30 @@
 
         ComPtr<ID3DBlob> compiledShader;
         ComPtr<ID3DBlob> errors;
-        HRESULT cr = d3dCompile(source.c_str(),    // pSrcData
-                                source.length(),   // SrcDataSize
-                                nullptr,           // pSourceName
-                                nullptr,           // pDefines
-                                nullptr,           // pInclude
-                                ep.first.c_str(),  // pEntrypoint
-                                profile,           // pTarget
-                                compileFlags,      // Flags1
-                                0,                 // Flags2
-                                &compiledShader,   // ppCode
-                                &errors);          // ppErrorMsgs
-        if (FAILED(cr)) {
+        HRESULT res = d3dCompile(source.c_str(),    // pSrcData
+                                 source.length(),   // SrcDataSize
+                                 nullptr,           // pSourceName
+                                 nullptr,           // pDefines
+                                 nullptr,           // pInclude
+                                 ep.first.c_str(),  // pEntrypoint
+                                 profile,           // pTarget
+                                 compileFlags,      // Flags1
+                                 0,                 // Flags2
+                                 &compiledShader,   // ppCode
+                                 &errors);          // ppErrorMsgs
+        if (FAILED(res)) {
             result.output = static_cast<char*>(errors->GetBufferPointer());
             result.failed = true;
             return result;
+        } else {
+            ComPtr<ID3DBlob> disassembly;
+            res = d3dDisassemble(compiledShader->GetBufferPointer(),
+                                 compiledShader->GetBufferSize(), 0, "", &disassembly);
+            if (FAILED(res)) {
+                result.output = "failed to disassemble shader";
+            } else {
+                result.output = static_cast<char*>(disassembly->GetBufferPointer());
+            }
         }
     }