[tint] do not emit space for binding group 0

D3D11 only supports HLSL SM5.0 which doesn't support `space`
(binding group in WGSL). So for D3D11, only one binding group will be
used, and tint will not emit `space` for HLSL, so shaders can be used
with D3D11.

Bug: dawn:1705
Change-Id: Ie0e9868137f10762c5243e188d76f5e41879c2bc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125080
Commit-Queue: Peng Huang <penghuang@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc
index 9ea120c..7f7f2e0 100644
--- a/src/tint/writer/hlsl/generator_impl.cc
+++ b/src/tint/writer/hlsl/generator_impl.cc
@@ -148,8 +148,14 @@
 };
 
 utils::StringStream& operator<<(utils::StringStream& s, const RegisterAndSpace& rs) {
-    s << " : register(" << rs.reg << rs.binding_point.binding << ", space" << rs.binding_point.group
-      << ")";
+    s << " : register(" << rs.reg << rs.binding_point.binding;
+    // Omit the space if it's 0, as it's the default.
+    // SM 5.0 doesn't support spaces, so we don't emit them if group is 0 for better compatibility.
+    if (rs.binding_point.group == 0) {
+        s << ")";
+    } else {
+        s << ", space" << rs.binding_point.group << ")";
+    }
     return s;
 }
 
@@ -3123,7 +3129,15 @@
 
     if (register_space) {
         auto bp = sem->As<sem::GlobalVariable>()->BindingPoint();
-        out << " : register(" << register_space << bp.binding << ", space" << bp.group << ")";
+        out << " : register(" << register_space << bp.binding;
+        // Omit the space if it's 0, as it's the default.
+        // SM 5.0 doesn't support spaces, so we don't emit them if group is 0 for better
+        // compatibility.
+        if (bp.group == 0) {
+            out << ")";
+        } else {
+            out << ", space" << bp.group << ")";
+        }
     }
 
     out << ";";