From 34a1ff5226a526cc17c5baecd63637f69c324fc7 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Sat, 22 May 2021 16:03:30 -0400 Subject: Improvements in -X support (#1852) * #include an absolute path didn't work - because paths were taken to always be relative. * Added SourceLoc handling for command line parsing. * Fix typo in debug. * Fix issue around the DiagnosticSink used in options parsing not having a writer available - by having DiagnosticSink parenting. * Small rename for clarity. * WIP extracting command line args for downstream tools. * Unit tests/bug fixes around extracting args. * Use DownstreamArgs in the EndToEndCompileRequest * Passing downstream compiler options downstream. * Fix issue with endToEndReq being nullptr. * Fix issue with diagnostics number change. * Small improvements to how the source line is displayed if it's too long. Default to 120, as suggested in previous review. * Make render test use x-args parsing and CommandArgReader. * Added missing diagnostics. * More DownstreamArgs to linkage so can be seen by 'components'. Added dxc-x-arg test. * Used combination of name and args instead of two Lists, which whilst equivalent was perhaps a little confusing. * Added documentation for -X support. * Added test for x-args parsing diagnostic. Improved diagnostic with list of known names. * Fix issues from merge. * Fix lookup for -matrix-layout-column-major in render test. * Remove commented out line. --- tools/render-test/slang-support.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'tools/render-test/slang-support.cpp') diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index 5470ea35a..adfea337c 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -88,18 +88,21 @@ void ShaderCompilerUtil::Output::reset() out.session = session; // Parse all the extra args - if (request.compileArgs.getCount() > 0) { List args; - for (const auto& arg : request.compileArgs) + for (const auto& arg : options.downstreamArgs.getArgsByName("slang")) { - args.add(arg.getBuffer()); + args.add(arg.value.getBuffer()); + } + + if (args.getCount()) + { + SLANG_RETURN_ON_FAIL(spProcessCommandLineArguments(slangRequest, args.getBuffer(), int(args.getCount()))); } - SLANG_RETURN_ON_FAIL(spProcessCommandLineArguments(slangRequest, args.getBuffer(), int(args.getCount()))); } spSetCodeGenTarget(slangRequest, input.target); - spSetTargetProfile(slangRequest, 0, spFindProfile(session, input.profile)); + spSetTargetProfile(slangRequest, 0, spFindProfile(session, input.profile.getBuffer())); // Define a macro so that shader code in a test can detect what language we // are nominally working with. @@ -140,10 +143,7 @@ void ShaderCompilerUtil::Output::reset() spSetCompileFlags(slangRequest, SLANG_COMPILE_FLAG_NO_CODEGEN); } - // Process any additional command-line options specified for Slang using - // the `-xslang ` option to `render-test`. - SLANG_RETURN_ON_FAIL(spProcessCommandLineArguments(slangRequest, input.args, input.argCount)); - + const auto sourceLanguage = input.sourceLanguage; int translationUnitIndex = 0; @@ -322,7 +322,6 @@ void ShaderCompilerUtil::Output::reset() /* static */SlangResult ShaderCompilerUtil::compileWithLayout(SlangSession* session, const Options& options, const ShaderCompilerUtil::Input& input, OutputAndLayout& output) { String sourcePath = options.sourcePath; - auto& compileArgs = options.compileArgs; auto shaderType = options.shaderType; List sourceText; @@ -377,8 +376,6 @@ void ShaderCompilerUtil::Output::reset() ShaderCompileRequest compileRequest; - compileRequest.compileArgs = compileArgs; - compileRequest.source = sourceInfo; // Now we will add the "default" entry point names/stages that -- cgit v1.2.3