From 41247c3942210df33b9e3dd733eafb23573a4f2f Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 8 Aug 2019 17:23:03 -0400 Subject: WIP: Preliminary Slang -> C++ code generation (#1009) * Expanded prelude for some other resource types. Disable C++ output for ParameterGroup. * WIP: Layout for CPU. * Fixes to CPU layout. * WIP: The uniform is output, but the variable definition is not. * WIP: Entry point parameters to global scope in C++. Handling of resource types (in so far as outputting) * Some discussion of ABI and different input types. * WIP: More C++ support around resource types. * WIP: Split up variables into different structures on emit. * WIP: Emitting C++ with wrapping up of 'Context' * WIP: C++ code has access to semantic values. Wrap in struct so can use method calls to pass shared state. Disable legalizeResourceTypes and legalizeExistentialTypeLayout * Fix structured buffer layout for CPU. * Remove testing/handling of global uniforms on CPU path. Typo fix. Changed CPU tests to use new CPU calling convention. * Check globals are working. Initalize context to zero globals. * Order the global parameters for C++ ouput by their layout. Note - that layout isn't quite working correctly because the StructuredBuffer the int seems to be consuming uniform space. * Work around for reflection not having all data needed for layout ordering for C++ code. * Output constant buffers as pointers. * Entry point parameters accessed through pointer to struct. * WIP: Layout for CPU is reasonable for test case. * Only output 'f' after float literal if type marks as a float. * Cast construction works on C++. * Made IntrinsicOp::ConvertConstruct to make intent clearer. * C++ handling construction from scalar. Handle access of a scalar with .x. Check default initialization. * Comment about need for split of kIROp_construct. Release build works. * Added support from constructVectorFromScalar to C/C++ target. * Handling of in/out in C/C++. * First pass documentation CPU support. * Improvements to C++/C slang code generation documentation. * Small doc change to include need for mechansim to specify cpp compiler path. * Better handling of swizzling - allow swizzling a scalar into a vector. --- tools/slang-test/slang-test-main.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 5e7a3d6f3..3235cc785 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -1130,7 +1130,7 @@ TestResult runCPUExecuteTest(TestContext* context, TestInput& input) StringBuilder actualOutput; - // TODO(JS): For moment just assume function name/data/paramters + // TODO(JS): For moment just assume function name/data/parameters { SharedLibrary::FuncPtr func = SharedLibrary::findFuncByName(sharedLibrary, "computeMain"); if (!func) @@ -1139,22 +1139,32 @@ TestResult runCPUExecuteTest(TestContext* context, TestInput& input) return TestResult::Fail; } - typedef void (*Func)(CPPPrelude::Vector threadID, CPPPrelude::RWStructuredBuffer buffer); + + struct UniformState + { + CPPPrelude::RWStructuredBuffer buffer; + }; + + typedef void (*Func)(CPPPrelude::ComputeVaryingInput* varyingInput, UniformState* uniformState); Func runFunc = Func(func); int32_t data[4] = { 0, 0, 0, 0}; - CPPPrelude::RWStructuredBuffer buffer{data, 4}; + UniformState state; + + state.buffer = CPPPrelude::RWStructuredBuffer{data, 4}; + + CPPPrelude::ComputeVaryingInput varyingInput = {}; for (Int i = 0; i < 4; ++i) { - CPPPrelude::Vector threadID{ uint32_t(i), 0, 0}; - runFunc(threadID, buffer); + varyingInput.groupThreadID.x = uint32_t(i); + runFunc(&varyingInput, &state); } SharedLibrary::unload(sharedLibrary); // Write the data - _writeBuffer(buffer, actualOutput); + _writeBuffer(state.buffer, actualOutput); } String expectedOutputPath = outputStem + ".expected"; @@ -1314,13 +1324,12 @@ static TestResult runCPPCompilerCompile(TestContext* context, TestInput& input) // need to execute the stand-alone Slang compiler on the file, and compare its output to what we expect - auto filePath999 = input.filePath; auto outputStem = input.outputStem; CommandLine cmdLine; _initSlangCompiler(context, cmdLine); - cmdLine.addArg(filePath999); + cmdLine.addArg(input.filePath); for (auto arg : input.testOptions->args) { -- cgit v1.2.3