Skip to content

Commit 751e84f

Browse files
committed
more
1 parent b659bbb commit 751e84f

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

source/slang/slang-compiler-tu.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL ComponentType::getModuleDependency(
291291
{
292292
return SLANG_E_INVALID_ARG;
293293
}
294+
getModuleDependencies()[dependencyIndex]->addRef();
294295
*outModule = getModuleDependencies()[dependencyIndex];
295296
return SLANG_OK;
296297
}

tools/gfx/renderer-shared.cpp

+14-7
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,8 @@ void ShaderProgramBase::init(const IShaderProgram::Desc& inDesc)
11031103

11041104
Result ShaderProgramBase::compileShaders(RendererBase* device)
11051105
{
1106+
// Check target type from RenderBase device
1107+
auto compileTarget = device->slangContext.compileTarget;
11061108
// For a fully specialized program, read and store its kernel code in `shaderProgram`.
11071109
auto compileShader = [&](slang::EntryPointReflection* entryPointInfo,
11081110
slang::IComponentType* entryPointComponent,
@@ -1111,13 +1113,13 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
11111113
auto stage = entryPointInfo->getStage();
11121114
List<ComPtr<ISlangBlob>> kernelCodes;
11131115
{
1114-
ComPtr<ISlangBlob> spirv;
1116+
ComPtr<ISlangBlob> downstreamIR;
11151117
ComPtr<ISlangBlob> diagnostics;
11161118
auto compileResult = device->getEntryPointCodeFromShaderCache(
11171119
entryPointComponent,
11181120
entryPointIndex,
11191121
0,
1120-
spirv.writeRef(),
1122+
downstreamIR.writeRef(),
11211123
diagnostics.writeRef());
11221124
if (diagnostics)
11231125
{
@@ -1129,7 +1131,7 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
11291131
DebugMessageSource::Slang,
11301132
(char*)diagnostics->getBufferPointer());
11311133
}
1132-
kernelCodes.add(spirv);
1134+
kernelCodes.add(downstreamIR);
11331135
}
11341136

11351137
// If target precompilation was used, kernelCode may only represent the
@@ -1141,17 +1143,22 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
11411143
(void**)componentPrecompileService.writeRef()) == SLANG_OK)
11421144
{
11431145
SlangInt dependencyCount = componentPrecompileService->getModuleDependencyCount();
1146+
printf("There are %d dependencies\n", dependencyCount);
11441147
if (dependencyCount > 0)
11451148
{
11461149
for (int dependencyIndex = 0; dependencyIndex < dependencyCount; dependencyIndex++)
11471150
{
11481151
ComPtr<slang::IModule> dependencyModule;
11491152
{
11501153
ComPtr<slang::IBlob> diagnosticsBlob;
1154+
printf("dependency %d\n", dependencyIndex);
1155+
fflush(stdout);
11511156
auto result = componentPrecompileService->getModuleDependency(
11521157
dependencyIndex,
11531158
dependencyModule.writeRef(),
11541159
diagnosticsBlob.writeRef());
1160+
printf("not skippt get. did nto crash yet\n");
1161+
fflush(stdout);
11551162
if (diagnosticsBlob)
11561163
{
11571164
DebugMessageType msgType = DebugMessageType::Warning;
@@ -1165,7 +1172,7 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
11651172
SLANG_RETURN_ON_FAIL(result);
11661173
}
11671174

1168-
ComPtr<slang::IBlob> spirv;
1175+
ComPtr<slang::IBlob> downstreamIR;
11691176
{
11701177
ComPtr<slang::IBlob> diagnosticsBlob;
11711178
SlangResult result = SLANG_OK;
@@ -1177,12 +1184,12 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
11771184
{
11781185
ComPtr<slang::IBlob> diagnosticsBlob;
11791186
auto result = precompileService->getPrecompiledTargetCode(
1180-
SLANG_SPIRV,
1181-
spirv.writeRef(),
1187+
compileTarget,
1188+
downstreamIR.writeRef(),
11821189
diagnosticsBlob.writeRef());
11831190
if (result == SLANG_OK)
11841191
{
1185-
kernelCodes.add(spirv);
1192+
kernelCodes.add(downstreamIR);
11861193
}
11871194
if (diagnosticsBlob)
11881195
{

tools/gfx/slang-context.h

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class SlangContext
1010
public:
1111
Slang::ComPtr<slang::IGlobalSession> globalSession;
1212
Slang::ComPtr<slang::ISession> session;
13+
SlangCompileTarget compileTarget;
1314
Result initialize(
1415
const gfx::IDevice::SlangDesc& desc,
1516
uint32_t extendedDescCount,
@@ -27,6 +28,7 @@ class SlangContext
2728
SLANG_RETURN_ON_FAIL(slang::createGlobalSession(globalSession.writeRef()));
2829
}
2930

31+
this->compileTarget = compileTarget;
3032
slang::SessionDesc slangSessionDesc = {};
3133
slangSessionDesc.defaultMatrixLayoutMode = desc.defaultMatrixLayoutMode;
3234
slangSessionDesc.searchPathCount = desc.searchPathCount;

0 commit comments

Comments
 (0)