slangpy
Advanced tools
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| #pragma once | ||
| #include "sgl/core/object.h" | ||
| #include <atomic> | ||
| #include <filesystem> | ||
| #include <span> | ||
| #include <vector> | ||
| #include <optional> | ||
| // Forward declaration | ||
| struct MDB_env; | ||
| namespace sgl { | ||
| /// Exception class for LMDB errors. | ||
| class SGL_API LMDBException : public std::runtime_error { | ||
| public: | ||
| LMDBException(const std::string& what, int error) | ||
| : std::runtime_error(what) | ||
| , m_error(error) | ||
| { | ||
| } | ||
| int error() const { return m_error; } | ||
| private: | ||
| int m_error; | ||
| }; | ||
| /// \brief LMDB-based persistent cache. | ||
| /// This class provides a simple key-value cache that stores its data in an LMDB database on disk. | ||
| /// It supports basic operations such as setting, getting, and deleting entries. | ||
| /// Eviction uses an LRU policy and is triggered when the cache size exceeds the eviction threshold. | ||
| class SGL_API LMDBCache : public Object { | ||
| SGL_OBJECT(LMDBCache) | ||
| public: | ||
| using WriteValueFunc = void (*)(const void* data, size_t size, void* user_data); | ||
| struct Options { | ||
| /// Maximum size of the cache on disk. | ||
| size_t max_size{64ull * 1024 * 1024}; | ||
| /// Eviction threshold in percent (0-100). When the cache size exceeds this | ||
| /// percentage of the maximum size, eviction is triggered. | ||
| uint32_t eviction_threshold = 80; | ||
| /// Eviction target in percent (0-100). When eviction is triggered, entries | ||
| /// are evicted until the cache size is below this percentage of the maximum size. | ||
| uint32_t eviction_target = 60; | ||
| /// Disable synchronous writes to improve performance at the cost of potential data loss | ||
| /// in case of a crash. This is equivalent to opening the LMDB environment with the | ||
| /// `MDB_NOSYNC` flag. | ||
| bool nosync = true; | ||
| }; | ||
| struct Usage { | ||
| /// Reserved size in bytes (maximum size on disk). | ||
| size_t reserved_size{0}; | ||
| /// Committed size in bytes (current size on disk). | ||
| size_t committed_size{0}; | ||
| /// Used size in bytes (storing active entries). | ||
| size_t used_size{0}; | ||
| }; | ||
| struct Stats { | ||
| /// Number of entries in the cache. | ||
| uint64_t entries{0}; | ||
| /// Total size of all entries in the cache. | ||
| uint64_t size{0}; | ||
| /// Eviction count (number of entries evicted since opening). | ||
| uint64_t evictions{0}; | ||
| }; | ||
| /// Constructor. | ||
| /// Open the cache at the specified path. | ||
| /// Throws on error. | ||
| /// \param path Path to the cache directory. | ||
| /// \param options Cache options. | ||
| LMDBCache(const std::filesystem::path& path, std::optional<Options> options = {}); | ||
| /// Destructor. | ||
| ~LMDBCache() override; | ||
| /// Set a value in the cache. | ||
| /// Throws on error. | ||
| /// \param key_data Pointer to the key data. | ||
| /// \param key_size Size of the key data. | ||
| /// \param value_data Pointer to the value data. | ||
| /// \param value_size Size of the value data. | ||
| void set(const void* key_data, size_t key_size, const void* value_data, size_t value_size); | ||
| /// Get a value from the cache. | ||
| /// Throws on error. | ||
| /// \param key_data Pointer to the key data. | ||
| /// \param key_size Size of the key data. | ||
| /// \param write_value_func Function to write the value data. | ||
| /// \param user_data User data passed to the write_value_func. | ||
| /// \return True if the key was found, false otherwise. | ||
| bool get(const void* key_data, size_t key_size, WriteValueFunc write_value_func, void* user_data = nullptr); | ||
| /// Delete a value from the cache. | ||
| /// Throws on error. | ||
| /// \param key_data Pointer to the key data. | ||
| /// \param key_size Size of the key data. | ||
| /// \return True if the key was found and deleted, false if the key was not found. | ||
| bool del(const void* key_data, size_t key_size); | ||
| /// Set a value in the cache. | ||
| /// Throws on error. | ||
| /// \param key Key. | ||
| /// \param value Value. | ||
| inline void set(std::span<const uint8_t> key, std::span<const uint8_t> value) | ||
| { | ||
| set(key.data(), key.size(), value.data(), value.size()); | ||
| } | ||
| /// Get a value from the cache. | ||
| /// Throws on error. | ||
| /// \param key Key. | ||
| /// \param value Vector to store the value. | ||
| /// \return True if the key was found, false otherwise. | ||
| inline bool get(std::span<const uint8_t> key, std::vector<uint8_t>& value) | ||
| { | ||
| return get( | ||
| key.data(), | ||
| key.size(), | ||
| [](const void* data, size_t size, void* user_data) | ||
| { | ||
| reinterpret_cast<std::vector<uint8_t>*>(user_data)->assign( | ||
| static_cast<const uint8_t*>(data), | ||
| static_cast<const uint8_t*>(data) + size | ||
| ); | ||
| }, | ||
| &value | ||
| ); | ||
| } | ||
| /// Delete a value from the cache. | ||
| /// Throws on error. | ||
| /// \param key Key. | ||
| /// \return True if the key was found and deleted, false if the key was not found. | ||
| inline bool del(std::span<const uint8_t> key) { return del(key.data(), key.size()); } | ||
| Usage usage() const; | ||
| Stats stats() const; | ||
| private: | ||
| void evict(); | ||
| struct DB { | ||
| MDB_env* env{nullptr}; | ||
| unsigned int dbi_data{0}; | ||
| unsigned int dbi_meta{0}; | ||
| }; | ||
| static DB open_db(const std::filesystem::path& path, const Options& options); | ||
| static void close_db(DB db); | ||
| DB m_db; | ||
| size_t m_max_key_size{0}; | ||
| std::atomic<uint64_t> m_evictions{0}; | ||
| size_t m_eviction_threshold_size{0}; | ||
| size_t m_eviction_target_size{0}; | ||
| SGL_NON_COPYABLE_AND_MOVABLE(LMDBCache); | ||
| friend struct DBCacheItem; | ||
| }; | ||
| } // namespace sgl |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| #pragma once | ||
| #include "sgl/core/lmdb_cache.h" | ||
| #include <slang-rhi.h> | ||
| #include <atomic> | ||
| namespace sgl { | ||
| struct PersistentCacheStats { | ||
| uint64_t entry_count; | ||
| uint64_t hit_count; | ||
| uint64_t miss_count; | ||
| }; | ||
| /// Wrapper around `LMDBCache` that implements the `rhi::IPersistentCache` interface. | ||
| class SGL_API PersistentCache : public Object, public rhi::IPersistentCache { | ||
| SGL_OBJECT(PersistentCache) | ||
| public: | ||
| PersistentCache(const std::filesystem::path& path, size_t max_size = 64ull * 1024 * 1024); | ||
| ~PersistentCache() override; | ||
| PersistentCacheStats stats() const; | ||
| // ISlangUnknown interface | ||
| virtual SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(const SlangUUID& uuid, void** outObject) override; | ||
| // We don't want RHI to do reference counting on this object. | ||
| virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 2; } | ||
| virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 2; } | ||
| // IPersistentCache interface | ||
| virtual SLANG_NO_THROW rhi::Result SLANG_MCALL writeCache(ISlangBlob* key, ISlangBlob* data) override; | ||
| virtual SLANG_NO_THROW rhi::Result SLANG_MCALL queryCache(ISlangBlob* key, ISlangBlob** outData) override; | ||
| private: | ||
| std::filesystem::path m_path; | ||
| ref<LMDBCache> m_cache; | ||
| std::atomic<uint64_t> m_hit_count{0}; | ||
| std::atomic<uint64_t> m_miss_count{0}; | ||
| }; | ||
| } // namespace sgl |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| import pytest | ||
| import numpy as np | ||
| import slangpy as spy | ||
| from slangpy.testing import helpers | ||
| # Tests different ways PrintableString can be returned from a Slang struct. | ||
| # Detected error reported here: https://github.com/shader-slang/slang/issues/8694 | ||
| @pytest.mark.parametrize("device_type", helpers.DEFAULT_DEVICE_TYPES) | ||
| def test_printable_string(device_type: spy.DeviceType): | ||
| device = helpers.get_device(device_type) | ||
| program = device.load_program("test_printable_string.slang", ["compute_main"]) | ||
| kernel = device.create_compute_kernel(program) | ||
| hashed_strings = program.layout.hashed_strings | ||
| hash_to_string = {obj.hash: obj.string for obj in hashed_strings} | ||
| result_buffer = device.create_buffer( | ||
| resource_type_layout=kernel.reflection.result, | ||
| element_count=5, | ||
| usage=spy.BufferUsage.unordered_access, | ||
| ) | ||
| kernel.dispatch(thread_count=[1, 1, 1], vars={"result": result_buffer}) | ||
| result = result_buffer.to_numpy().view(np.uint32).flatten() | ||
| assert hash_to_string[result[0]] == "string_from_function" | ||
| assert hash_to_string[result[1]] == "string_from_method" | ||
| # Disabled due to: https://github.com/shader-slang/slang/issues/8694 | ||
| # assert hash_to_string[result[2]] == "string_from_static_const" | ||
| # assert hash_to_string[result[3]] == "string_from_interface_static_const" | ||
| assert hash_to_string[result[4]] == "string_from_interface_method" | ||
| if __name__ == "__main__": | ||
| pytest.main([__file__, "-v", "-s"]) |
Sorry, the diff of this file is not supported yet
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| import pytest | ||
| import sys | ||
| import numpy as np | ||
| import slangpy as spy | ||
| from slangpy.testing import helpers | ||
| @pytest.mark.parametrize("device_type", helpers.DEFAULT_DEVICE_TYPES) | ||
| @pytest.mark.parametrize("mode", ["render", "compute"]) | ||
| def test_generate_mips(device_type: spy.DeviceType, mode: str): | ||
| if mode == "render" and device_type == spy.DeviceType.metal: | ||
| pytest.skip("Currently fails on Metal, needs investigation.") | ||
| if mode == "compute" and device_type == spy.DeviceType.cuda and sys.platform == "linux": | ||
| pytest.skip( | ||
| "Currently fails on CUDA/Linux with CUDA_ERROR_MISALIGNED_ADDRESS when calling cuMemcpy3D to read back mip 0." | ||
| ) | ||
| device = helpers.get_device(device_type) | ||
| if mode == "render" and not spy.Feature.rasterization in device.features: | ||
| pytest.skip("Device does not support rasterization") | ||
| mip0 = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 8], [5, 6, 7, 8]], dtype=np.float32) | ||
| mip1 = np.array([[3.5, 5.5], [7.5, 8.5]], dtype=np.float32) | ||
| mip2 = np.array([[6.25]], dtype=np.float32) | ||
| usage = spy.TextureUsage.shader_resource | spy.TextureUsage.unordered_access | ||
| if mode == "render": | ||
| usage |= spy.TextureUsage.render_target | ||
| texture = device.create_texture( | ||
| type=spy.TextureType.texture_2d, | ||
| format=spy.Format.r32_float, | ||
| width=4, | ||
| height=4, | ||
| mip_count=spy.ALL_MIPS, | ||
| usage=usage, | ||
| data=mip0, | ||
| ) | ||
| encoder = device.create_command_encoder() | ||
| encoder.generate_mips(texture) | ||
| device.submit_command_buffer(encoder.finish()) | ||
| assert np.allclose(texture.to_numpy(mip=0), mip0) | ||
| assert np.allclose(texture.to_numpy(mip=1), mip1) | ||
| assert np.allclose(texture.to_numpy(mip=2), mip2) | ||
| if __name__ == "__main__": | ||
| pytest.main([__file__, "-v", "-s"]) |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| import pytest | ||
| from pathlib import Path | ||
| import slangpy as spy | ||
| from slangpy.testing import helpers | ||
| @pytest.mark.parametrize("device_type", helpers.DEFAULT_DEVICE_TYPES) | ||
| def test_shader_cache(device_type: spy.DeviceType, tmpdir: str): | ||
| cache_dir = tmpdir | ||
| # Create device with a shader cache. | ||
| device = spy.Device( | ||
| type=device_type, | ||
| enable_print=True, | ||
| shader_cache_path=cache_dir, | ||
| compiler_options={"include_paths": [Path(__file__).parent]}, | ||
| label=f"shader-cache-1-{device_type.name}", | ||
| ) | ||
| # We expect the cache to be empty and untouched. | ||
| stats = device.shader_cache_stats | ||
| assert stats.entry_count == 0 | ||
| assert stats.hit_count == 0 | ||
| assert stats.miss_count == 0 | ||
| # Create and dispatch kernel, shader should be stored to the cache. | ||
| program = device.load_program( | ||
| module_name="test_shader_cache", entry_point_names=["compute_main"] | ||
| ) | ||
| kernel = device.create_compute_kernel(program) | ||
| kernel.dispatch(thread_count=[1, 1, 1]) | ||
| assert device.flush_print_to_string().strip() == "Hello shader cache!" | ||
| # We expect at least one entry but potentially more than one | ||
| # (pipelines can get cached in addition to the compiled shader binary). | ||
| # We also expect at least one miss because the cache was empty. | ||
| stats = device.shader_cache_stats | ||
| assert stats.entry_count > 0 | ||
| assert stats.hit_count == 0 | ||
| assert stats.miss_count > 0 | ||
| # Close device. | ||
| device.close() | ||
| # Re-create device using same shader cache location. | ||
| device = spy.Device( | ||
| type=device_type, | ||
| enable_print=True, | ||
| shader_cache_path=cache_dir, | ||
| compiler_options={"include_paths": [Path(__file__).parent]}, | ||
| label=f"shader-cache-1-{device_type.name}", | ||
| ) | ||
| # We expect at least one entry, but hit/miss count are reset. | ||
| stats = device.shader_cache_stats | ||
| assert stats.entry_count > 0 | ||
| assert stats.hit_count == 0 | ||
| assert stats.miss_count == 0 | ||
| entry_count_before = stats.entry_count | ||
| # Create and dispatch kernel, shader should be loaded from cache. | ||
| program = device.load_program( | ||
| module_name="test_shader_cache", entry_point_names=["compute_main"] | ||
| ) | ||
| kernel = device.create_compute_kernel(program) | ||
| kernel.dispatch(thread_count=[1, 1, 1]) | ||
| assert device.flush_print_to_string().strip() == "Hello shader cache!" | ||
| # We expect the same number of entries in the cache, but at least one hit. | ||
| stats = device.shader_cache_stats | ||
| assert stats.entry_count == entry_count_before | ||
| assert stats.hit_count > 0 | ||
| assert stats.miss_count == 0 | ||
| # Close device. | ||
| device.close() | ||
| if __name__ == "__main__": | ||
| pytest.main([__file__, "-v", "-s"]) |
Sorry, the diff of this file is not supported yet
+4
-2
| Metadata-Version: 2.4 | ||
| Name: slangpy | ||
| Version: 0.36.0 | ||
| Version: 0.37.0 | ||
| Summary: Easily call Slang functions and integrate with PyTorch auto diff directly from Python. | ||
@@ -77,3 +77,5 @@ Author-email: Simon Kallweit <skallweit@nvidia.com>, Chris Cummings <chriscummings@nvidia.com>, Benedikt Bitterli <bbitterli@nvidia.com>, Sai Bangaru <sbangaru@nvidia.com>, Yong He <yhe@nvidia.com> | ||
| - [libpng](http://www.libpng.org/pub/png/libpng.html) (libpng) | ||
| - [lmdb](https://github.com/LMDB/lmdb) (OpenLDAP Public License) | ||
| - [nanobind](https://github.com/wjakob/nanobind) (BSD) | ||
| - [nanothread](https://github.com/mitsuba-renderer/nanothread) (BSD) | ||
| - [NVAPI](https://github.com/NVIDIA/nvapi) (MIT) | ||
@@ -104,5 +106,5 @@ - [OpenEXR](https://openexr.com/en/latest/) (BSD) | ||
| note = {https://github.com/shader-slang/slangpy}, | ||
| version = {0.36.0}, | ||
| version = {0.37.0}, | ||
| year = 2025 | ||
| } | ||
| ``` |
+41
-34
| slangpy/__init__.py,sha256=PsbtOD5NRRgDcN2C7SbPnePNpAzce326xQM9tZhBT9M,1948 | ||
| slangpy/__init__.pyi,sha256=wOVzPzLrRGvVqsKXC-cUwQrtiilqDKDi2e9E571fI8c,193464 | ||
| slangpy/libsgl.dylib,sha256=-Z9L-Y5u6Jv28MUOr4xFXWX3wymr8sgqlP48yMcYGyk,8341040 | ||
| slangpy/libslang-glsl-module.dylib,sha256=KSxBBR3H5kiWnP50MI6EZ05TZaoj9b0nBoqAmBMuP00,1441488 | ||
| slangpy/libslang-glslang.dylib,sha256=F61SQsPfGAb5OIueoJ2_pPOJcymx3LCe2vmK5ftKLEo,8052992 | ||
| slangpy/libslang-rhi.a,sha256=kB_6AhuTh8c9mqv7UXSOZeXy6VT_-G51nSJR0jwUrBA,74109752 | ||
| slangpy/libslang-rt.dylib,sha256=km9PjcYyiRtcNd5zhzjb4zDqH0YdEK6DfxeO6HIzPrY,249968 | ||
| slangpy/libslang.dylib,sha256=Kj2L8D3laBvLjTOs9x-u1qP1WKAQgeft5UTFOdnio0I,19841296 | ||
| slangpy/slangpy_ext.cpython-310-darwin.so,sha256=avdfPOP6_cy7V2rxd0YQqPKr2fw9g88efHYGRVXkGVU,6653680 | ||
| slangpy/__init__.pyi,sha256=7czP3FZa6JdpBtoofk_W7SQh1avhbrLvu9e88ae7QZk,193528 | ||
| slangpy/libsgl.dylib,sha256=XsZ8Cjah-uTF2wczZKPqLXsdpXymXFjV2Dx5JO3VALE,8481104 | ||
| slangpy/libslang-glsl-module.dylib,sha256=qz2CfSdo57p9925LbA1QNTZJHmbzAnfGiGyf_Eu1dsg,1458000 | ||
| slangpy/libslang-glslang.dylib,sha256=cOUaCSl336pitfL_nLEPC3oInCMPqKs1WKhKRDOYxSc,8052992 | ||
| slangpy/libslang-rhi.a,sha256=ExzFUc39xYRtZX_1XnPow5v7wWyId4kNj1BMaapY80w,74008680 | ||
| slangpy/libslang-rt.dylib,sha256=OlI5dfwxudMfkwKIuN85j37WXTrzC5L38L7itB9JSns,249968 | ||
| slangpy/libslang.dylib,sha256=8Ot3CZIVfPCdT7vSE-uToX4ibTUqaT91GiGp-HfnHZ4,19897264 | ||
| slangpy/slangpy_ext.cpython-310-darwin.so,sha256=qNqMmDCTpuQH4rije_RoMR4P1aEoda5j5qDRerFxRPg,6653808 | ||
| slangpy/benchmarks/conftest.py,sha256=rAYyblUkfrklcEe_TbJ0UuSAzQ8b0pmAbrWG2_s1nrg,438 | ||
@@ -14,5 +14,5 @@ slangpy/benchmarks/test_benchmark_interop.py,sha256=7xkivr7F1sD7_VRUVivVy125whirpZkbuttauURqgDw,15467 | ||
| slangpy/bindings/__init__.py,sha256=wLvyNHYyvIGbvuHLHa3uc12d5kdTduizQZd47W7nm7E,621 | ||
| slangpy/bindings/boundvariable.py,sha256=bYN43XLldSFVquJvUCe0kjTllCpp2FkGZKJ0F1zses4,23597 | ||
| slangpy/bindings/boundvariable.py,sha256=zExxpOQBkbevp_Id25xXq9Jfvav9yZmF_SaAK_tCrME,23882 | ||
| slangpy/bindings/boundvariableruntime.py,sha256=S5irVy5e6zGPgQ3k6i5iz6_cr4MIObYl6aeHTkoNXb4,2326 | ||
| slangpy/bindings/codegen.py,sha256=RYNojLmUMHpDwV8C6wr8hTiytoLcriDUBMAH3CKyRhU,6735 | ||
| slangpy/bindings/codegen.py,sha256=-1qWw0FroLOPoL1vlUFH0BQqcWnEHcvTATHJ3dvvNhQ,6784 | ||
| slangpy/bindings/marshall.py,sha256=yqXdH43blbqHkHvD8bUhCvaXITH5rgKxhClxAquS_MA,4896 | ||
@@ -36,3 +36,3 @@ slangpy/bindings/typeregistry.py,sha256=fHuoHVOdhHDVFVxYiHDWQAe46aOQO19amguaCJY18eM,1392 | ||
| slangpy/core/calldata.py,sha256=oVK6IexBHGWsp7Qffx1wS75QymE8V57HCRCKC-bmxUM,21458 | ||
| slangpy/core/callsignature.py,sha256=Tjwg-gZ64zHAKOEordoNwvOjEP12zFcM3155gGJvmLo,27449 | ||
| slangpy/core/callsignature.py,sha256=dH36kpZwi5-HCkl11WrNDEW_nrLxs-QGMk0ClwsaNmo,28330 | ||
| slangpy/core/dispatchdata.py,sha256=S176OEjLyzVovpkomRllpxVproTy4KttSRnU38ie5Z0,10955 | ||
@@ -107,14 +107,14 @@ slangpy/core/enums.py,sha256=lLLVsfRqLWNMDOE7eaxOyy6t6KNzbXjv2JsvmepltU0,211 | ||
| slangpy/include/slang-rhi-config.h,sha256=Em9yoqMRi3H21r1rWhJgTwSbWUk88IEQzrQ-ot2Ppf0,403 | ||
| slangpy/include/slang-rhi.h,sha256=TXBUwV3UTT0W0gFJnQZpG23GveyIBTpjGziHsxVCVlM,106409 | ||
| slangpy/include/slang-rhi.h,sha256=fQ4y3wlWXyTDj_Tj9JbxNt-IclRJooKbuNh3gSiDY8Y,106958 | ||
| slangpy/include/slang-user-config.h,sha256=-DTfKSDXKnCWR_NU6n96RYbQyYmM5ms2IFQH8UWNn7Y,151 | ||
| slangpy/include/slang.h,sha256=sQbZxKt6WhP8F8wvU8EnyMzltucfmIWgQ_7tdZnhRvM,179036 | ||
| slangpy/include/sgl/sgl.h,sha256=V9JQ90C9puL6aGY0vUpHAD7U9Cv7wKaAXpVL1mQ2Ofs,610 | ||
| slangpy/include/sgl/sgl.h,sha256=k_NcH7S5laDFiCdCBbX2fpEhsHC3YTKHaXyrzoSVRxU,610 | ||
| slangpy/include/sgl/sgl_pch.h,sha256=SD1ALBpwwkcMlCnU_V8nHdSvS6-NZIXZOv5Rd6_r5z8,131 | ||
| slangpy/include/sgl/app/app.h,sha256=tyvkNXNrsvsYWL98uSxVKcYesdiJ2ZRqdwJpfw9dbwA,2809 | ||
| slangpy/include/sgl/core/bitmap.h,sha256=XlUXZ705ibY5AtQrJErQBwlPkvu0guEHkNs3sZqvOeM,10177 | ||
| slangpy/include/sgl/core/bitmap.h,sha256=JLCfpDQJ0wWXdVMo9v4Rb-DcJz62JFJQEhsZoopGXGQ,10232 | ||
| slangpy/include/sgl/core/crypto.h,sha256=oVbUulanCyhTejMsv3Oa-ltTTsFAFcVRLHMNXw5phyw,1828 | ||
| slangpy/include/sgl/core/data_struct.h,sha256=iKcl1DBHkh9m47HXTJv4fstQ_a8w409ycSHKYuUQJC0,11651 | ||
| slangpy/include/sgl/core/data_type.h,sha256=n5FHYfDfchh1OAp-Q5Eez3jkGozdP0q2bvlyrS-4NGI,900 | ||
| slangpy/include/sgl/core/data_type.h,sha256=qvV0hhTSyruh0l557qkpWnocpBa1nEkou4wPO9Nza2M,1518 | ||
| slangpy/include/sgl/core/dds_file.h,sha256=y0bUeGRtQa54E8K1-YR6YL3PqveIX1s9FvLn5bvCJ38,3023 | ||
| slangpy/include/sgl/core/enum.h,sha256=5qsnYE7LoY-AMccK7CX7No-vbXv9CfT8IDlminvHZ0I,6229 | ||
| slangpy/include/sgl/core/enum.h,sha256=D_ZS17JTYQ4_56pBgFAAE3n-FDVwENMwiAXVHXzL2cI,6205 | ||
| slangpy/include/sgl/core/error.h,sha256=o-Mi9Fo-j3sDX1BZnIljNdLQtRylKiJuPYr3AQvCCS0,6727 | ||
@@ -124,5 +124,6 @@ slangpy/include/sgl/core/file_stream.h,sha256=7JXL14o9sdLC4DJmKoyJ5jWyN6wIBdK1ALudklAXYQs,1509 | ||
| slangpy/include/sgl/core/format.h,sha256=WP8Qy7Y8sfnJFiHqodsmzPsi8W5VRlQM5-8gpi0WNqU,903 | ||
| slangpy/include/sgl/core/fwd.h,sha256=u7w8Y6GrgZzh3dSum0TMXFaCx0TwQeK6xTU9uoyCrd8,1117 | ||
| slangpy/include/sgl/core/fwd.h,sha256=B5n1wlM0vyWejnXBWLKS8A5UpRlkWJy1B65zla2bkXY,1152 | ||
| slangpy/include/sgl/core/hash.h,sha256=HNyUBAz4lK8CbpBeAnVYjuSWSW9m39XUvkll-DXGsVA,968 | ||
| slangpy/include/sgl/core/input.h,sha256=T1goFZi75MSAwBfebHDaXxmKS60TlI4qHEX-sVuz6QI,13528 | ||
| slangpy/include/sgl/core/lmdb_cache.h,sha256=uVKXKpYMScjIV1Z3tJ8J27AC38TnqZcCc5DI1rr23Wg,5639 | ||
| slangpy/include/sgl/core/logger.h,sha256=rJIVQ_Wsop-DZTVas-rD-0Vv4XEtZsXg7kv3dQNRlvU,8240 | ||
@@ -135,3 +136,3 @@ slangpy/include/sgl/core/macros.h,sha256=UChfEuye9Jf2wa6qlPieJc_vIl3f7kbMsSb2NgbcOiQ,7122 | ||
| slangpy/include/sgl/core/object.h,sha256=ltTTfbin7aQVoCisRCUlHUZXGbbSrgAlhwcqf8g9quI,21301 | ||
| slangpy/include/sgl/core/platform.h,sha256=HGuX-Y1SWCJWNrA2G3psYupwEjJC8PrxsEip06X0WFQ,8713 | ||
| slangpy/include/sgl/core/platform.h,sha256=jol6ibPoC7HL_a-tSB5w5QUshxGZaNxJoFEgIj3oFNs,9064 | ||
| slangpy/include/sgl/core/plugin.h,sha256=tRhOXiBPq-wND13Xd7U-cQNVm6NS18iN3qCRjuSU7Dw,13120 | ||
@@ -142,3 +143,3 @@ slangpy/include/sgl/core/resolver.h,sha256=wUrKyiHwwvXUoIVXPFcVyN36lpQuF9eMuVBFM_w_p-M,951 | ||
| slangpy/include/sgl/core/stream.h,sha256=mdrcEPnkxZSdrzI9pjoqCvEsGFkOX0KxJsRV5UlvIJs,1786 | ||
| slangpy/include/sgl/core/string.h,sha256=azYJO32kfk9ThHoLsEjQMiTiYUPt-2Uadve1mEvA0v8,8223 | ||
| slangpy/include/sgl/core/string.h,sha256=vtaxwKW1oCGp3rIsGGxQwDNG8jOPIxvj9F95DVoSmTg,8187 | ||
| slangpy/include/sgl/core/thread.h,sha256=A9W4s8uQ2_BAxL-yUZlGZaIrWSngO9bMUZiGzyK7qpE,670 | ||
@@ -156,10 +157,10 @@ slangpy/include/sgl/core/timer.h,sha256=VfajHJRJi-N-EwJqrjYBLUxNlHjO3MsHjuuE0CqDZy4,1552 | ||
| slangpy/include/sgl/device/cuda_utils.h,sha256=zfSe9EoDtBNJv0E7iYYfyYFyyotI3GS8MTo1_4cMsrc,4274 | ||
| slangpy/include/sgl/device/cursor_access_wrappers.h,sha256=WNMqwoMuoYAkayIjbM_xFbcAYVx9iBgjRoHjRqtvSfo,17156 | ||
| slangpy/include/sgl/device/cursor_utils.h,sha256=ShnXzyl6j4LO_MRgRUlioqmUFYUHAM0-t_BslGtSTfg,5062 | ||
| slangpy/include/sgl/device/cursor_access_wrappers.h,sha256=MfubfdRr63dvVfwDaVe3stS1qgHWna_8fUX_4eyRGwU,17186 | ||
| slangpy/include/sgl/device/cursor_utils.h,sha256=H50dbFbAKFtMY4JeYF5wk57GFZknsjlS3uJUwa6NHto,4751 | ||
| slangpy/include/sgl/device/debug_logger.h,sha256=hK98tQ8RvVBgI1Z5EoqJKuL9yBU_S2j4EdsWq-l4bGg,2502 | ||
| slangpy/include/sgl/device/device.h,sha256=FWEklpSKuy2Cm1kAesD3tMjuQEeXlHbyCDOnW1DYWIg,24937 | ||
| slangpy/include/sgl/device/device.h,sha256=8sgNEo3z4kBAxj5RK-prlMXmnENP_gUr3eXu9xUSWM0,25216 | ||
| slangpy/include/sgl/device/device_child.h,sha256=4euwuyohyciWFNpgWLHrNyCLWNQhEDsFSq9tSncvgt4,985 | ||
| slangpy/include/sgl/device/fence.h,sha256=kA3A46D5lD56RD92eGWqIr-qh_NzFK2yfmFeTTo0g50,2875 | ||
| slangpy/include/sgl/device/formats.h,sha256=H6PfPqJ8lvel6C5hO0P5sgInQn_wtac-9BP4IHZXGvU,16872 | ||
| slangpy/include/sgl/device/fwd.h,sha256=TQ_IN_GJrCa9zyOr-5Yo2Ws6eGmXzxZjCDlJd70ubmg,2468 | ||
| slangpy/include/sgl/device/fwd.h,sha256=65QUywZPnnGhDL7k_e29BlovtY_xbsjYIcGchCDbpNU,2515 | ||
| slangpy/include/sgl/device/helpers.h,sha256=ZcfJHIebzX2WYgpYodYG9FRCV0EMCzt65QmD2NVz7XA,2015 | ||
@@ -172,2 +173,3 @@ slangpy/include/sgl/device/hot_reload.h,sha256=WbvnDarrppcxjTPvyIun4yGz6c5o3lc8SIWZgcbiQxE,2509 | ||
| slangpy/include/sgl/device/native_handle_traits.h,sha256=q0f6XFP2zVCd-w_DofQklk0FvnFPE0gTx-fLibEeqGc,4953 | ||
| slangpy/include/sgl/device/persistent_cache.h,sha256=30XIPcpjtSwo2kB26IBe4L9gs57SpPqERAdb1Uubf3E,1460 | ||
| slangpy/include/sgl/device/pipeline.h,sha256=LZXcuQTvwszfnA-asW43vDoLaJAn39dZXc-WnTMTFpE,4379 | ||
@@ -181,3 +183,3 @@ slangpy/include/sgl/device/print.h,sha256=aCa0bzaq8E3Ux-lKV8n9La2jXMJeb2PJ6JL4x95_td0,1042 | ||
| slangpy/include/sgl/device/shader.h,sha256=qGtdw3Oo5smKLGj8AQTRV98RQKZ9JbBPWJsTKw6F98w,18202 | ||
| slangpy/include/sgl/device/shader_cursor.h,sha256=tsoj4yuZk6tEHlWRReBGJKR9ES1CmVBIa_lMKUPn-7o,3484 | ||
| slangpy/include/sgl/device/shader_cursor.h,sha256=AKgr35_4SG6MIAowZy8hp5HKNfdHty527zOB6raUs3I,3510 | ||
| slangpy/include/sgl/device/shader_object.h,sha256=fxkc2LAJI6MJDyvHhteRJPRmx8hoPl65PAc2dw5vKrs,2490 | ||
@@ -226,6 +228,6 @@ slangpy/include/sgl/device/shader_offset.h,sha256=pnRDl9wuCQp7nWYKDvPU9j8R4X_EmIAS5feY9HSfa4k,2044 | ||
| slangpy/renderdoc/__init__.pyi,sha256=tGkBiHP11-d0bCQWQa2rnw4L75VWWWEUCeinTaeYrqo,1315 | ||
| slangpy/shaders/sgl/device/blit.slang,sha256=LxNUAgP-7v9ZBctVQYGsesSVLV1KxiHIA8RAnYdgIK0,3189 | ||
| slangpy/shaders/sgl/device/blit.slang,sha256=EjRhRmq9uATe1kG3oiT2W4ppBgDHSSYbdhMf58IYGm8,3219 | ||
| slangpy/shaders/sgl/device/nvapi.slang,sha256=xrxIu2gd51EUZ0z56rfKKukCwYvaZRPN4lG0ndwRivg,119 | ||
| slangpy/shaders/sgl/device/nvapi.slangh,sha256=6JFiYhHzsR1-H--YAM-BDAN5i95cdrfByoIyIYW7eFI,163 | ||
| slangpy/shaders/sgl/device/print.slang,sha256=FTJL-btEbaNdpF4QJKft4347OvGVnW5hFOdYGMykFQI,9382 | ||
| slangpy/shaders/sgl/device/print.slang,sha256=MGiY3N2wNPDxYgjppPLkOjc9Vx892-tS-diO5ehezKM,10185 | ||
| slangpy/shaders/sgl/math/constants.slang,sha256=5A9YEQqB65jpbs0pmLyw8U10xAzD6HydwbbIioh4Jr8,121 | ||
@@ -263,5 +265,6 @@ slangpy/shaders/sgl/math/ray.slang,sha256=xeHNuWaAsTmubx0ilAvQ3ihRY9AXG2swnu2Oqg_9wKo,683 | ||
| slangpy/tests/core/test_timer.py,sha256=_9j8wCE-dGKqQHUy4WzBlfES-0hVQj4-4jJilLf9L30,1230 | ||
| slangpy/tests/device/test_bindless.py,sha256=jnZEx7SEvlfARMErSGvRT0WVxp56dR5HB1RAzy_rOaA,6159 | ||
| slangpy/tests/device/test_bindless.py,sha256=e4hEuqzyYUg16UbbPLYi0AHQKY7x5oD6lAciDBV5Fek,6385 | ||
| slangpy/tests/device/test_bindless_buffer.slang,sha256=-8Os9geRlVKYAMwMvaVY5wv13sf3I6734M7-2KVR-GI,709 | ||
| slangpy/tests/device/test_bindless_texture.slang,sha256=A-KSoaf5k3GAetJGuMSu-CcATBQznpcAvnSwrPeKHfg,489 | ||
| slangpy/tests/device/test_blit.py,sha256=ttHAStFqV2heTiNziLZ5sHnqUxoaLjeXiPAXugZBtJg,1882 | ||
| slangpy/tests/device/test_buffer.py,sha256=I7aLlw06SOAJhl-iIuy50SuNNs6OJIVHnULZxDwtbjA,7159 | ||
@@ -289,7 +292,9 @@ slangpy/tests/device/test_buffer.slang,sha256=gteU9upzn-Bf8o4foGlzTjVzYoElUKOXAv4Ibtn0S2Y,1279 | ||
| slangpy/tests/device/test_pipeline_utils.slang,sha256=1nmuw1rwrv2FK3IXCAkWtGBZmXOeyGOofBu-OftTtFg,1162 | ||
| slangpy/tests/device/test_print.py,sha256=wPD7lhnk_NkFriIRM4W0NrHSVz7brYX2PWOzJfu7yZQ,8581 | ||
| slangpy/tests/device/test_print.slang,sha256=gmuwQnChanGhXkW7005fLR6yhHzxc2Lpej4-GsOYq60,5512 | ||
| slangpy/tests/device/test_print.py,sha256=A1IKUOhV7iaGfNC5l9uydxRP1LGoGoRt_rmdTVXDu1k,8996 | ||
| slangpy/tests/device/test_print.slang,sha256=ihCRR630FAQK87ujwF-M_XprHGkEd9W8o0co6n8gjjQ,5605 | ||
| slangpy/tests/device/test_print_module2.slang,sha256=3Tk0MEt1usLKlpjyyRaQwpP7KGA2vMJ_N_HaLoVjeLg,221 | ||
| slangpy/tests/device/test_reflection.py,sha256=XI8p9B8qWKBkYet7_ZFmLZd6v1X3VeVwdSt2oWf20sM,41166 | ||
| slangpy/tests/device/test_shader.py,sha256=j5eRKQFaA1HDpnqN_3b_QLAmWrZkEkfcZZBp5qUCS1I,4583 | ||
| slangpy/tests/device/test_shader_cache.py,sha256=R6Z48PfTk_QqUwld7DGj4btvfEDjCpgl71vn_EvHiLs,2774 | ||
| slangpy/tests/device/test_shader_cache.slang,sha256=4x4P80SGtdmxwl1-RJFwAOCUPjqyj7O1BHg-mSPRnYs,186 | ||
| slangpy/tests/device/test_shader_compile_error.slang,sha256=C-IscJwV1aj47SFEjffYJXoyFgZ6dTTQU_bSG3HCx88,64 | ||
@@ -314,2 +319,4 @@ slangpy/tests/device/test_shader_cursor.py,sha256=vMQjGqRap1jYC1lYiJGE6YuVemPznS6Hyi7xlFILDqk,15545 | ||
| slangpy/tests/device/slang/test_nested_structs.slang,sha256=PoYf1B4k3F2-0jZjjaeXOZX2pCRrbZ6ggQXL1jQsIZA,1310 | ||
| slangpy/tests/device/slang/test_printable_string.py,sha256=bdAKERb-zUyKKwrTO8fbMZc6bQGEykZsJqCQiBXuv4Q,1543 | ||
| slangpy/tests/device/slang/test_printable_string.slang,sha256=0PT_SBEck0YFArpBHKMqWrpQ0Va3e52kqQGdGIxFSuc,1329 | ||
| slangpy/tests/device/slang/test_uint64.py,sha256=bmV4kGiWFcxpNBD4Y7ueT1ylTV_Vt6GXWKzkmYbYiJM,1344 | ||
@@ -404,6 +411,6 @@ slangpy/tests/device/slang/test_uint64.slang,sha256=d3XrSqwZH4ehpCr_Z1gJ0QBGgHGbbOm3B1Lm3Z4W1kA,739 | ||
| slangpy/ui/__init__.pyi,sha256=6oKnW1qupqQCPSe82znQzssxR5mw6zAuM4mGr3CaSvQ,30512 | ||
| slangpy-0.36.0.dist-info/licenses/LICENSE,sha256=tzjZi3clQUtTTBGaxmEmh2uMvUCqiuSCENsZBxS4FnA,1490 | ||
| slangpy-0.36.0.dist-info/METADATA,sha256=TYMWbyG0UV4xhFYK1CUPa4IO8a59S8vnzHtV1UWTDvg,4323 | ||
| slangpy-0.36.0.dist-info/WHEEL,sha256=QbwVjH-TlueSdsOKSic424jsJD30r52gknYt4wXVwF0,109 | ||
| slangpy-0.36.0.dist-info/top_level.txt,sha256=Wo7_Eny8d-MI3ZHT-XHGGMEKKIK38FlAmUCz8AffxA0,8 | ||
| slangpy-0.36.0.dist-info/RECORD,, | ||
| slangpy-0.37.0.dist-info/licenses/LICENSE,sha256=tzjZi3clQUtTTBGaxmEmh2uMvUCqiuSCENsZBxS4FnA,1490 | ||
| slangpy-0.37.0.dist-info/METADATA,sha256=NsxHHPSyA2cXa-01age9AnUWTs0-gtO9TkZuv2a1qP4,4457 | ||
| slangpy-0.37.0.dist-info/WHEEL,sha256=QbwVjH-TlueSdsOKSic424jsJD30r52gknYt4wXVwF0,109 | ||
| slangpy-0.37.0.dist-info/top_level.txt,sha256=Wo7_Eny8d-MI3ZHT-XHGGMEKKIK38FlAmUCz8AffxA0,8 | ||
| slangpy-0.37.0.dist-info/RECORD,, |
@@ -267,2 +267,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| # HACK! Part of the hack in callsignature.py specialize, | ||
| # where structs written to interface inputs need to be explicitly | ||
| # specialized BEFORE binding. | ||
| if self.explicitly_vectorized and self.vector_type: | ||
| self.slang_type = self.vector_type | ||
| if self.children is not None: | ||
@@ -269,0 +275,0 @@ for child in self.children.values(): |
@@ -142,3 +142,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| #: Imports list | ||
| self.imports: set[str] = set() | ||
| self.imports: list[str] = [] | ||
@@ -171,3 +171,4 @@ #: Trampoline function | ||
| """ | ||
| self.imports.add(import_name) | ||
| if not import_name in self.imports: | ||
| self.imports.append(import_name) | ||
@@ -174,0 +175,0 @@ def add_parameter_block(self, type_name: str, var_name: str): |
@@ -18,2 +18,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| from slangpy.builtin.value import NoneMarshall, ValueMarshall | ||
| from slangpy.builtin import StructMarshall | ||
| from slangpy.reflection.reflectiontypes import SlangFunction, SlangType | ||
@@ -158,2 +159,16 @@ from slangpy.types.buffer import NDBuffer | ||
| inputs.append(python_arg.python) | ||
| elif ( | ||
| slang_param.type.type_reflection.kind == TypeReflection.Kind.interface | ||
| and isinstance(python_arg.python, StructMarshall) | ||
| and python_arg.python.slang_type.name != "Unknown" | ||
| and not python_arg.explicitly_vectorized | ||
| ): | ||
| # HACK! If we're calling a function with an interface parameter, | ||
| # we need to have a concrete type to load data into. This Chris approved hack | ||
| # allows us to do that. Re-visit after the type resolution fixes are in. | ||
| # The other half of the hack i sin boundvariable.py, BoundVariable.bind | ||
| python_arg.vector_type = python_arg.python.slang_type | ||
| python_arg.explicitly_vectorized = True | ||
| inputs.append(slang_param.type) | ||
| elif slang_param.type.type_reflection.kind != TypeReflection.Kind.none: | ||
@@ -160,0 +175,0 @@ # If the type is fully resolved, use it |
@@ -133,3 +133,4 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| const std::vector<std::string>& channel_names = {}, | ||
| void* data = nullptr | ||
| void* data = nullptr, | ||
| std::optional<bool> srgb_gamma = std::nullopt | ||
| ); | ||
@@ -136,0 +137,0 @@ |
@@ -46,2 +46,29 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| /// Get the size of a type in bytes. | ||
| inline size_t data_type_size(sgl::DataType type) | ||
| { | ||
| using sgl::DataType; | ||
| switch (type) { | ||
| case DataType::int8: | ||
| case DataType::uint8: | ||
| return 1; | ||
| case DataType::int16: | ||
| case DataType::uint16: | ||
| case DataType::float16: | ||
| return 2; | ||
| case DataType::int32: | ||
| case DataType::uint32: | ||
| case DataType::float32: | ||
| return 4; | ||
| case DataType::int64: | ||
| case DataType::uint64: | ||
| case DataType::float64: | ||
| return 8; | ||
| case DataType::void_: | ||
| case DataType::bool_: | ||
| break; // throws | ||
| }; | ||
| SGL_THROW("Invalid type."); | ||
| } | ||
| } // namespace sgl |
@@ -24,8 +24,4 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| concept is_enum_info = requires(T v) { | ||
| { | ||
| v.name | ||
| } -> std::same_as<const char* const&>; | ||
| { | ||
| v.items[0] | ||
| } -> std::same_as<const std::pair<typename T::enum_type, const char*>&>; | ||
| { v.name } -> std::same_as<const char* const&>; | ||
| { v.items[0] } -> std::same_as<const std::pair<typename T::enum_type, const char*>&>; | ||
| }; | ||
@@ -32,0 +28,0 @@ |
@@ -35,2 +35,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // lmdb_cache.h | ||
| class LMDBCache; | ||
| // logger.h | ||
@@ -37,0 +41,0 @@ |
@@ -16,7 +16,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| #if SGL_WINDOWS | ||
| #define DECLARE_HANDLE(name) \ | ||
| #define SGL_DECLARE_HANDLE(name) \ | ||
| struct name##__; \ | ||
| typedef struct name##__* name | ||
| DECLARE_HANDLE(HWND); | ||
| #undef DECLARE_HANDLE | ||
| SGL_DECLARE_HANDLE(HWND); | ||
| #undef SGL_DECLARE_HANDLE | ||
| #endif | ||
@@ -39,2 +39,5 @@ | ||
| using SharedLibraryHandle = void*; | ||
| using ProcessID = int; | ||
| } // namespace sgl | ||
@@ -164,2 +167,9 @@ | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // Processes | ||
| // ------------------------------------------------------------------------------------------------- | ||
| /// Get the process ID of the current process. | ||
| [[nodiscard]] SGL_API ProcessID current_process_id(); | ||
| // ------------------------------------------------------------------------------------------------- | ||
| // Memory | ||
@@ -166,0 +176,0 @@ // ------------------------------------------------------------------------------------------------- |
@@ -97,5 +97,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| concept object_to_string = requires(typename std::remove_pointer<typename remove_ref<T>::type>::type t) { | ||
| { | ||
| t.to_string() | ||
| } -> std::convertible_to<std::string>; | ||
| { t.to_string() } -> std::convertible_to<std::string>; | ||
| }; | ||
@@ -129,5 +127,3 @@ | ||
| concept free_standing_to_string = requires(T t) { | ||
| { | ||
| to_string(t) | ||
| } -> std::convertible_to<std::string>; | ||
| { to_string(t) } -> std::convertible_to<std::string>; | ||
| }; | ||
@@ -164,5 +160,3 @@ | ||
| concept iterable_has_to_string = requires(typename T::iterator t) { | ||
| { | ||
| (*t)->to_string() | ||
| } -> std::convertible_to<std::string>; | ||
| { (*t)->to_string() } -> std::convertible_to<std::string>; | ||
| }; | ||
@@ -169,0 +163,0 @@ |
@@ -225,4 +225,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| void _get_array_or_vector(void* data, size_t size, TypeReflection::ScalarType cpu_scalar_type, size_t element_count) | ||
| const | ||
| void _get_array_or_vector( | ||
| void* data, | ||
| size_t size, | ||
| TypeReflection::ScalarType cpu_scalar_type, | ||
| size_t element_count | ||
| ) const | ||
| { | ||
@@ -229,0 +233,0 @@ // CPU is assumed tightly packed, i.e., stride and size are the same value. |
@@ -78,26 +78,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| concept TraversableCursor = requires(T obj, std::string_view name_idx, uint32_t el_index) { | ||
| { | ||
| obj[name_idx] | ||
| } -> std::same_as<T>; | ||
| { | ||
| obj[el_index] | ||
| } -> std::same_as<T>; | ||
| { | ||
| obj.find_field(name_idx) | ||
| } -> std::same_as<T>; | ||
| { | ||
| obj.find_element(el_index) | ||
| } -> std::same_as<T>; | ||
| { | ||
| obj.has_field(name_idx) | ||
| } -> std::convertible_to<bool>; | ||
| { | ||
| obj.has_element(el_index) | ||
| } -> std::convertible_to<bool>; | ||
| { | ||
| obj.slang_type_layout() | ||
| } -> std::convertible_to<slang::TypeLayoutReflection*>; | ||
| { | ||
| obj.is_valid() | ||
| } -> std::convertible_to<bool>; | ||
| { obj[name_idx] } -> std::same_as<T>; | ||
| { obj[el_index] } -> std::same_as<T>; | ||
| { obj.find_field(name_idx) } -> std::same_as<T>; | ||
| { obj.find_element(el_index) } -> std::same_as<T>; | ||
| { obj.has_field(name_idx) } -> std::convertible_to<bool>; | ||
| { obj.has_element(el_index) } -> std::convertible_to<bool>; | ||
| { obj.slang_type_layout() } -> std::convertible_to<slang::TypeLayoutReflection*>; | ||
| { obj.is_valid() } -> std::convertible_to<bool>; | ||
| }; | ||
@@ -115,20 +99,8 @@ | ||
| ) { | ||
| { | ||
| obj.template get<_AnyCursorValue>(val) | ||
| } -> std::same_as<void>; // Ensure set() method exists | ||
| { | ||
| obj.template as<_AnyCursorValue>() | ||
| } -> std::same_as<_AnyCursorValue>; | ||
| { | ||
| obj._get_array(data, size, scalar_type, element_count) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._get_scalar(data, size, scalar_type) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._get_vector(data, size, scalar_type, 0) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._get_matrix(data, size, scalar_type, 0, 0) | ||
| } -> std::same_as<void>; | ||
| { obj.template get<_AnyCursorValue>(val) } -> std::same_as<void>; // Ensure set() method exists | ||
| { obj.template as<_AnyCursorValue>() } -> std::same_as<_AnyCursorValue>; | ||
| { obj._get_array(data, size, scalar_type, element_count) } -> std::same_as<void>; | ||
| { obj._get_scalar(data, size, scalar_type) } -> std::same_as<void>; | ||
| { obj._get_vector(data, size, scalar_type, 0) } -> std::same_as<void>; | ||
| { obj._get_matrix(data, size, scalar_type, 0, 0) } -> std::same_as<void>; | ||
| }; | ||
@@ -140,22 +112,10 @@ | ||
| = requires(T obj, void* data, size_t size, TypeReflection::ScalarType scalar_type, size_t element_count) { | ||
| { | ||
| obj.template set<_AnyCursorValue>({}) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj.template operator=<_AnyCursorValue>({}) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._set_array(data, size, scalar_type, element_count) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._set_scalar(data, size, scalar_type) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._set_vector(data, size, scalar_type, 0) | ||
| } -> std::same_as<void>; | ||
| { | ||
| obj._set_matrix(data, size, scalar_type, 0, 0) | ||
| } -> std::same_as<void>; | ||
| { obj.template set<_AnyCursorValue>({}) } -> std::same_as<void>; | ||
| { obj.template operator= <_AnyCursorValue>({}) } -> std::same_as<void>; | ||
| { obj._set_array(data, size, scalar_type, element_count) } -> std::same_as<void>; | ||
| { obj._set_scalar(data, size, scalar_type) } -> std::same_as<void>; | ||
| { obj._set_vector(data, size, scalar_type, 0) } -> std::same_as<void>; | ||
| { obj._set_matrix(data, size, scalar_type, 0, 0) } -> std::same_as<void>; | ||
| }; | ||
| } // namespace sgl |
@@ -119,2 +119,5 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| /// Maximum size of the persistent shader cache used to cache both shaders and pipelines. | ||
| uint64_t shader_cache_size{128 * 1024 * 1024}; | ||
| /// Native device handles for initializing with externally created device. Currenlty | ||
@@ -256,2 +259,5 @@ /// only used for CUDA interoperability. | ||
| /// Check if the device is closed. | ||
| bool is_closed() const { return m_closed; } | ||
| /// Close all open devices. | ||
@@ -679,2 +685,3 @@ static void close_all_devices(); | ||
| std::filesystem::path m_shader_cache_path; | ||
| ref<PersistentCache> m_persistent_cache; | ||
@@ -681,0 +688,0 @@ Slang::ComPtr<rhi::IDevice> m_rhi_device; |
@@ -90,2 +90,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // persistent_cache.h | ||
| class PersistentCache; | ||
| // pipeline.h | ||
@@ -92,0 +96,0 @@ |
@@ -89,5 +89,8 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| void | ||
| _set_array_unsafe(const void* data, size_t size, size_t element_count, TypeReflection::ScalarType cpu_scalar_type) | ||
| const; | ||
| void _set_array_unsafe( | ||
| const void* data, | ||
| size_t size, | ||
| size_t element_count, | ||
| TypeReflection::ScalarType cpu_scalar_type | ||
| ) const; | ||
@@ -94,0 +97,0 @@ /// CursorWriteWrappers, CursorReadWrappers |
@@ -8,3 +8,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| #define SGL_VERSION_MAJOR 0 | ||
| #define SGL_VERSION_MINOR 36 | ||
| #define SGL_VERSION_MINOR 37 | ||
| #define SGL_VERSION_PATCH 0 | ||
@@ -11,0 +11,0 @@ |
@@ -15,2 +15,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| pytest.skip("Bindless not supported on this device.") | ||
| if device_type == spy.DeviceType.cuda: | ||
| pytest.skip("Bindless textures not supported with CUDA yet.") | ||
@@ -85,2 +87,4 @@ module = device.load_module("test_bindless_texture.slang") | ||
| pytest.skip("Bindless not supported on this device.") | ||
| if device_type == spy.DeviceType.cuda: | ||
| pytest.skip("Bindless textures not supported with CUDA yet.") | ||
@@ -87,0 +91,0 @@ module = device.load_module("test_bindless_buffer.slang") |
@@ -12,2 +12,9 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| def test_print(device_type: spy.DeviceType): | ||
| # Metal test disabled until printing of float16 values in Metal has been fixed | ||
| # in Slang. | ||
| if device_type == spy.DeviceType.metal: | ||
| pytest.skip( | ||
| "Skipped due to issue in Slang: https://github.com/shader-slang/slangpy/issues/497" | ||
| ) | ||
| device = spy.Device(type=device_type, enable_print=True, label=f"print-{device_type.name}") | ||
@@ -34,2 +41,3 @@ helpers.dispatch_compute( | ||
| bool: false=false, true=true | ||
| printable_string: foo=foo | ||
| int16: min=-32768, max=32767, -12345=-12345, 12345=12345 | ||
@@ -69,2 +77,3 @@ int32: min=-2147483648, max=2147483647, -12345=-12345, 12345=12345 | ||
| bool: false=false, true=true | ||
| printable_string: foo=foo | ||
| int8: min=-128, max=127, -123=-123, 123=123 | ||
@@ -105,2 +114,3 @@ int16: min=-32768, max=32767, -12345=-12345, 12345=12345 | ||
| bool: false=false, true=true | ||
| printable_string: foo=foo | ||
| int8: min=-128, max=127, -123=-123, 123=123 | ||
@@ -114,3 +124,3 @@ int16: min=-32768, max=32767, -12345=-12345, 12345=12345 | ||
| uint64: min=0, max=18446744073709551615, 12345=12345, 23456=23456 | ||
| float16: min=0, max=0, -123.45=0, 123.45=0 | ||
| float16: min=-65504, max=65504, -123.45=-123.44, 123.45=123.44 | ||
| float32: min=-3.4028235e+38, max=3.4028235e+38, -123.45=-123.45, 123.45=123.45 | ||
@@ -123,3 +133,3 @@ int16_tX: {-4000, -3000} {-2000, -1000, 0} {1000, 2000, 3000, 4000} | ||
| uint64_tX: {10000000000000, 20000000000000} {30000000000000, 40000000000000, 50000000000000} {60000000000000, 70000000000000, 80000000000000, 90000000000000} | ||
| float16_tX: {0, 0} {0, 0, 0} {0, 0, 0, 0} | ||
| float16_tX: {-400, -300} {-200, -100, 0} {100, 200, 300, 400} | ||
| float32_tX: {-4000000, -3000000} {-2000000, -1000000, 0} {1000000, 2000000, 3000000, 4000000} | ||
@@ -139,2 +149,3 @@ float3x3: {{-4.00, -3.00, -1.00}, {+0.00, +1.00, +2.00}, {+3.00, +4.00, +5.00}} | ||
| bool: false=false, true=true | ||
| printable_string: foo=foo | ||
| int8: min=-128, max=127, -123=-123, 123=123 | ||
@@ -141,0 +152,0 @@ int16: min=-32768, max=32767, -12345=-12345, 12345=12345 |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.