<feed xmlns='http://www.w3.org/2005/Atom'>
<title>slang.git/source/core/slang-file-system.h, branch master</title>
<subtitle>Making it easier to work with shaders</subtitle>
<id>https://git.yummers.dev/slang.git/atom?h=master</id>
<link rel='self' href='https://git.yummers.dev/slang.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/'/>
<updated>2025-06-06T17:48:06+00:00</updated>
<entry>
<title>Disable Link-Time-Optimization by default (#7345)</title>
<updated>2025-06-06T17:48:06+00:00</updated>
<author>
<name>Jay Kwak</name>
<email>82421531+jkwak-work@users.noreply.github.com</email>
</author>
<published>2025-06-06T17:48:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=7f04adbfb9dc0c39c372809ea02cc740d484b291'/>
<id>urn:sha1:7f04adbfb9dc0c39c372809ea02cc740d484b291</id>
<content type='text'>
* Disable Link-Time-Optimization by default

LTO was requested for the release package a while ago.
When we added it, LTO was enabled by default although it was needed only for
the release packages.

Later we found that the Release build cannot be incrementally recompiled
when LTO is enabled. It sometimes works fine, but it required full recompilation
when it doesn't work. We added a new CMake option, `SLANG_ENABLE_RELEASE_LTO`,
to disable it for developers. But many Slang developers don't know the
option exists.

I was going to update the document, CONTRIBUTING.md, but I thought it
will be better to change the default behavior.

* Fix a compiler warning treated as an error on linux

A padding variable was uninitialized, which is fine, but the compiler
was complaining about it.

* Fix other gcc error for uninitialized variable

* Fix more compile warning treated as error

* Fix compiler warning from gcc 11

It appears that this is a valid warning that the `delete this` is done
on an offset 8 when the class uses multiple inheritance.

The compiler warning is following:
```
In file included from /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:5,
                 from /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:3:
In destructor ‘virtual Slang::ComBaseObject::~ComBaseObject()’,
    inlined from ‘uint32_t Slang::ComBaseObject::_releaseImpl()’ at /home/runner/work/slang/slang/source/core/slang-com-object.h:49:16,
    inlined from ‘virtual uint32_t Slang::MemoryFileSystem::release()’ at /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:34:5:
/home/runner/work/slang/slang/source/core/slang-com-object.h:33:31: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘&lt;unknown&gt;’ with nonzero offset 8 [-Werror=free-nonheap-object]
   33 |     virtual ~ComBaseObject() {}
      |                               ^
In destructor ‘virtual Slang::ComBaseObject::~ComBaseObject()’,
    inlined from ‘uint32_t Slang::ComBaseObject::_releaseImpl()’ at /home/runner/work/slang/slang/source/core/slang-com-object.h:49:16,
    inlined from ‘virtual uint32_t Slang::MemoryFileSystem::release()’ at /home/runner/work/slang/slang/source/core/slang-memory-file-system.h:34:5,
    inlined from ‘Slang::ComPtr&lt;T&gt;::~ComPtr() [with T = ISlangMutableFileSystem]’ at /home/runner/work/slang/slang/include/slang-com-ptr.h:113:34,
    inlined from ‘void _modulePtr_impl(UnitTestContext*)’ at /home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:92:1:
/home/runner/work/slang/slang/source/core/slang-com-object.h:33:31: error: ‘void operator delete(void*, std::size_t)’ called on pointer ‘&lt;unknown&gt;’ with nonzero offset 8 [-Werror=free-nonheap-object]
   33 |     virtual ~ComBaseObject() {}
      |                               ^
/home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp: In function ‘void _modulePtr_impl(UnitTestContext*)’:
/home/runner/work/slang/slang/tools/slang-unit-test/unit-test-module-ptr.cpp:36:69: note: returned from ‘void* operator new(std::size_t)’
   36 |         ComPtr&lt;ISlangMutableFileSystem&gt;(new Slang::MemoryFileSystem());
      |                                                                     ^
```

The problem is on the fact that `ComBaseObject` is not the first in the
multiple inheritance:
```
class MemoryFileSystem : public ISlangMutableFileSystem, public ComBaseObject
{
public:
    // ISlangUnknown
    SLANG_COM_BASE_IUNKNOWN_ALL
```

It should be:
```
class MemoryFileSystem : public ComBaseObject, public ISlangMutableFileSystem
```

The chain of ComObject release is little complicated and it is easy to
make a mistake. Here is summary with details,

1. `release()` is declared as a pure-virtual in ISlangUnknown, which is
one of the base classes of `ISlangMutableFileSystem`.
```
    struct ISlangUnknown
    {
        virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() = 0;
```

2. `release()` is implemented with the macro
   `SLANG_COM_BASE_IUNKNOWN_RELEASE`.
```
    SLANG_NO_THROW uint32_t SLANG_MCALL release() SLANG_OVERRIDE \
    {                                                            \
        return _releaseImpl();                                   \
    }

inline uint32_t ComBaseObject::_releaseImpl()
{
    // Check there is a ref count to avoid underflow
    SLANG_ASSERT(m_refCount != 0);
    const uint32_t count = --m_refCount;
    if (count == 0)
    {
        delete this;
    }
    return count;
}
```

3. The instance of `MemoryFileSystem` is handled by ComPtr. And
   `ComPtr::~ComPtr()` calls the `release()`.
```
    ComPtr&lt;ISlangMutableFileSystem&gt; memoryFileSystem =
        ComPtr&lt;ISlangMutableFileSystem&gt;(new Slang::MemoryFileSystem());

    SLANG_FORCE_INLINE ~ComPtr()
    {
        if (m_ptr)
            ((Ptr)m_ptr)-&gt;release();
    }
```

4. When `delete this` is called, because ComBaseObject is not the first
   in the multiple inheritance, `this` is 8 byte off from the actual
   instance address.

A fix for this is to change the order of the inheritance and make
ComBaseObject to be the first in the order.</content>
</entry>
<entry>
<title>format</title>
<updated>2024-10-29T06:49:26+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T06:49:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21'/>
<id>urn:sha1:f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21</id>
<content type='text'>
* format

* Minor test fixes

* enable checking cpp format in ci</content>
</entry>
<entry>
<title>preparation for clang format (#5422)</title>
<updated>2024-10-29T05:59:28+00:00</updated>
<author>
<name>Ellie Hermaszewska</name>
<email>ellieh@nvidia.com</email>
</author>
<published>2024-10-29T05:59:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=a729c15e9dce9f5116a38afc66329ab2ca4cea54'/>
<id>urn:sha1:a729c15e9dce9f5116a38afc66329ab2ca4cea54</id>
<content type='text'>
* Clang-format excludes

* Add .clang-format

* Don't clang-format in external

* Missing includes and forward declarations

* Replace wonky include-once macro name

* neaten include naming

* Add clang-format to formatting script

* Add xargs and diff to required binaries

* add clang-format to ci formatting check

* Add max version check to formatting script

* temporarily disable checking formatting for cpp files</content>
</entry>
<entry>
<title>Fix prelude generation by using relative paths for including `slang.h` (#4973)</title>
<updated>2024-08-30T23:58:07+00:00</updated>
<author>
<name>Sai Praveen Bangaru</name>
<email>31557731+saipraveenb25@users.noreply.github.com</email>
</author>
<published>2024-08-30T23:58:07+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=ca2317a28814c2ffe6427470be57df6d778b1358'/>
<id>urn:sha1:ca2317a28814c2ffe6427470be57df6d778b1358</id>
<content type='text'>
* Change `slang.h` path in `slang-common.h` to allow `slang-embed` to resolve correctly.

* Change `slang.h` path in all slang/core files

---------

Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Move the file public header files to `include` dir (#4636)</title>
<updated>2024-07-17T17:53:19+00:00</updated>
<author>
<name>kaizhangNV</name>
<email>149626564+kaizhangNV@users.noreply.github.com</email>
</author>
<published>2024-07-17T17:53:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=2db15080085856ed9b5f20642dbb354aac59a888'/>
<id>urn:sha1:2db15080085856ed9b5f20642dbb354aac59a888</id>
<content type='text'>
* Move the file public header files to `include` dir

Close the issue (#4635).

Move the following headers files to a `include` dir
located at root dir of slang repo:

 slang-com-helper.h -&gt; include/slang-com-helper.h
 slang-com-ptr.h -&gt; include/slang-com-ptr.h
 slang-gfx.h -&gt; include/slang-gfx.h
 slang.h -&gt; include/slang.h

Change cmake/SlangTarget.cmake to add include path to
every target, and change the source file to use
"#include &lt;slang.h&gt;" to include the public headers.

The source code update is by the script like follow:

```
fileNames_slang=$(grep -r "\".*slang\.h\"" source/ -l)

for fileName in "${fileNames_slang[@]}"
do
    echo "$fileName"
    sed -i "s/\".*slang\.h\"/\"slang\.h\"/" $fileName
done
```

* Fix the test issues

* Fix cpu test issues by adding include seach path

* Update cmake to not add include path for every target

Also change "#include &lt;slang.h&gt;" to "include "slang.h" " to
make the coding style consistent with other slang code.

* Change public include to private include for unit-test and slang-glslang</content>
</entry>
<entry>
<title>Add -repro-fallback-directory (#3188)</title>
<updated>2023-09-07T14:20:26+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2023-09-07T14:20:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=269282fd3647f1b201d2aae4c82b0c0af16c6420'/>
<id>urn:sha1:269282fd3647f1b201d2aae4c82b0c0af16c6420</id>
<content type='text'>
Co-authored-by: Yong He &lt;yonghe@outlook.com&gt;</content>
</entry>
<entry>
<title>Improvements around absolute paths and file systems (#2433)</title>
<updated>2022-10-06T14:27:50+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-10-06T14:27:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=d1e740d8b25e03a734093bd84b792eaf969649d1'/>
<id>urn:sha1:d1e740d8b25e03a734093bd84b792eaf969649d1</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Add handling for root paths.

* Fixes around absolute paths.

* Add SimplifyStyle

* Remove unrequire include.

* Fix some details around RelativeFileSystem canonical paths.

* For MemoryFileSystem make sure "/a" and "a" maps to same canonical path.

* Add test for canonicalPath.

* Improve comment.

* More testing around canonical paths.</content>
</entry>
<entry>
<title>IMutableFileSystem::saveFileBlob (#2427)</title>
<updated>2022-10-04T01:09:16+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-10-04T01:09:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=0b51ea6bb54b1d8a12695ccc2c259fd591069791'/>
<id>urn:sha1:0b51ea6bb54b1d8a12695ccc2c259fd591069791</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Remove ref count for Entry in RiffFileSystem.
Free up backing Entry types (to work around Dictionary not doing this).

* Some small improvements to RiffFileSystem.

* Add testing for file systems.

* Split out MemoryFileSystem.

* Add some documentation around different FileSystems.

* Small tiry up - removing unused headers, fixing some comments.
Use StringBlob::moveCreate where appropriate.

* Small improvement to MemoryFileSystem.
Improve documentation comments a little.

* Added PathKind

* * Make MemoryFileSystem not have implicit directories
* Make RelativeFileSystem only allow access to files in file system (kind of like chroot)
* Added Path::simplifyAbsolute
* Special handling for root of MemoryFileSystem
* Improvements around paths for different impls

* More improvements around RelativeFileSystem.
Special case root handling.

* Test archive serialization.
Move testinf from compression.
Remove the implicit directory test -&gt; doesn't work on all file systems.

* Small optimization that removes need for check for a parent unless an item is being *created*.

* Add implicit path testing.

* Add support for saveFileBlob
Add testing for saveFileBlob

* Removed TemporaryFileSet
Added PlatformUtil::outputDebugMessage

* Some small improvements around RelativeFileSystem.

* Split out ImplicitDirectoryCollector so can use without requiring compression systems.

* Split out StringSliceIndexMap into own files.</content>
</entry>
<entry>
<title>RIFF filesystem improvements (#2418)</title>
<updated>2022-09-29T14:07:37+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-09-29T14:07:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=70a6fbb33136e8e25a21977b4b07d3ced7597354'/>
<id>urn:sha1:70a6fbb33136e8e25a21977b4b07d3ced7597354</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Remove ref count for Entry in RiffFileSystem.
Free up backing Entry types (to work around Dictionary not doing this).

* Some small improvements to RiffFileSystem.

* Add testing for file systems.</content>
</entry>
<entry>
<title>Make ISlangFileSystem derive from ICastable (#2386)</title>
<updated>2022-09-01T20:39:08+00:00</updated>
<author>
<name>jsmall-nvidia</name>
<email>jsmall@nvidia.com</email>
</author>
<published>2022-09-01T20:39:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.yummers.dev/slang.git/commit/?id=cc0b81350f6b681c794b4ac7c0f3b5fe73cb19eb'/>
<id>urn:sha1:cc0b81350f6b681c794b4ac7c0f3b5fe73cb19eb</id>
<content type='text'>
* #include an absolute path didn't work - because paths were taken to always be relative.

* Make ISlangFileSystem derive from ICastable.

* Make ArchiveFileSystem into an interface
Make file systems atomically reference counted.

* Small fix.

* Some small fixes to work around issues of ICastable on ISlangFileSystem

* Use ISlangFileSystem derived type instead of IArchiveFileSystem. Can always get other interface with castAs.

* Some small fixes around change of interface returned from archive type functions.

* Remove CacheFileSystem member from linkage. Can access easily from m_fileSystemExt if necessary with as cast.

* Fix RiffFileSystem casting issue.

* Add a check around CacheFileSystem.</content>
</entry>
</feed>
