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/render-test-main.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'tools/render-test/render-test-main.cpp') diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp index 5feeeaf21..c04d6db00 100644 --- a/tools/render-test/render-test-main.cpp +++ b/tools/render-test/render-test-main.cpp @@ -99,9 +99,9 @@ public: Result applyBinding(PipelineType pipelineType, ICommandEncoder* encoder); void setProjectionMatrix(IShaderObject* rootObject); - Result writeBindingOutput(const char* fileName); + Result writeBindingOutput(const String& fileName); - Result writeScreen(const char* filename); + Result writeScreen(const String& filename); protected: /// Called in initialize @@ -652,12 +652,12 @@ void RenderTestApp::finalize() { } -Result RenderTestApp::writeBindingOutput(const char* fileName) +Result RenderTestApp::writeBindingOutput(const String& fileName) { // Wait until everything is complete m_queue->wait(); - FILE * f = fopen(fileName, "wb"); + FILE * f = fopen(fileName.getBuffer(), "wb"); if (!f) { return SLANG_FAIL; @@ -729,7 +729,7 @@ Result RenderTestApp::writeBindingOutput(const char* fileName) return SLANG_OK; } -Result RenderTestApp::writeScreen(const char* filename) +Result RenderTestApp::writeScreen(const String& filename) { size_t rowPitch, pixelSize; ComPtr blob; @@ -738,7 +738,7 @@ Result RenderTestApp::writeScreen(const char* filename) auto bufferSize = blob->getBufferSize(); uint32_t width = static_cast(rowPitch / pixelSize); uint32_t height = static_cast(bufferSize / rowPitch); - return PngSerializeUtil::write(filename, blob, width, height); + return PngSerializeUtil::write(filename.getBuffer(), blob, width, height); } Result RenderTestApp::update() @@ -768,7 +768,7 @@ Result RenderTestApp::update() m_queue->wait(); // If we are in a mode where output is requested, we need to snapshot the back buffer here - if (m_options.outputPath || m_options.performanceProfile) + if (m_options.outputPath.getLength() || m_options.performanceProfile) { // Wait until everything is complete @@ -807,7 +807,7 @@ Result RenderTestApp::update() _outputProfileTime(m_startTicks, endTicks); } - if (m_options.outputPath) + if (m_options.outputPath.getLength()) { if (m_options.shaderType == Options::ShaderProgramType::Compute || m_options.shaderType == Options::ShaderProgramType::GraphicsCompute) { @@ -909,8 +909,6 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi input.profile = ""; input.target = SLANG_TARGET_NONE; - input.args = &options.slangArgs[0]; - input.argCount = options.slangArgCount; SlangSourceLanguage nativeLanguage = SLANG_SOURCE_LANGUAGE_UNKNOWN; SlangPassThrough slangPassThrough = SLANG_PASS_THROUGH_NONE; @@ -1020,7 +1018,7 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi #endif // Use the profile name set on options if set - input.profile = options.profileName ? options.profileName : input.profile; + input.profile = options.profileName.getLength() ? options.profileName : input.profile; StringBuilder rendererName; auto info = @@ -1085,11 +1083,17 @@ static SlangResult _innerMain(Slang::StdWriters* stdWriters, SlangSession* sessi desc.requiredFeatures = requiredFeatureList.getBuffer(); desc.requiredFeatureCount = (int)requiredFeatureList.getCount(); - for (int i = 0; i < options.slangArgCount; i++) + + // Look for args going to slang { - if (UnownedStringSlice(options.slangArgs[i]) == "-matrix-layout-column-major") + const auto& args = options.downstreamArgs.getArgsByName("slang"); + for (const auto& arg : args) { - desc.slang.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR; + if (arg.value == "-matrix-layout-column-major") + { + desc.slang.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR; + break; + } } } -- cgit v1.2.3