Skip to content

Commit 916bef7

Browse files
committed
Shader stage mitigation & fix issue with heap alloc
1 parent 3f625cb commit 916bef7

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/nbl/asset/interchange/CHLSLLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ SAssetBundle CHLSLLoader::loadAsset(system::IFile* _file, const IAssetLoader::SA
4343
// return {};
4444
//}
4545

46-
auto shader = core::make_smart_refctd_ptr<ICPUShader>(reinterpret_cast<char*>(source), IShader::ESS_UNKNOWN, IShader::E_CONTENT_TYPE::ECT_HLSL, filename.string());
46+
auto shader = core::make_smart_refctd_ptr<ICPUShader>(reinterpret_cast<char*>(source), IShader::ESS_COMPUTE, IShader::E_CONTENT_TYPE::ECT_HLSL, filename.string());
4747
_NBL_ALIGNED_FREE(source);
4848

4949
return SAssetBundle(nullptr,{ core::make_smart_refctd_ptr<ICPUSpecializedShader>(std::move(shader),ISpecializedShader::SInfo({},nullptr,"main")) });

src/nbl/asset/utils/CHLSLCompiler.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ CHLSLCompiler::DxcCompilationResult CHLSLCompiler::dxcCompile(std::string& sourc
5353
insertion << "\n";
5454
insertIntoStart(source, std::move(insertion));
5555
}
56+
57+
IDxcBlobEncoding* src;
58+
auto res = m_dxcUtils->CreateBlob(reinterpret_cast<const void*>(source.data()), source.size(), CP_UTF8, &src);
59+
assert(SUCCEEDED(res));
5660

5761
DxcBuffer sourceBuffer;
58-
sourceBuffer.Ptr = source.data();
59-
sourceBuffer.Size = source.size();
62+
sourceBuffer.Ptr = src->GetBufferPointer();
63+
sourceBuffer.Size = src->GetBufferSize();
6064
sourceBuffer.Encoding = 0;
6165

6266
IDxcResult* compileResult;
63-
auto res = m_dxcCompiler->Compile(&sourceBuffer, args, argCount, nullptr, IID_PPV_ARGS(&compileResult));
67+
res = m_dxcCompiler->Compile(&sourceBuffer, args, argCount, nullptr, IID_PPV_ARGS(&compileResult));
6468
// If the compilation failed, this should still be a successful result
6569
assert(SUCCEEDED(res));
6670

@@ -149,8 +153,8 @@ core::smart_refctd_ptr<ICPUShader> CHLSLCompiler::compileToSPIRV(const char* cod
149153
L"-Qembed_debug" //Embeds debug information
150154
};
151155

152-
const uint32_t nonDebugArgs = 3;
153-
const uint32_t allArgs = nonDebugArgs + 1;
156+
const uint32_t nonDebugArgs = 5;
157+
const uint32_t allArgs = nonDebugArgs + 2;
154158

155159
DxcCompilationResult compileResult = dxcCompile(newCode, &arguments[0], hlslOptions.genDebugInfo ? allArgs : nonDebugArgs, hlslOptions);
156160

0 commit comments

Comments
 (0)