summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-compiler.cpp4
-rw-r--r--source/slang/slang-ir-link.cpp2
-rw-r--r--source/slang/slang-module-library.cpp22
-rw-r--r--source/slang/slang-module-library.h10
-rw-r--r--source/slang/slang-options.cpp6
-rw-r--r--source/slang/slang-parameter-binding.cpp2
-rw-r--r--source/slang/slang-type-layout.cpp2
-rw-r--r--source/slang/slang.cpp6
8 files changed, 36 insertions, 18 deletions
diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp
index d4c5812b7..8a9c322b2 100644
--- a/source/slang/slang-compiler.cpp
+++ b/source/slang/slang-compiler.cpp
@@ -1303,7 +1303,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
// If we aren't using LLVM 'host callable', we want downstream compile to produce a shared library
if (compilerType != PassThroughMode::LLVM &&
- ArtifactDesc::makeFromCompileTarget(asExternal(target)).kind == ArtifactKind::Callable)
+ ArtifactDesc::makeFromCompileTarget(asExternal(target)).kind == ArtifactKind::HostCallable)
{
target = CodeGenTarget::ShaderSharedLibrary;
}
@@ -1800,7 +1800,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val)
ComPtr<ISlangBlob> blob;
if (SLANG_FAILED(result.getBlob(blob)))
{
- if (ArtifactDesc::makeFromCompileTarget(asExternal(targetReq->getTarget())).kind == ArtifactKind::Callable)
+ if (ArtifactDesc::makeFromCompileTarget(asExternal(targetReq->getTarget())).kind == ArtifactKind::HostCallable)
{
// Some HostCallable are not directly representable as a 'binary'.
// So here, we just ignore if that appears the case, and don't output an unexpected error.
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index 14724046a..636a32a4d 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1411,7 +1411,7 @@ LinkedIR linkIR(
});
for (IArtifact* artifact : linkage->m_libModules)
{
- ModuleLibrary* library = (ModuleLibrary*)artifact->findElementObject(ModuleLibrary::getTypeGuid());
+ ModuleLibrary* library = (ModuleLibrary*)artifact->findItemObject(ModuleLibrary::getTypeGuid());
if (library)
{
irModules.addRange(library->m_modules.getBuffer()->readRef(), library->m_modules.getCount());
diff --git a/source/slang/slang-module-library.cpp b/source/slang/slang-module-library.cpp
index 140be4d64..b60555766 100644
--- a/source/slang/slang-module-library.cpp
+++ b/source/slang/slang-module-library.cpp
@@ -15,13 +15,27 @@ namespace Slang {
void* ModuleLibrary::getInterface(const Guid& uuid)
{
- if (uuid == ISlangUnknown::getTypeGuid() || uuid == IArtifactInstance::getTypeGuid())
+ if (uuid == ISlangUnknown::getTypeGuid() || uuid == ICastable::getTypeGuid() || uuid == IArtifactRepresentation::getTypeGuid())
{
- return static_cast<IArtifactInstance*>(this);
+ return static_cast<IArtifactRepresentation*>(this);
}
return nullptr;
}
+void* ModuleLibrary::getObject(const Guid& uuid)
+{
+ return uuid == getTypeGuid() ? this : nullptr;
+}
+
+void* ModuleLibrary::castAs(const Guid& guid)
+{
+ if (auto intf = getInterface(guid))
+ {
+ return intf;
+ }
+ return getObject(guid);
+}
+
SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary)
{
RefPtr<ModuleLibrary> library = new ModuleLibrary;
@@ -77,7 +91,7 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCo
SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary)
{
- if (auto foundLibrary = (ModuleLibrary*)artifact->findElementObject(ModuleLibrary::getTypeGuid()))
+ if (auto foundLibrary = (ModuleLibrary*)artifact->findItemObject(ModuleLibrary::getTypeGuid()))
{
outLibrary = foundLibrary;
return SLANG_OK;
@@ -93,7 +107,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCo
if (canKeep(keep))
{
- artifact->addElement(artifact->getDesc(), library);
+ artifact->addItem(library);
}
outLibrary = library;
diff --git a/source/slang/slang-module-library.h b/source/slang/slang-module-library.h
index 7b65dad9e..58d10bfc3 100644
--- a/source/slang/slang-module-library.h
+++ b/source/slang/slang-module-library.h
@@ -10,7 +10,7 @@ namespace Slang
{
// Class to hold information serialized in from a -r slang-lib/slang-module
-class ModuleLibrary : public ComObject, public IArtifactInstance
+class ModuleLibrary : public ComObject, public IArtifactRepresentation
{
public:
@@ -18,14 +18,18 @@ public:
SLANG_CLASS_GUID(0x2f7412bd, 0x6154, 0x40a9, { 0x89, 0xb3, 0x62, 0xe0, 0x24, 0x17, 0x24, 0xa1 });
- // IArtifactInstance
+ // ICastable
+ virtual SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;
+
+ // IArtifactRepresentation
virtual SLANG_NO_THROW SlangResult SLANG_MCALL writeToBlob(ISlangBlob** blob) SLANG_OVERRIDE { SLANG_UNUSED(blob); return SLANG_E_NOT_IMPLEMENTED; }
- virtual SLANG_NO_THROW void* SLANG_MCALL queryObject(const Guid& classGuid) SLANG_OVERRIDE { return classGuid == getTypeGuid() ? this : nullptr; }
+ virtual SLANG_NO_THROW bool SLANG_MCALL exists() SLANG_OVERRIDE { return true; }
List<FrontEndCompileRequest::ExtraEntryPointInfo> m_entryPoints;
List<RefPtr<IRModule>> m_modules;
void* getInterface(const Guid& uuid);
+ void* getObject(const Guid& uuid);
};
SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& module);
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 9825e4e23..f56395f5b 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -1467,12 +1467,12 @@ struct OptionsParser
}
// If it's a GPU binary, then we'll assume it's a library
- if (ArtifactInfoUtil::isGpuBinary(desc))
+ if (ArtifactInfoUtil::isGpuUsable(desc))
{
desc.kind = ArtifactKind::Library;
}
- if (!ArtifactInfoUtil::isBinaryLinkable(desc))
+ if (!ArtifactInfoUtil::isLinkable(desc))
{
sink->diagnose(referenceModuleName.loc, Diagnostics::kindNotLinkable, Path::getPathExt(path));
return SLANG_FAIL;
@@ -2036,7 +2036,7 @@ struct OptionsParser
// and output type is callable, add an empty' rawOutput.
if (rawOutputs.getCount() == 0 &&
rawTargets.getCount() == 1 &&
- ArtifactDesc::makeFromCompileTarget(asExternal(rawTargets[0].format)).kind == ArtifactKind::Callable)
+ ArtifactDesc::makeFromCompileTarget(asExternal(rawTargets[0].format)).kind == ArtifactKind::HostCallable)
{
RawOutput rawOutput;
rawOutput.impliedFormat = rawTargets[0].format;
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index d0b12b19b..220cfb992 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -3032,7 +3032,7 @@ static int _calcTotalNumUsedRegistersForLayoutResourceKind(ParameterBindingConte
static bool _isCPUTarget(CodeGenTarget target)
{
const auto desc = ArtifactDesc::makeFromCompileTarget(asExternal(target));
- return ArtifactInfoUtil::isCpuTarget(desc);
+ return ArtifactInfoUtil::isCpuLikeTarget(desc);
}
static bool _isPTXTarget(CodeGenTarget target)
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 09a21fb6f..cde70d488 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -1606,7 +1606,7 @@ bool isKhronosTarget(TargetRequest* targetReq)
bool isCPUTarget(TargetRequest* targetReq)
{
- return ArtifactInfoUtil::isCpuTarget(ArtifactDesc::makeFromCompileTarget(asExternal(targetReq->getTarget())));
+ return ArtifactInfoUtil::isCpuLikeTarget(ArtifactDesc::makeFromCompileTarget(asExternal(targetReq->getTarget())));
}
bool isCUDATarget(TargetRequest* targetReq)
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 891b9827a..b3762e471 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -727,7 +727,7 @@ SlangPassThrough Session::getDownstreamCompilerForTransition(SlangCompileTarget
const auto desc = ArtifactDesc::makeFromCompileTarget(inTarget);
// Special case host-callable
- if ((desc.kind == ArtifactKind::Callable) &&
+ if ((desc.kind == ArtifactKind::HostCallable) &&
(source == CodeGenTarget::CSource || source == CodeGenTarget::CPPSource))
{
// We prefer LLVM if it's available
@@ -4507,9 +4507,9 @@ SlangResult EndToEndCompileRequest::addLibraryReference(const void* libData, siz
const auto desc = ArtifactDesc::make(ArtifactKind::Library, ArtifactPayload::SlangIR);
// Create an artifact without any name (as one is not provided)
- RefPtr<Artifact> artifact = new Artifact(desc, String());
+ ComPtr<IArtifact> artifact(new Artifact(desc, String()));
- artifact->addElement(desc, library);
+ artifact->addItem(library);
return _addLibraryReference(this, artifact);
}