diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-04-27 17:53:21 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-27 17:53:21 -0400 |
| commit | 634f5414f332f904c7db968810b3d6f0ca253959 (patch) | |
| tree | c5747ca337e21ce74cc5997722b19a94604fe4aa | |
| parent | ec530b300524635dfe0fd86949b0a4fc5c19a984 (diff) | |
Make artifact an interface (#2195)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Compile to a dxil library.
* Added CompileProduct.
* Support handling of ModuleLibrary.
* CacheBehavior -> Cache
* Use CompileProduct for -r references.
* CompileProduct -> Artifact.
* Determining an artifact type on binding.
* Determine binary linkability.
* Added Artifact::exists.
* Added ArtifactKeep.
* Small fixes.
* Small improvements to Artifact.
* Add zip extension.
* Fix some comments.
* Fix multiple adding of PublicDecoration.
Make public output export for DXIL/lib.
Add checking for simpleDecorations such that only added once.
* Use 'whole program' to identify library build.
* Move slang-artifact into compiler-core.
* Split out Keep free functions.
* Artifact::Keep -> ArtifactKeep.
* Handle libraries as artifacts.
* Add -target dxil so test infrastructure knows it needs DXC.
* Linking working in DXC.
* Improve handling around emit for 'export'.
* Add comment around Artifact name.
* Render test working with linking.
* Improvements around Artifact handling.
* Add ArtifactPayloadInfo.
* Small tidy up around artifact.
* Split out code to get info about Artifacts into artifact-info.cpp/.h
* IArtifact interface and IArtifactInstance interface.
* Fix small issues.
* Fix compilation warning issue.
* Fix missing SLANG_OVERRIDE.
* Small fixes to make compilation work on Visual Studio 2022.
* Small improvements to Artifact interface/naming.
* Added Desc with each element in IArchive to allow more flexibility in usage.
* Fix clang warning issue.
* Add ArtifactPayload::Diagnostics
* More discussion around IArtifact usage.
* Re-add slang-artifact.h which was removed during merge.
* Fix typo identified in review.
25 files changed, 405 insertions, 307 deletions
diff --git a/source/compiler-core/slang-artifact-info.cpp b/source/compiler-core/slang-artifact-info.cpp index 6aaf1552c..1b9209516 100644 --- a/source/compiler-core/slang-artifact-info.cpp +++ b/source/compiler-core/slang-artifact-info.cpp @@ -66,6 +66,8 @@ static ArtifactPayloadInfo::Lookup _makePayloadInfoLookup() {Payload::DebugInfo, Flavor::Unknown, 0}, + {Payload::Diagnostics, Flavor::Unknown, 0}, + {Payload::Zip, Flavor::Container, 0}, }; @@ -245,4 +247,68 @@ UnownedStringSlice ArtifactInfoUtil::getDefaultExtension(const ArtifactDesc& des } } +/* static */String ArtifactInfoUtil::getBaseNameFromPath(const ArtifactDesc& desc, const UnownedStringSlice& path) +{ + String name = Path::getFileName(path); + + const bool isSharedLibraryPrefixPlatform = SLANG_LINUX_FAMILY || SLANG_APPLE_FAMILY; + if (isSharedLibraryPrefixPlatform) + { + // Strip lib prefix + if (ArtifactInfoUtil::isCpuBinary(desc) && + (desc.kind == ArtifactKind::Library || + desc.kind == ArtifactKind::SharedLibrary)) + { + // If it starts with lib strip it + if (name.startsWith("lib")) + { + const String stripLib = name.getUnownedSlice().tail(3); + name = stripLib; + } + } + } + + // Strip any extension + { + auto descExt = ArtifactInfoUtil::getDefaultExtension(desc); + // Strip the extension if it's a match + if (descExt.getLength() && + Path::getPathExt(name) == descExt) + { + name = Path::getFileNameWithoutExt(name); + } + } + + return name; +} + +/* static */String ArtifactInfoUtil::getBaseName(IArtifact* artifact) +{ + const auto pathType = artifact->getPathType(); + + // If we have a path, get the base name from that + if (pathType != ArtifactPathType::None) + { + UnownedStringSlice path(artifact->getPath()); + const auto desc = artifact->getDesc(); + + return getBaseNameFromPath(desc, path); + } + + // Else use the name + return artifact->getName(); +} + +/* static */String ArtifactInfoUtil::getParentPath(IArtifact* artifact) +{ + const auto pathType = artifact->getPathType(); + const auto path = artifact->getPath(); + + if (pathType != ArtifactPathType::None && *path != 0) + { + return Path::getParentDirectory(path); + } + return String(); +} + } // namespace Slang diff --git a/source/compiler-core/slang-artifact-info.h b/source/compiler-core/slang-artifact-info.h index 95de38cf6..1db3712dc 100644 --- a/source/compiler-core/slang-artifact-info.h +++ b/source/compiler-core/slang-artifact-info.h @@ -1,4 +1,4 @@ -// slang-artifact.h +// slang-artifact-info.h #ifndef SLANG_ARTIFACT_INFO_H #define SLANG_ARTIFACT_INFO_H @@ -89,6 +89,18 @@ struct ArtifactInfoUtil /// Get the extension for CPU/Host for a kind static UnownedStringSlice getCpuExtensionForKind(Kind kind); + + /// Given a desc and a path returns the base name (stripped of prefix and extension) + static String getBaseNameFromPath(const ArtifactDesc& desc, const UnownedStringSlice& path); + + /// Get the base name of this artifact. + /// If there is a path set, will extract the name from that (stripping prefix, extension as necessary). + /// Else if there is an explicit name set, this is returned. + /// Else returns the empty string + static String getBaseName(IArtifact* artifact); + + /// Get the parent path (empty if there isn't one) + static String getParentPath(IArtifact* artifact); }; } // namespace Slang diff --git a/source/compiler-core/slang-artifact.cpp b/source/compiler-core/slang-artifact.cpp index 862e7bb37..dfa9e645b 100644 --- a/source/compiler-core/slang-artifact.cpp +++ b/source/compiler-core/slang-artifact.cpp @@ -46,68 +46,24 @@ namespace Slang { /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Artifact !!!!!!!!!!!!!!!!!!!!!!!!!!! */ -Artifact::~Artifact() +void* Artifact::getInterface(const Guid& uuid) { - if (m_pathType == PathType::Temporary) - { - File::remove(m_path); - } - - for (const auto& entry : m_entries) + if (uuid == ISlangUnknown::getTypeGuid() || uuid == IArtifact::getTypeGuid()) { - // Release the associated data - switch (entry.type) - { - case Entry::Type::ObjectInstance: - { - entry.object->releaseReference(); - break; - } - case Entry::Type::InterfaceInstance: - { - entry.intf->release(); - break; - } - default: break; - } + return static_cast<IArtifact*>(this); } + return nullptr; } -Index Artifact::indexOf(Entry::Type type) const -{ - return m_entries.findFirstIndex([&](const Entry& entry) -> bool { return entry.type == type; }); -} - -void Artifact::add(Entry::Style style, RefObject* obj) -{ - SLANG_ASSERT(obj); - - Entry entry; - entry.type = Entry::Type::ObjectInstance; - entry.style = style; - entry.object = obj; - - obj->addReference(); - - m_entries.add(entry); -} - -void Artifact::add(Entry::Style style, ISlangUnknown* intf) +Artifact::~Artifact() { - // Can't be nullptr - SLANG_ASSERT(intf); - - Entry entry; - entry.type = Entry::Type::InterfaceInstance; - entry.style = style; - - intf->addRef(); - - entry.intf = intf; - m_entries.add(entry); + if (m_pathType == PathType::Temporary) + { + File::remove(m_path); + } } -bool Artifact::exists() const +bool Artifact::exists() { // If we have a blob it exists if (m_blob) @@ -116,13 +72,9 @@ bool Artifact::exists() const } // If we have an associated entry that represents the artifact it exists - for (const auto& entry : m_entries) + if (findElement(IArtifactInstance::getTypeGuid())) { - if (entry.style == Entry::Style::Artifact) - { - // There is a representation that 'is' the artifact - return true; - } + return true; } // If we don't have a path then it can't exist @@ -135,78 +87,55 @@ bool Artifact::exists() const return File::exists(m_path); } -ISlangUnknown* Artifact::findInterfaceInstance(const Guid& guid) +ISlangUnknown* Artifact::findElement(const Guid& guid) { - for (const auto& entry : m_entries) + for (auto const& element : m_elements) { - if (entry.type == Entry::Type::InterfaceInstance) - { - ISlangUnknown* intf = nullptr; - if (SLANG_SUCCEEDED(entry.intf->queryInterface(guid, (void**)&intf)) && intf) - { - // NOTE! This assumes we *DONT* need to ref count to keep an interface in scope - // (as strict COM requires so as to allow on demand interfaces). - intf->release(); + ISlangUnknown* value = element.value; - return intf; - } + ISlangUnknown* intf = nullptr; + if (SLANG_SUCCEEDED(value->queryInterface(guid, (void**)&intf)) && intf) + { + // NOTE! This assumes we *DONT* need to ref count to keep an interface in scope + // (as strict COM requires so as to allow on demand interfaces). + intf->release(); + return intf; } } return nullptr; } -/* static */String Artifact::getBaseNameFromPath(Desc& desc, const UnownedStringSlice& path) +void Artifact::addElement(const Desc& desc, ISlangUnknown* intf) +{ + SLANG_ASSERT(intf); + Element element{ desc, ComPtr<ISlangUnknown>(intf) }; + m_elements.add(element); +} + +void Artifact::removeElementAt(Index i) { - String name = Path::getFileName(path); + m_elements.removeAt(i); +} - const bool isSharedLibraryPrefixPlatform = SLANG_LINUX_FAMILY || SLANG_APPLE_FAMILY; - if (isSharedLibraryPrefixPlatform) +void* Artifact::findElementObject(const Guid& classGuid) +{ + ComPtr<IArtifactInstance> instance; + for (const auto& element : m_elements) { - // Strip lib prefix - if (ArtifactInfoUtil::isCpuBinary(desc) && - (desc.kind == ArtifactKind::Library || - desc.kind == ArtifactKind::SharedLibrary)) + ISlangUnknown* value = element.value; + + if (SLANG_SUCCEEDED(value->queryInterface(IArtifactInstance::getTypeGuid(), (void**)instance.writeRef())) && instance) { - // If it starts with lib strip it - if (name.startsWith("lib")) + void* classInstance = instance->queryObject(classGuid); + if (classInstance) { - const String stripLib = name.getUnownedSlice().tail(3); - name = stripLib; + return classInstance; } } } - // Strip any extension - { - auto descExt = ArtifactInfoUtil::getDefaultExtension(desc); - // Strip the extension if it's a match - if (descExt.getLength() && - Path::getPathExt(name) == descExt) - { - name = Path::getFileNameWithoutExt(name); - } - } - - return name; -} - -String Artifact::getBaseName() -{ - if (m_pathType != PathType::None) - { - return getBaseNameFromPath(m_desc, m_path.getUnownedSlice()); - } - return m_name; -} - -String Artifact::getParentPath() -{ - if (m_pathType != PathType::None && m_path.getLength()) - { - return Path::getParentDirectory(m_path); - } - return String(); + return nullptr; } SlangResult Artifact::requireFileLike(Keep keep) @@ -244,7 +173,7 @@ SlangResult Artifact::requireFile(Keep keep) ComPtr<ISlangBlob> blob; // Get the contents as a blob. If we can't do that, then we can't write anything... - SLANG_RETURN_ON_FAIL(loadBlob(getIntermediateKeep(keep), blob)); + SLANG_RETURN_ON_FAIL(loadBlob(getIntermediateKeep(keep), blob.writeRef())); // If we have a name, make the generated name based on that name // Else just use 'slang-generated' the basis @@ -303,41 +232,62 @@ SlangResult Artifact::requireFile(Keep keep) SLANG_RETURN_ON_FAIL(File::writeAllBytes(path, blob->getBufferPointer(), blob->getBufferSize())); // Okay we can now add this as temporary path too - setPath(PathType::Temporary, path); + _setPath(PathType::Temporary, path); return SLANG_OK; } -SlangResult Artifact::loadBlob(Keep keep, ComPtr<ISlangBlob>& outBlob) +SlangResult Artifact::loadBlob(Keep keep, ISlangBlob** outBlob) { - if (m_blob) - { - outBlob = m_blob; - return SLANG_OK; - } + ComPtr<ISlangBlob> blob(m_blob); - // TODO(JS): - // Strictly speaking we could *potentially* convert some other representation into - // a blob by serializing it, but we don't worry about any of that here - if (m_pathType == PathType::None) + if (!blob) { - return SLANG_E_NOT_FOUND; - } + // TODO(JS): + // Strictly speaking we could *potentially* convert some other representation into + // a blob by serializing it, but we don't worry about any of that here + if (m_pathType != PathType::None) + { + // Read into a blob + ScopedAllocation alloc; + SLANG_RETURN_ON_FAIL(File::readAllBytes(m_path, alloc)); - // Read into a blob - ScopedAllocation alloc; - SLANG_RETURN_ON_FAIL(File::readAllBytes(m_path, alloc)); + // Create as a blob + blob = RawBlob::moveCreate(alloc); + } + else + { + for (const auto& element : m_elements) + { + ISlangUnknown* intf = element.value; + + ComPtr<IArtifactInstance> inst; + if (SLANG_SUCCEEDED(intf->queryInterface(IArtifactInstance::getTypeGuid(), (void**)inst.writeRef())) && inst) + { + SlangResult res = inst->writeToBlob(blob.writeRef()); + if (SLANG_SUCCEEDED(res) && blob) + { + break; + } + } + } + } - // Create as a blob - RefPtr<RawBlob> blob = RawBlob::moveCreate(alloc); + // Wasn't able to construct - // Put in cache - if (canKeep(keep)) - { - setBlob(blob); + if (!blob) + { + return SLANG_E_NOT_FOUND; + } + + // Put in cache + if (canKeep(keep)) + { + setBlob(blob); + } } - outBlob = blob; + *outBlob = blob.detach(); return SLANG_OK; } diff --git a/source/compiler-core/slang-artifact.h b/source/compiler-core/slang-artifact.h index 1395c1b7c..91f8bec37 100644 --- a/source/compiler-core/slang-artifact.h +++ b/source/compiler-core/slang-artifact.h @@ -7,6 +7,8 @@ #include "../../slang-com-helper.h" #include "../../slang-com-ptr.h" +#include "../core/slang-com-object.h" + namespace Slang { @@ -21,7 +23,7 @@ enum class ArtifactKind : uint8_t Executable, ///< Self contained such it can exectuted. On GPU this would be a kernel. SharedLibrary, ///< Shared library/dll - Callable, ///< Callable directly (typically means there isn't a binary artifact) + Callable, ///< Callable directly (can mean there isn't a binary artifact) Text, ///< Text @@ -67,6 +69,8 @@ enum class ArtifactPayload : uint8_t DebugInfo, ///< Debug information + Diagnostics, ///< Diagnostics + Zip, ///< It's a zip CountOf, @@ -91,13 +95,6 @@ struct ArtifactFlag }; }; -// Controls what items can be kept. -enum class ArtifactKeep -{ - No, ///< Don't keep the item - Yes, ///< Yes keep the final item - All, ///< Keep the final item and any intermediataries -}; /** A value type to describe aspects of the contents of an Artifact. @@ -160,7 +157,53 @@ inline /* static */ArtifactDesc ArtifactDesc::make(Packed inPacked) return r; } -/* The Artifact type is a type designed to represent some Artifact of compilation. It could be input to or output from a compilation. + +// Controls what items can be kept. +enum class ArtifactKeep +{ + No, ///< Don't keep the item + Yes, ///< Yes keep the final item + All, ///< Keep the final item and any intermediataries +}; + +/// True if can keep an intermediate item +SLANG_INLINE bool canKeepIntermediate(ArtifactKeep keep) { return keep == ArtifactKeep::All; } +/// True if can keep +SLANG_INLINE bool canKeep(ArtifactKeep keep) { return Index(keep) >= Index(ArtifactKeep::Yes); } +/// Returns the keep type for an intermediate +SLANG_INLINE ArtifactKeep getIntermediateKeep(ArtifactKeep keep) { return (keep == ArtifactKeep::All) ? ArtifactKeep::All : ArtifactKeep::No; } + +enum ArtifactPathType +{ + None, + Temporary, + Existing, +}; + +/* The IArtifactInstance interface represents a single instance of a type that can be part of an artifact. It's special in so far +as + +* IArtifactInstance can be queried for it's underlying object class +* Can optionally serialize into a blob +*/ +class IArtifactInstance : public ISlangUnknown +{ + SLANG_COM_INTERFACE(0x311457a8, 0x1796, 0x4ebb, { 0x9a, 0xfc, 0x46, 0xa5, 0x44, 0xc7, 0x6e, 0xa9 }) + + /// Convert the instance into a serializable blob. + /// Returns SLANG_E_NOT_IMPLEMENTED if an implementation doesn't implement + virtual SLANG_NO_THROW SlangResult SLANG_MCALL writeToBlob(ISlangBlob** blob) = 0; + + /// Queries for the backing object type. The type is represented by a guid. + /// If the object doesn't derive from the type guid the function returns nullptr. + /// Unlike the analagous queryInterface method the ref count remains unchanged. + /// NOTE! + /// Whilst this method *could) be used across an ABI boundary (whereas using something like dynamic_cast would not), + /// it is generally dangerous to do so. + virtual SLANG_NO_THROW void* SLANG_MCALL queryObject(const Guid& classGuid) = 0; +}; + +/* The IArtifact interface is designed to represent some Artifact of compilation. It could be input to or output from a compilation. An abstraction is desirable here, because depending on the compiler the artifact/s could be @@ -170,11 +213,11 @@ An abstraction is desirable here, because depending on the compiler the artifact * Some other (perhaps multiple) in memory representations * A name -The artifact uses the Blob as the standard representation of in memory data. +The artifact uses the Blob as the canonical in memory representation. Some downstream compilers require the artifact to be available as a file system file, or to produce -artifacts that are files. The Artifact type allows to abstract away this difference, including the -ability to turn an in memory representation into a temporary file on the system file. +artifacts that are files. The IArtifact type allows to abstract away this difference, including the +ability to turn an in memory representation into a temporary file on the file system. The mechanism also allows for 'Containers' which allow for Artifacts to contain other Artifacts (amongst other things). Those artifacts may be other files. For example a downstream compilation that produces results as well as temporary @@ -185,15 +228,20 @@ files could be a Container containing artifacts for * Files that contain known types * Callable interface (an ISlangSharedLibrary) -A more long term goal would be to +Each one of these additions is an 'Element'. An Element is an interface pointer and a Desc that describes what the +inteface represents. Having the associated desc provides more detail about what the interface pointer actually is +without having to make the interface know what it is being used for. This allows an interface to be used in multiple +ways - for example the ISlangBlob interface could be used to represent some text, or a compiled kernel. + +A more long term goals would be to -* Make Artifact an interface (such that it can work long term over binary boundaries) * Make Diagnostics into an interface (such it can be added to a Artifact result) * Use Artifact and related types for downstream compiler */ -class Artifact : public RefObject +class IArtifact : public ISlangUnknown { public: + SLANG_COM_INTERFACE(0x57375e20, 0xbed, 0x42b6, { 0x9f, 0x5e, 0x59, 0x4f, 0x6, 0x2b, 0xe6, 0x90 }) typedef ArtifactDesc Desc; @@ -202,62 +250,20 @@ public: typedef ArtifactStyle Style; typedef ArtifactFlags Flags; typedef ArtifactKeep Keep; + typedef ArtifactPathType PathType; - enum PathType - { - None, - Temporary, - Existing, - }; - - /* A compile product can be made up of multiple representations. - */ - struct Entry - { - /// NOTE! Only interface innstances work across dll/shared library boundaries - /// because casting other types does not work across those boundaries. - - // The Type of the entry - enum class Type : uint8_t - { - InterfaceInstance, ///< An interface instance - ObjectInstance, ///< An object instance - RawInstance, - }; - enum class Style : uint8_t - { - Artifact, ///< Means this entry *can* represent the whole artifact - Child, ///< Some part of the artifact - Info, ///< Informational - Other, ///< Other - }; - - Type type; - Style style; - union - { - RefObject* object; - ISlangUnknown* intf; - void* raw; - }; - }; - - /// Given a type T find the associated instance - template <typename T> - T* findObjectInstance(); - - /// Finds an instance of that has the guid. - ISlangUnknown* findInterfaceInstance(const Guid& guid); + /// Get the Desc defining the contents of the artifact + virtual SLANG_NO_THROW Desc SLANG_MCALL getDesc() = 0; - /// Returns true if the artifact in principal exists (it could be invalid) - bool exists() const; + /// Returns true if the artifact in principal exists + virtual SLANG_NO_THROW bool SLANG_MCALL exists() = 0; /// Load as a blob - SlangResult loadBlob(Keep keep, ComPtr<ISlangBlob>& outBlob); + virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadBlob(Keep keep, ISlangBlob** outBlob) = 0; /// Require artifact is available as a file. /// NOTE! May need to serialize and write as a temporary file. - SlangResult requireFile(Keep keep); + virtual SLANG_NO_THROW SlangResult SLANG_MCALL requireFile(Keep keep) = 0; /// Require artifact is available in file-like scenarion. /// @@ -267,92 +273,122 @@ public: /// For example when system libraries are specified - the library paths may be known to /// a downstream compiler (or the path is passed in explicitly), in that case only the /// artifact name needs to be correct. - SlangResult requireFileLike(Keep keep); + virtual SLANG_NO_THROW SlangResult SLANG_MCALL requireFileLike(Keep keep) = 0; + + /// Finds an instance of that has the the interface guid + virtual SLANG_NO_THROW ISlangUnknown* SLANG_MCALL findElement(const Guid& guid) = 0; - /// Get the base name of this artifact. - /// If there is a path set, will extract the name from that (stripping prefix, extension as necessary). - /// Else if there is an explicit name set, this is returned. - /// Else returns the empty string - String getBaseName(); + /// Find an element that derives from IArtifactInstance, and which queryObject works with the classGuid + virtual SLANG_NO_THROW void* SLANG_MCALL findElementObject(const Guid& classGuid) = 0; - /// Get the parent path (empty if there isn't one) - String getParentPath(); + /// Add items + virtual SLANG_NO_THROW void SLANG_MCALL setPath(PathType pathType, const char* filePath) = 0; - /// Get the Desc defining the contents of the artifact - SLANG_FORCE_INLINE const Desc& getDesc() { return m_desc; } + /// Set the blob representing the contents of the asset + virtual SLANG_NO_THROW void SLANG_MCALL setBlob(ISlangBlob* blob) = 0; + + /// Get the path type + virtual SLANG_NO_THROW PathType SLANG_MCALL getPathType() = 0; + /// Get the path + virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() = 0; + + /// Get the name of the artifact. This can be empty. + virtual SLANG_NO_THROW const char* SLANG_MCALL getName() = 0; - /// Returns the index of the entry - Index indexOf(Entry::Type type) const; + /// Add an interface + virtual SLANG_NO_THROW void SLANG_MCALL addElement(const Desc& desc, ISlangUnknown* intf) = 0; - /// Add items - void setPath(PathType pathType, const String& filePath) { m_pathType = pathType; m_path = filePath; } + /// Get the item at the index + virtual SLANG_NO_THROW ISlangUnknown* SLANG_MCALL getElementAt(Index i) = 0; + /// Get the desc associated with an element + virtual SLANG_NO_THROW Desc SLANG_MCALL getElementDescAt(Index i) = 0; - /// Set the blob representing the contents of the asset - void setBlob(ISlangBlob* blob) { m_blob = blob; } + /// Remove the element at the specified index. + virtual SLANG_NO_THROW void SLANG_MCALL removeElementAt(Index i) = 0; - void add(Entry::Style style, RefObject* obj); - void add(Entry::Style style, ISlangUnknown* intf); + /// Get the amount of elements + virtual SLANG_NO_THROW Index SLANG_MCALL getElementCount() = 0; +}; - PathType getPathType() const { return m_pathType; } - const String& getPath() const { return m_path; } +/* +Discussion: - /// Get the name of the artifact. This can be empty. - const String& getName() const { return m_name; } +It could make sense to remove the explicit variables of a ISlangBlob, and the file backing from this interface, as they could +all be implemented as element types presumably deriving from IArtifactInstance. Doing so would mean how a 'file' is turned into +a blob is abstracted. - const List<Entry>& getEntries() const { return m_entries; } +It may be helpful to be able to add temporary files to the artifact (such that they will be deleted when the artifact goes out of +scope). Using an implementation of the File backed IArtifactInstance, with a suitable desc would sort of work, but it breaks the idea +that any IArtifactInstance *represents* the contents of Artifact that contains it. Of course there could be types *not* deriving +from IArtifactInstance that handle temporary file existance. This is probably the simplest answer to the problem. - /// Given a desc and a path returns the base name from the path (stripped of prefix and extension) - static String getBaseNameFromPath(Desc& desc, const UnownedStringSlice& path); +Another issue occurs around wanting to hold multiple kernels within a container. The problem here is that although through the desc +we can identify what target a kernel is for, there is no way of telling what stage it is for. - /// Ctor - Artifact(const Desc& desc, const String& name): +When discussing the idea of a shader cache, one idea was to use a ISlangFileSystem (which could actually be a zip, or directory or in memory rep) +as the main structure. Within this it can contain kernels, and then a json manifest can describe what each of these actually are. + +This all 'works', in that we can add an element of ISlangFileSystem with a desc of Container. Code that uses this can then go through the process +of finding, and getting the blob, and find from the manifest what it means. That does sound a little tedious though. Perhaps we just have an interface +that handles this detail, such that we search for that first. That interface is just attached to the artifact as an element. +*/ + +/* Implementation of the IArtifact interface */ +class Artifact : public ComObject, public IArtifact +{ +public: + + SLANG_COM_OBJECT_IUNKNOWN_ALL + + /// IArtifact impl + virtual SLANG_NO_THROW Desc SLANG_MCALL getDesc() SLANG_OVERRIDE { return m_desc; } + virtual SLANG_NO_THROW bool SLANG_MCALL exists() SLANG_OVERRIDE; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL loadBlob(Keep keep, ISlangBlob** outBlob) SLANG_OVERRIDE; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL requireFile(Keep keep) SLANG_OVERRIDE; + virtual SLANG_NO_THROW SlangResult SLANG_MCALL requireFileLike(Keep keep) SLANG_OVERRIDE; + virtual SLANG_NO_THROW ISlangUnknown* SLANG_MCALL findElement(const Guid& guid) SLANG_OVERRIDE; + virtual SLANG_NO_THROW void* SLANG_MCALL findElementObject(const Guid& classGuid) SLANG_OVERRIDE; + virtual SLANG_NO_THROW void SLANG_MCALL setPath(PathType pathType, const char* path) SLANG_OVERRIDE { _setPath(pathType, path); } + virtual SLANG_NO_THROW void SLANG_MCALL setBlob(ISlangBlob* blob) SLANG_OVERRIDE { m_blob = blob; } + virtual SLANG_NO_THROW PathType SLANG_MCALL getPathType() SLANG_OVERRIDE { return m_pathType; } + virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE { return m_path.getBuffer(); } + virtual SLANG_NO_THROW const char* SLANG_MCALL getName() SLANG_OVERRIDE { return m_name.getBuffer(); } + virtual SLANG_NO_THROW void SLANG_MCALL addElement(const Desc& desc, ISlangUnknown* intf) SLANG_OVERRIDE; + virtual SLANG_NO_THROW ISlangUnknown* SLANG_MCALL getElementAt(Index i) SLANG_OVERRIDE { return m_elements[i].value; } + virtual SLANG_NO_THROW Desc SLANG_MCALL getElementDescAt(Index i) SLANG_OVERRIDE { return m_elements[i].desc; } + virtual SLANG_NO_THROW void SLANG_MCALL removeElementAt(Index i) SLANG_OVERRIDE; + virtual SLANG_NO_THROW Index SLANG_MCALL getElementCount() SLANG_OVERRIDE { return m_elements.getCount(); } + + /// Ctor + Artifact(const Desc& desc, const String& name) : m_desc(desc), m_name(name) {} - /// Dtor + /// Dtor ~Artifact(); protected: - Desc m_desc; - String m_name; + void* getInterface(const Guid& uuid); + + void _setPath(PathType pathType, const String& path) { m_pathType = pathType; m_path = path; } + + struct Element + { + ArtifactDesc desc; + ComPtr<ISlangUnknown> value; + }; + + Desc m_desc; ///< Description of the artifact + String m_name; ///< Name of this artifact PathType m_pathType = PathType::None; ///< What the path indicates String m_path; ///< The path ComPtr<ISlangBlob> m_blob; ///< Blob to store result in memory - List<Entry> m_entries; + List<Element> m_elements; ///< Associated elements }; -// ---------------------------------------------------------------------- -template <typename T> -T* Artifact::findObjectInstance() -{ - RefObject* check = static_cast<T*>(nullptr); - SLANG_UNUSED(check); - - // Check if we already have it - for (const auto& entry : m_entries) - { - if (entry.type == Entry::Type::ObjectInstance) - { - auto obj = as<T>(entry.object); - if (obj) - { - return obj; - } - } - } - return nullptr; -} - -/// True if can keep an intermediate item -SLANG_INLINE bool canKeepIntermediate(ArtifactKeep keep) { return keep == ArtifactKeep::All; } - /// True if can keep -SLANG_INLINE bool canKeep(ArtifactKeep keep) { return Index(keep) >= Index(ArtifactKeep::Yes); } - /// Returns the keep type for an intermediate -SLANG_INLINE ArtifactKeep getIntermediateKeep(ArtifactKeep keep) { return (keep == ArtifactKeep::All) ? ArtifactKeep::All : ArtifactKeep::No; } - } // namespace Slang #endif diff --git a/source/compiler-core/slang-doc-extractor.cpp b/source/compiler-core/slang-doc-extractor.cpp index d26ed01d1..c2200cf37 100644 --- a/source/compiler-core/slang-doc-extractor.cpp +++ b/source/compiler-core/slang-doc-extractor.cpp @@ -447,8 +447,7 @@ SlangResult DocMarkupExtractor::_findMarkup(const FindInfo& info, Location locat out.reset(); const auto& toks = info.tokenList->m_tokens; - const Index tokIndex = info.tokenIndex; - + // The starting token index Index startIndex = _findStartIndex(info, location); if (startIndex <= 0) diff --git a/source/compiler-core/slang-downstream-compiler.h b/source/compiler-core/slang-downstream-compiler.h index e6c1f7a40..db89eeaf1 100644 --- a/source/compiler-core/slang-downstream-compiler.h +++ b/source/compiler-core/slang-downstream-compiler.h @@ -305,7 +305,7 @@ public: List<String> libraryPaths; /// Libraries to link against. - List<RefPtr<Artifact>> libraries; + List<ComPtr<IArtifact>> libraries; List<CapabilityVersion> requiredCapabilityVersions; diff --git a/source/compiler-core/slang-dxc-compiler.cpp b/source/compiler-core/slang-dxc-compiler.cpp index 0d05bf724..6375ba23a 100644 --- a/source/compiler-core/slang-dxc-compiler.cpp +++ b/source/compiler-core/slang-dxc-compiler.cpp @@ -19,6 +19,8 @@ #include "../core/slang-shared-library.h" +#include "../compiler-core/slang-artifact-info.h" + // Enable calling through to `dxc` to // generate code on Windows. #ifdef _WIN32 @@ -79,9 +81,9 @@ static UnownedStringSlice _addName(const UnownedStringSlice& inSlice, StringSlic } } -static UnownedStringSlice _addName(Artifact* artifact, StringSlicePool& pool) +static UnownedStringSlice _addName(IArtifact* artifact, StringSlicePool& pool) { - return _addName(artifact->getBaseName().getUnownedSlice(), pool); + return _addName(ArtifactInfoUtil::getBaseName(artifact).getUnownedSlice(), pool); } class DxcIncludeHandler : public IDxcIncludeHandler @@ -288,8 +290,8 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr } // Find all of the libraries - List<Artifact*> libraries; - for (Artifact* library : options.libraries) + List<IArtifact*> libraries; + for (IArtifact* library : options.libraries) { const auto desc = library->getDesc(); @@ -297,7 +299,7 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr { // Make sure they all have blobs ComPtr<ISlangBlob> libraryBlob; - SLANG_RETURN_ON_FAIL(library->loadBlob(ArtifactKeep::Yes, libraryBlob)); + SLANG_RETURN_ON_FAIL(library->loadBlob(ArtifactKeep::Yes, libraryBlob.writeRef())); libraries.add(library); } @@ -462,10 +464,10 @@ SlangResult DXCDownstreamCompiler::compile(const CompileOptions& options, RefPtr List<ComPtr<ISlangBlob>> libraryBlobs; List<OSString> libraryNames; - for (Artifact* library : libraries) + for (IArtifact* library : libraries) { ComPtr<ISlangBlob> blob; - SLANG_RETURN_ON_FAIL(library->loadBlob(ArtifactKeep::Yes, blob)); + SLANG_RETURN_ON_FAIL(library->loadBlob(ArtifactKeep::Yes, blob.writeRef())); libraryBlobs.add(blob); libraryNames.add(String(_addName(library, pool)).toWString()); diff --git a/source/compiler-core/slang-gcc-compiler-util.cpp b/source/compiler-core/slang-gcc-compiler-util.cpp index 554322198..ca1d8e8e3 100644 --- a/source/compiler-core/slang-gcc-compiler-util.cpp +++ b/source/compiler-core/slang-gcc-compiler-util.cpp @@ -631,7 +631,7 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse } // Artifacts might add library paths - for (Artifact* artifact : options.libraries) + for (IArtifact* artifact : options.libraries) { const auto desc = artifact->getDesc(); // If it's a library for CPU types, try and use it @@ -640,8 +640,8 @@ static SlangResult _parseGCCFamilyLine(const UnownedStringSlice& line, LineParse // Get the name and path (can be empty) to the library SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No)); - libPathPool.add(artifact->getParentPath()); - cmdLine.addPrefixPathArg("-l", artifact->getBaseName()); + libPathPool.add(ArtifactInfoUtil::getParentPath(artifact)); + cmdLine.addPrefixPathArg("-l", ArtifactInfoUtil::getBaseName(artifact)); } } diff --git a/source/compiler-core/slang-visual-studio-compiler-util.cpp b/source/compiler-core/slang-visual-studio-compiler-util.cpp index d70f7ca84..d0f748c76 100644 --- a/source/compiler-core/slang-visual-studio-compiler-util.cpp +++ b/source/compiler-core/slang-visual-studio-compiler-util.cpp @@ -260,7 +260,7 @@ namespace Slang } // Link libraries. - for (Artifact* artifact : options.libraries) + for (IArtifact* artifact : options.libraries) { auto desc = artifact->getDesc(); @@ -269,9 +269,9 @@ namespace Slang // Get the libray name and path SLANG_RETURN_ON_FAIL(artifact->requireFileLike(ArtifactKeep::No)); - libPathPool.add(artifact->getParentPath()); + libPathPool.add(ArtifactInfoUtil::getParentPath(artifact)); // We need the extension for windows - cmdLine.addArg(artifact->getBaseName() + ".lib"); + cmdLine.addArg(ArtifactInfoUtil::getBaseName(artifact) + ".lib"); } } diff --git a/source/core/slang-archive-file-system.cpp b/source/core/slang-archive-file-system.cpp index 8c4d0ef2d..0d998c849 100644 --- a/source/core/slang-archive-file-system.cpp +++ b/source/core/slang-archive-file-system.cpp @@ -96,6 +96,7 @@ void ImplicitDirectoryCollector::addRemainingPath(SlangPathType pathType, const } const Index countIndex = m_map.findOrAdd(pathRemainder, pathType); + SLANG_UNUSED(countIndex); // Make sure they are the same type SLANG_ASSERT(SlangPathType(m_map.getValueAt(countIndex)) == pathType); } diff --git a/source/core/slang-com-object.h b/source/core/slang-com-object.h index ad4578585..50dac5ba2 100644 --- a/source/core/slang-com-object.h +++ b/source/core/slang-com-object.h @@ -15,12 +15,13 @@ public: ComObject() : comRefCount(0) {} - ComObject(const ComObject&) : comRefCount(0) {} - ComObject& operator=(const ComObject&) - { - comRefCount = 0; - return *this; - }; + ComObject(const ComObject& rhs) : + RefObject(rhs), + comRefCount(0) + {} + + ComObject& operator=(const ComObject&) { return *this; } + virtual void comFree() {} uint32_t addRefImpl() diff --git a/source/core/slang-deflate-compression-system.cpp b/source/core/slang-deflate-compression-system.cpp index dab6654f7..6c75de9e4 100644 --- a/source/core/slang-deflate-compression-system.cpp +++ b/source/core/slang-deflate-compression-system.cpp @@ -50,7 +50,7 @@ SlangResult DeflateCompressionSystemImpl::compress(const CompressionStyle* style size_t compressedSizeInBytes; const int flags = 0; - void* compressed = tdefl_compress_mem_to_heap(src, srcSizeInBytes, &compressedSizeInBytes, 0); + void* compressed = tdefl_compress_mem_to_heap(src, srcSizeInBytes, &compressedSizeInBytes, flags); if (!compressed) { diff --git a/source/core/slang-lz4-compression-system.cpp b/source/core/slang-lz4-compression-system.cpp index fd360ce2e..4b8661534 100644 --- a/source/core/slang-lz4-compression-system.cpp +++ b/source/core/slang-lz4-compression-system.cpp @@ -56,6 +56,7 @@ SlangResult LZ4CompressionSystemImpl::compress(const CompressionStyle* style, co SlangResult LZ4CompressionSystemImpl::decompress(const void* compressed, size_t compressedSizeInBytes, size_t decompressedSizeInBytes, void* outDecompressed) { const int decompressedSize = LZ4_decompress_safe((const char*)compressed, (char*)outDecompressed, int(compressedSizeInBytes), int(decompressedSizeInBytes)); + SLANG_UNUSED(decompressedSize); SLANG_ASSERT(size_t(decompressedSize) == decompressedSizeInBytes); return SLANG_OK; } diff --git a/source/core/slang-smart-pointer.h b/source/core/slang-smart-pointer.h index a6aa35906..c473cca3c 100644 --- a/source/core/slang-smart-pointer.h +++ b/source/core/slang-smart-pointer.h @@ -24,7 +24,7 @@ namespace Slang : referenceCount(0) {} - RefObject& operator=(const RefObject& rhs) = default; + RefObject& operator=(const RefObject&) { return *this; } virtual ~RefObject() {} diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index edcb6e2d4..4445d9620 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -1286,7 +1286,7 @@ void printDiagnosticArg(StringBuilder& sb, CodeGenTarget val) { options.libraryPaths.add(Path::getParentDirectory(Path::getExecutablePath())); // Set up the library artifact - RefPtr<Artifact> artifact = new Artifact(ArtifactDesc::make(ArtifactKind::Library, Artifact::Payload::HostCPU), "slang-rt"); + ComPtr<IArtifact> artifact(new Artifact(ArtifactDesc::make(ArtifactKind::Library, Artifact::Payload::HostCPU), "slang-rt")); options.libraries.add(artifact); } } diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 74929d7da..d534e986a 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1808,7 +1808,7 @@ namespace Slang bool m_useFalcorCustomSharedKeywordSemantics = false; // Modules that have been read in with the -r option - List<RefPtr<Artifact>> m_libModules; + List<ComPtr<IArtifact>> m_libModules; void _stopRetainingParentSession() { diff --git a/source/slang/slang-emit-hlsl.cpp b/source/slang/slang-emit-hlsl.cpp index 03566f9df..650012b9f 100644 --- a/source/slang/slang-emit-hlsl.cpp +++ b/source/slang/slang-emit-hlsl.cpp @@ -736,7 +736,6 @@ void HLSLSourceEmitter::emitFuncDecorationImpl(IRDecoration* decoration) auto profile = m_effectiveProfile; const auto family = profile.getFamily(); - const auto stage = profile.getStage(); const auto version = profile.getVersion(); // If it's whole program and it's for a late enough version of shader model diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp index fd91d81bb..8c1edc032 100644 --- a/source/slang/slang-ir-link.cpp +++ b/source/slang/slang-ir-link.cpp @@ -1391,9 +1391,9 @@ LinkedIR linkIR( { irModules.add(irModule); }); - for (Artifact* artifact : linkage->m_libModules) + for (IArtifact* artifact : linkage->m_libModules) { - ModuleLibrary* library = artifact->findObjectInstance<ModuleLibrary>(); + ModuleLibrary* library = (ModuleLibrary*)artifact->findElementObject(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 76bb85ebb..140be4d64 100644 --- a/source/slang/slang-module-library.cpp +++ b/source/slang/slang-module-library.cpp @@ -13,6 +13,14 @@ namespace Slang { +void* ModuleLibrary::getInterface(const Guid& uuid) +{ + if (uuid == ISlangUnknown::getTypeGuid() || uuid == IArtifactInstance::getTypeGuid()) + { + return static_cast<IArtifactInstance*>(this); + } + return nullptr; +} SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary) { @@ -67,9 +75,9 @@ SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCo return SLANG_OK; } -SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary) +SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& outLibrary) { - if (auto foundLibrary = product->findObjectInstance<ModuleLibrary>()) + if (auto foundLibrary = (ModuleLibrary*)artifact->findElementObject(ModuleLibrary::getTypeGuid())) { outLibrary = foundLibrary; return SLANG_OK; @@ -77,7 +85,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndComp // Load the blob ComPtr<ISlangBlob> blob; - SLANG_RETURN_ON_FAIL(product->loadBlob(getIntermediateKeep(keep), blob)); + SLANG_RETURN_ON_FAIL(artifact->loadBlob(getIntermediateKeep(keep), blob.writeRef())); // Load the module RefPtr<ModuleLibrary> library; @@ -85,7 +93,7 @@ SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* product, EndToEndComp if (canKeep(keep)) { - product->add(Artifact::Entry::Style::Artifact, library); + artifact->addElement(artifact->getDesc(), library); } outLibrary = library; diff --git a/source/slang/slang-module-library.h b/source/slang/slang-module-library.h index dc709a684..7b65dad9e 100644 --- a/source/slang/slang-module-library.h +++ b/source/slang/slang-module-library.h @@ -10,18 +10,28 @@ namespace Slang { // Class to hold information serialized in from a -r slang-lib/slang-module -class ModuleLibrary : public RefObject +class ModuleLibrary : public ComObject, public IArtifactInstance { public: + SLANG_COM_OBJECT_IUNKNOWN_ALL + + SLANG_CLASS_GUID(0x2f7412bd, 0x6154, 0x40a9, { 0x89, 0xb3, 0x62, 0xe0, 0x24, 0x17, 0x24, 0xa1 }); + + // IArtifactInstance + 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; } + List<FrontEndCompileRequest::ExtraEntryPointInfo> m_entryPoints; List<RefPtr<IRModule>> m_modules; + + void* getInterface(const Guid& uuid); }; SlangResult loadModuleLibrary(const Byte* inBytes, size_t bytesCount, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& module); // Given a product make available as a module -SlangResult loadModuleLibrary(ArtifactKeep keep, Artifact* artifact, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& module); +SlangResult loadModuleLibrary(ArtifactKeep keep, IArtifact* artifact, EndToEndCompileRequest* req, RefPtr<ModuleLibrary>& module); } // namespace Slang diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 10980f216..c31006058 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -26,7 +26,7 @@ namespace Slang { -SlangResult _addLibraryReference(EndToEndCompileRequest* req, Artifact* artifact); +SlangResult _addLibraryReference(EndToEndCompileRequest* req, IArtifact* artifact); struct OptionsParser { @@ -1401,7 +1401,7 @@ struct OptionsParser CommandLineArg referenceModuleName; SLANG_RETURN_ON_FAIL(reader.expectArg(referenceModuleName)); - auto path = referenceModuleName.value; + const auto path = referenceModuleName.value; auto desc = ArtifactInfoUtil::getDescFromPath(path.getUnownedSlice()); @@ -1423,13 +1423,21 @@ struct OptionsParser return SLANG_FAIL; } - const String name = Artifact::getBaseNameFromPath(desc, referenceModuleName.value.getUnownedSlice()); + const String name = ArtifactInfoUtil::getBaseNameFromPath(desc, path.getUnownedSlice()); // Create the artifact - RefPtr<Artifact> artifact = new Artifact(desc, name); + ComPtr<IArtifact> artifact(new Artifact(desc, name)); - // Set the path - artifact->setPath(Artifact::PathType::Existing, referenceModuleName.value); + // There is a problem here if I want to reference a library that is a 'system' library or is not directly a file + // In that case the path shouldn't be set and the name should completely define the library. + // Seeing as on all targets the baseName doesn't have an extension, and all library types do + // if the name doesn't have an extension we can assume there is no path to it. + + if (Path::getPathExt(path).getLength() > 0) + { + // Set the path + artifact->setPath(Artifact::PathType::Existing, path.getBuffer()); + } // TODO(JS): We might want to check if the artifact exists. // If the artifact is a CPU (or downstream compiler) library diff --git a/source/slang/slang-serialize-ast.cpp b/source/slang/slang-serialize-ast.cpp index bbd8237d2..31a3f6ac0 100644 --- a/source/slang/slang-serialize-ast.cpp +++ b/source/slang/slang-serialize-ast.cpp @@ -107,6 +107,8 @@ struct ASTFieldAccess const size_t writtenSize = writtenEntry->calcSize(classes); const size_t readSize = readEntry->calcSize(classes); + SLANG_UNUSED(writtenSize); + SLANG_UNUSED(readSize); SLANG_ASSERT(readSize == writtenSize); // Check the payload is the same diff --git a/source/slang/slang-serialize-ir.cpp b/source/slang/slang-serialize-ir.cpp index 0824bd68d..221a97bc8 100644 --- a/source/slang/slang-serialize-ir.cpp +++ b/source/slang/slang-serialize-ir.cpp @@ -852,6 +852,7 @@ Result IRSerialReader::read(const IRSerialData& data, Session* session, SerialSo { const Ser::Inst& srcInst = data.m_insts[i]; const IROp op((IROp)srcInst.m_op); + SLANG_UNUSED(op); IRInst* dstInst = insts[i]; diff --git a/source/slang/slang-serialize.cpp b/source/slang/slang-serialize.cpp index a7074df1c..71ef303b7 100644 --- a/source/slang/slang-serialize.cpp +++ b/source/slang/slang-serialize.cpp @@ -487,6 +487,7 @@ SlangResult SerialWriter::write(Stream* stream) const size_t nextAlignment = SerialInfo::getAlignment(next->info); const size_t alignment = SerialInfo::getAlignment(entry->info); + SLANG_UNUSED(alignment); entry->info = SerialInfo::combineWithNext(entry->info, next->info); @@ -559,6 +560,7 @@ SlangResult SerialWriter::writeIntoContainer(FourCC fourCc, RiffContainer* conta const size_t nextAlignment = SerialInfo::getAlignment(next->info); const size_t alignment = SerialInfo::getAlignment(entry->info); + SLANG_UNUSED(alignment); entry->info = SerialInfo::combineWithNext(entry->info, next->info); diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 83c52c660..985599022 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4329,7 +4329,7 @@ void EndToEndCompileRequest::setDefaultModuleName(const char* defaultModuleName) frontEndReq->m_defaultModuleName = namePool->getName(defaultModuleName); } -SlangResult _addLibraryReference(EndToEndCompileRequest* req, Artifact* artifact) +SlangResult _addLibraryReference(EndToEndCompileRequest* req, IArtifact* artifact) { auto desc = artifact->getDesc(); @@ -4350,7 +4350,7 @@ SlangResult _addLibraryReference(EndToEndCompileRequest* req, Artifact* artifact // Add to the m_libModules auto linkage = req->getLinkage(); - linkage->m_libModules.add(artifact); + linkage->m_libModules.add(ComPtr<IArtifact>(artifact)); return SLANG_OK; } @@ -4366,7 +4366,7 @@ SlangResult EndToEndCompileRequest::addLibraryReference(const void* libData, siz // Create an artifact without any name (as one is not provided) RefPtr<Artifact> artifact = new Artifact(desc, String()); - artifact->add(Artifact::Entry::Style::Artifact, library); + artifact->addElement(desc, library); return _addLibraryReference(this, artifact); } |
