diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-cpp.cpp | 49 | ||||
| -rw-r--r-- | source/slang/slang-ir-insts.h | 6 | ||||
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 11 |
3 files changed, 39 insertions, 27 deletions
diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index f71406261..7e70b73e2 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -2642,6 +2642,7 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module, DiagnosticSink* sink) if (auto entryPointDecoration = func->findDecoration<IREntryPointDecoration>()) { String entryPointName = entryPointDecoration->getName()->getStringSlice(); + String moduleName = entryPointDecoration->getModuleName()->getStringSlice(); for (int index = 0; index < program->getEntryPointCount(); index++) { auto entryPoint = program->getEntryPoint(index); @@ -2680,30 +2681,30 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module, DiagnosticSink* sink) else { - auto ptr = (const unsigned char*)blob->getBufferPointer(); + // auto ptr = (const unsigned char*)blob->getBufferPointer(); - m_writer->emit("size_t __"); - m_writer->emit(entryPointName); - m_writer->emit("Size = "); - m_writer->emitInt64(blob->getBufferSize()); - m_writer->emit(";\n"); + // m_writer->emit("size_t __"); + // m_writer->emit(entryPointName); + // m_writer->emit("Size = "); + // m_writer->emitInt64(blob->getBufferSize()); + // m_writer->emit(";\n"); - m_writer->emit("unsigned char __"); - m_writer->emit(entryPointName); - m_writer->emit("[] = {"); + // m_writer->emit("unsigned char __"); + // m_writer->emit(entryPointName); + // m_writer->emit("[] = {"); // every 20 bytes, emit a newline - size_t j = 0; - for (size_t i = 0; i < blob->getBufferSize(); i++) { - m_writer->emitUInt64(ptr[i]); - m_writer->emit(", "); - if (j == 20) - { - m_writer->emit("\n"); - j = 0; - } - j++; - } - m_writer->emit("};\n"); + // size_t j = 0; + // for (size_t i = 0; i < blob->getBufferSize(); i++) { + // m_writer->emitUInt64(ptr[i]); + // m_writer->emit(", "); + // if (j == 20) + // { + // m_writer->emit("\n"); + // j = 0; + // } + // j++; + // } + // m_writer->emit("};\n"); } } } @@ -2717,7 +2718,11 @@ void CPPSourceEmitter::emitModuleImpl(IRModule* module, DiagnosticSink* sink) m_writer->emit(", __"); m_writer->emit(entryPointName); m_writer->emit("Size);");*/ - m_writer->emit("\n\tgfx_ShaderProgram_0* shaderProgram = loadShaderProgram_0(device);"); + m_writer->emit("\n\tgfx_ShaderProgram_0* shaderProgram = loadShaderProgram_0(device, \""); + m_writer->emit(entryPointName); + m_writer->emit("\", \""); + m_writer->emit(moduleName); + m_writer->emit("\");"); m_writer->emit("\n\tgfx_TransientResourceHeap_0* transientHeap = buildTransientHeap_0(device);"); m_writer->emit("\n\tgfx_PipelineState_0* pipelineState = "); m_writer->emit("buildPipelineState_0(device, shaderProgram);"); diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index 049801db1..36ffcbbaf 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -360,6 +360,7 @@ struct IREntryPointDecoration : IRDecoration Profile getProfile() { return Profile(Profile::RawVal(getIntVal(getProfileInst()))); } IRStringLit* getName() { return cast<IRStringLit>(getOperand(1)); } + IRStringLit* getModuleName() { return cast<IRStringLit>(getOperand(2)); } }; struct IRGeometryInputPrimitiveTypeDecoration: IRDecoration @@ -2623,9 +2624,10 @@ struct IRBuilder addDecoration(value, kIROp_ExportDecoration, getStringValue(mangledName)); } - void addEntryPointDecoration(IRInst* value, Profile profile, UnownedStringSlice const& name) + void addEntryPointDecoration(IRInst* value, Profile profile, UnownedStringSlice const& name, UnownedStringSlice const& moduleName) { - addDecoration(value, kIROp_EntryPointDecoration, getIntValue(getIntType(), profile.raw), getStringValue(name)); + IRInst* operands[] = { getIntValue(getIntType(), profile.raw), getStringValue(name), getStringValue(moduleName) }; + addDecoration(value, kIROp_EntryPointDecoration, operands, SLANG_COUNT_OF(operands)); } void addKeepAliveDecoration(IRInst* value) diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index cde9fcc70..2c63520b6 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -7806,7 +7806,8 @@ LoweredValInfo emitDeclRef( static void lowerFrontEndEntryPointToIR( IRGenContext* context, - EntryPoint* entryPoint) + EntryPoint* entryPoint, + String moduleName) { // TODO: We should emit an entry point as a dedicated IR function // (distinct from the IR function used if it were called normally), @@ -7837,7 +7838,7 @@ static void lowerFrontEndEntryPointToIR( { Name* entryPointName = entryPoint->getFuncDecl()->getName(); - builder->addEntryPointDecoration(instToDecorate, entryPoint->getProfile(), entryPointName->text.getUnownedSlice()); + builder->addEntryPointDecoration(instToDecorate, entryPoint->getProfile(), entryPointName->text.getUnownedSlice(), moduleName.getUnownedSlice()); } // Go through the entry point parameters creating decorations from layout as appropriate @@ -8000,7 +8001,11 @@ IRModule* generateIRForTranslationUnit( // in case they require special handling. for (auto entryPoint : translationUnit->getEntryPoints()) { - lowerFrontEndEntryPointToIR(context, entryPoint); + List<SourceFile*> sources = translationUnit->getSourceFiles(); + SourceFile* source = sources.getFirst(); + PathInfo pInfo = source->getPathInfo(); + String path = pInfo.getMostUniqueIdentity(); + lowerFrontEndEntryPointToIR(context, entryPoint, Path::getFileNameWithoutExt(path)); } // |
