@@ -18,23 +18,37 @@ SLANG_UNIT_TEST(findAndCheckEntryPoint)
18
18
{
19
19
// Source for a module that contains an undecorated entrypoint.
20
20
const char * userSourceBody = R"(
21
- float4 fragMain(float4 pos:SV_Position) : SV_Target
22
- {
23
- return pos;
24
- }
21
+ RWStructuredBuffer<float> outputBuffer;
22
+
23
+ [numthreads(4, 1, 1)]
24
+ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
25
+ {
26
+ outputBuffer[dispatchThreadID.x] = float(dispatchThreadID.x);
27
+ }
25
28
)" ;
26
29
27
30
auto moduleName = " moduleG" + String (Process::getId ());
28
31
String userSource = " import " + moduleName + " ;\n " + userSourceBody;
29
32
ComPtr<slang::IGlobalSession> globalSession;
30
33
SLANG_CHECK (slang_createGlobalSession (SLANG_API_VERSION, globalSession.writeRef ()) == SLANG_OK);
31
34
slang::TargetDesc targetDesc = {};
32
- targetDesc.format = SLANG_CUDA_SOURCE;
33
- targetDesc.profile = globalSession->findProfile (" spirv_1_5" );
35
+ targetDesc.format = SLANG_PTX;
34
36
slang::SessionDesc sessionDesc = {};
35
37
sessionDesc.targetCount = 1 ;
36
38
sessionDesc.targets = &targetDesc;
37
39
ComPtr<slang::ISession> session;
40
+ List<slang::CompilerOptionEntry> sessionOptionEntries;
41
+ {
42
+ slang::CompilerOptionEntry entry = {};
43
+ entry.name = slang::CompilerOptionName::DumpIntermediates;
44
+ entry.value .kind = slang::CompilerOptionValueKind::Int;
45
+ entry.value .intValue0 = int (false );
46
+ sessionOptionEntries.add (entry);
47
+ }
48
+ sessionDesc.compilerOptionEntries = sessionOptionEntries.getBuffer ();
49
+ sessionDesc.compilerOptionEntryCount = sessionOptionEntries.getCount ();
50
+ targetDesc.compilerOptionEntries = sessionOptionEntries.getBuffer ();
51
+ targetDesc.compilerOptionEntryCount = sessionOptionEntries.getCount ();
38
52
SLANG_CHECK (globalSession->createSession (sessionDesc, session.writeRef ()) == SLANG_OK);
39
53
40
54
ComPtr<slang::IBlob> diagnosticBlob;
@@ -47,7 +61,7 @@ SLANG_UNIT_TEST(findAndCheckEntryPoint)
47
61
48
62
ComPtr<slang::IEntryPoint> entryPoint;
49
63
module->findAndCheckEntryPoint (
50
- " fragMain " ,
64
+ " computeMain " ,
51
65
SLANG_STAGE_COMPUTE,
52
66
entryPoint.writeRef (),
53
67
diagnosticBlob.writeRef ());
@@ -67,7 +81,9 @@ SLANG_UNIT_TEST(findAndCheckEntryPoint)
67
81
SLANG_CHECK (linkedProgram != nullptr );
68
82
69
83
ComPtr<slang::IBlob> code;
70
- linkedProgram->getEntryPointCode (0 , 0 , code.writeRef (), diagnosticBlob.writeRef ());
84
+ auto res = linkedProgram->getEntryPointCode (0 , 0 , code.writeRef (), diagnosticBlob.writeRef ());
85
+ if (res != SLANG_OK)
86
+ std::cout << " diagnostic: " << (char *)diagnosticBlob->getBufferPointer () << std::endl;
71
87
SLANG_CHECK (code != nullptr );
72
88
SLANG_CHECK (code->getBufferSize () != 0 );
73
89
0 commit comments