Skip to content

Commit b581f9d

Browse files
authored
[HLSL] Add option for VK layouts (#145327)
We add the options to the driver, so that the one option that is being implemented at this time can be used. Issue an error for the other options. When we start to implement the other options, we will have to figure out how to pass which option is active to clang. Part of but does not complete: #136956 #136959 #136958
1 parent 4847bd5 commit b581f9d

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9326,6 +9326,16 @@ def fspv_extension_EQ
93269326
Group<dxc_Group>,
93279327
HelpText<"Specify the available SPIR-V extensions. If this option is not "
93289328
"specified, then all extensions are available.">;
9329+
def fvk_use_dx_layout
9330+
: DXCFlag<"fvk-use-dx-layout">,
9331+
HelpText<"Use DirectX memory layout for Vulkan resources.">;
9332+
def fvk_use_gl_layout : DXCFlag<"fvk-use-gl-layout">,
9333+
HelpText<"Use strict OpenGL std140/std430 memory "
9334+
"layout for Vulkan resources.">;
9335+
def fvk_use_scalar_layout
9336+
: DXCFlag<"fvk-use-scalar-layout">,
9337+
HelpText<"Use scalar memory layout for Vulkan resources.">;
9338+
93299339
def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
93309340
Group<m_Group>,
93319341
HelpText<"Disable the wasm-opt optimizer">,

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ bool checkExtensionArgsAreValid(ArrayRef<std::string> SpvExtensionArgs,
200200
for (auto Extension : SpvExtensionArgs) {
201201
if (!isValidSPIRVExtensionName(Extension)) {
202202
Driver.Diag(diag::err_drv_invalid_value)
203-
<< "-fspv_extension" << Extension;
203+
<< "-fspv-extension" << Extension;
204204
AllValid = false;
205205
}
206206
}
@@ -330,6 +330,25 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, StringRef BoundArch,
330330
A->claim();
331331
continue;
332332
}
333+
334+
if (A->getOption().getID() == options::OPT_fvk_use_dx_layout) {
335+
// This is the only implemented layout so far.
336+
A->claim();
337+
continue;
338+
}
339+
340+
if (A->getOption().getID() == options::OPT_fvk_use_scalar_layout) {
341+
getDriver().Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
342+
A->claim();
343+
continue;
344+
}
345+
346+
if (A->getOption().getID() == options::OPT_fvk_use_gl_layout) {
347+
getDriver().Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args);
348+
A->claim();
349+
continue;
350+
}
351+
333352
DAL->append(A);
334353
}
335354

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// No errors. Otherwise nothing observable.
2+
// RUN: %clang_dxc -fvk-use-dx-layout -spirv -Tlib_6_7 -### %s
3+
4+
// RUN: not %clang_dxc -fvk-use-scalar-layout -spirv -Tlib_6_7 -### %s 2>&1 | FileCheck %s -check-prefix=SCALAR
5+
// SCALAR: error: the clang compiler does not support '-fvk-use-scalar-layout'
6+
7+
// RUN: not %clang_dxc -fvk-use-gl-layout -spirv -Tlib_6_7 -### %s 2>&1 | FileCheck %s -check-prefix=GL
8+
// GL: error: the clang compiler does not support '-fvk-use-gl-layout'

clang/test/Driver/dxc_fspv_extension.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
// Check for the error message if the extension name is not properly formed.
1414
// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL
15-
// FAIL: invalid value 'TEST1' in '-fspv_extension'
16-
// FAIL: invalid value 'TEST2' in '-fspv_extension'
15+
// FAIL: invalid value 'TEST1' in '-fspv-extension'
16+
// FAIL: invalid value 'TEST2' in '-fspv-extension'
1717

1818
// If targeting DXIL, the `-spirv-ext` should not be passed to the backend.
1919
// RUN: %clang_dxc -Tlib_6_7 -### %s 2>&1 | FileCheck %s -check-prefix=DXIL

0 commit comments

Comments
 (0)