Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

slangpy

Package Overview
Dependencies
Maintainers
5
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slangpy - npm Package Compare versions

Comparing version
0.37.0
to
0.38.0
+74
slangpy/builtin/descriptor.py
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
from typing import Any, cast
from slangpy.core.native import AccessType, NativeDescriptorMarshall, unpack_arg, Shape
import slangpy
from slangpy import TypeReflection, ShaderCursor
import slangpy.reflection as kfr
from slangpy import math
from slangpy.bindings import (
PYTHON_SIGNATURES,
PYTHON_TYPES,
BindContext,
BoundVariable,
CodeGenBlock,
)
from slangpy import DescriptorHandle, DescriptorHandleType
class DescriptorMarshall(NativeDescriptorMarshall):
def __init__(self, layout: kfr.SlangProgramLayout, type: DescriptorHandleType):
st = layout.find_type_by_name("DescriptorHandle<StructuredBuffer<Unknown>>")
if st is None:
raise ValueError(
f"Could not find DescriptorHandle<StructuredBuffer<Unknown>> slang type. "
"This usually indicates the slangpy module has not been imported."
)
super().__init__(st, type)
self.concrete_shape = Shape()
self.slang_type: kfr.SlangType
def resolve_type(self, context: BindContext, bound_type: kfr.SlangType):
return bound_type
def resolve_dimensionality(
self,
context: BindContext,
binding: "BoundVariable",
vector_target_type: kfr.SlangType,
):
return 0
# Call data can only be read access to primal, and simply declares it as a variable
def gen_calldata(self, cgb: CodeGenBlock, context: BindContext, binding: "BoundVariable"):
name = "(None)" if self.slang_type is None else self.slang_type.full_name
vec_name = "(None)" if binding.vector_type is None else binding.vector_type.full_name
access = binding.access
name = binding.variable_name
if access[0] in [AccessType.read, AccessType.readwrite]:
assert binding.vector_type is not None
cgb.type_alias(
f"_t_{name}",
binding.vector_type.full_name.replace("DescriptorHandle", "DescriptorType"),
)
else:
cgb.type_alias(f"_t_{name}", f"NoneType")
def reduce_type(self, context: BindContext, dimensions: int) -> kfr.SlangType:
if dimensions == 0:
return self.slang_type
raise ValueError("Cannot reduce dimensions of Descriptor")
def build_shader_object(self, context: "BindContext", data: DescriptorHandle) -> "ShaderObject":
so = context.device.create_shader_object(self.slang_type.uniform_layout.reflection)
cursor = ShaderCursor(so)
cursor.write(data)
return so
PYTHON_TYPES[DescriptorHandle] = lambda layout, handle: DescriptorMarshall(layout, handle.type)
PYTHON_SIGNATURES[DescriptorHandle] = lambda handle: f"[{handle.type}]"
#pragma once
#include "slang-rhi.h"
#include "cuda-driver-api.h"
// This file defines a minimal subset of the OptiX API needed to use the OptiX denoiser.
// slang-rhi has support for multiple versions of OptiX via an internal abstraction layer.
// To avoid introducing a hard dependency on the OptiX SDK, we define the necessary parts of
// the OptiX API here instead of including the OptiX headers directly.
// For documentation on the OptiX API, consult the official OptiX documentation from NVIDIA:
// https://developer.nvidia.com/optix
namespace rhi::optix_denoiser {
typedef void* OptixDeviceContext;
typedef void* OptixDenoiser;
enum OptixResult
{
OPTIX_SUCCESS = 0,
OPTIX_ERROR_INVALID_VALUE = 7001,
OPTIX_ERROR_HOST_OUT_OF_MEMORY = 7002,
OPTIX_ERROR_INVALID_OPERATION = 7003,
OPTIX_ERROR_FILE_IO_ERROR = 7004,
OPTIX_ERROR_INVALID_FILE_FORMAT = 7005,
OPTIX_ERROR_DISK_CACHE_INVALID_PATH = 7010,
OPTIX_ERROR_DISK_CACHE_PERMISSION_ERROR = 7011,
OPTIX_ERROR_DISK_CACHE_DATABASE_ERROR = 7012,
OPTIX_ERROR_DISK_CACHE_INVALID_DATA = 7013,
OPTIX_ERROR_LAUNCH_FAILURE = 7050,
OPTIX_ERROR_INVALID_DEVICE_CONTEXT = 7051,
OPTIX_ERROR_CUDA_NOT_INITIALIZED = 7052,
OPTIX_ERROR_VALIDATION_FAILURE = 7053,
OPTIX_ERROR_INVALID_INPUT = 7200,
OPTIX_ERROR_INVALID_LAUNCH_PARAMETER = 7201,
OPTIX_ERROR_INVALID_PAYLOAD_ACCESS = 7202,
OPTIX_ERROR_INVALID_ATTRIBUTE_ACCESS = 7203,
OPTIX_ERROR_INVALID_FUNCTION_USE = 7204,
OPTIX_ERROR_INVALID_FUNCTION_ARGUMENTS = 7205,
OPTIX_ERROR_PIPELINE_OUT_OF_CONSTANT_MEMORY = 7250,
OPTIX_ERROR_PIPELINE_LINK_ERROR = 7251,
OPTIX_ERROR_ILLEGAL_DURING_TASK_EXECUTE = 7270,
OPTIX_ERROR_INTERNAL_COMPILER_ERROR = 7299,
OPTIX_ERROR_DENOISER_MODEL_NOT_SET = 7300,
OPTIX_ERROR_DENOISER_NOT_INITIALIZED = 7301,
OPTIX_ERROR_NOT_COMPATIBLE = 7400,
OPTIX_ERROR_PAYLOAD_TYPE_MISMATCH = 7500,
OPTIX_ERROR_PAYLOAD_TYPE_RESOLUTION_FAILED = 7501,
OPTIX_ERROR_PAYLOAD_TYPE_ID_INVALID = 7502,
OPTIX_ERROR_NOT_SUPPORTED = 7800,
OPTIX_ERROR_UNSUPPORTED_ABI_VERSION = 7801,
OPTIX_ERROR_FUNCTION_TABLE_SIZE_MISMATCH = 7802,
OPTIX_ERROR_INVALID_ENTRY_FUNCTION_OPTIONS = 7803,
OPTIX_ERROR_LIBRARY_NOT_FOUND = 7804,
OPTIX_ERROR_ENTRY_SYMBOL_NOT_FOUND = 7805,
OPTIX_ERROR_LIBRARY_UNLOAD_FAILURE = 7806,
OPTIX_ERROR_DEVICE_OUT_OF_MEMORY = 7807,
OPTIX_ERROR_INVALID_POINTER = 7808,
OPTIX_ERROR_CUDA_ERROR = 7900,
OPTIX_ERROR_INTERNAL_ERROR = 7990,
OPTIX_ERROR_UNKNOWN = 7999,
};
typedef void (*OptixLogCallback)(unsigned int level, const char* tag, const char* message, void* cbdata);
enum OptixDeviceContextValidationMode
{
OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_OFF = 0,
OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL = 0xFFFFFFFF
};
struct OptixDeviceContextOptions
{
OptixLogCallback logCallbackFunction;
void* logCallbackData;
int logCallbackLevel;
OptixDeviceContextValidationMode validationMode;
};
enum OptixPixelFormat
{
OPTIX_PIXEL_FORMAT_HALF1 = 0x220a,
OPTIX_PIXEL_FORMAT_HALF2 = 0x2207,
OPTIX_PIXEL_FORMAT_HALF3 = 0x2201,
OPTIX_PIXEL_FORMAT_HALF4 = 0x2202,
OPTIX_PIXEL_FORMAT_FLOAT1 = 0x220b,
OPTIX_PIXEL_FORMAT_FLOAT2 = 0x2208,
OPTIX_PIXEL_FORMAT_FLOAT3 = 0x2203,
OPTIX_PIXEL_FORMAT_FLOAT4 = 0x2204,
OPTIX_PIXEL_FORMAT_UCHAR3 = 0x2205,
OPTIX_PIXEL_FORMAT_UCHAR4 = 0x2206,
OPTIX_PIXEL_FORMAT_INTERNAL_GUIDE_LAYER = 0x2209
};
struct OptixImage2D
{
CUdeviceptr data;
unsigned int width;
unsigned int height;
unsigned int rowStrideInBytes;
unsigned int pixelStrideInBytes;
OptixPixelFormat format;
};
enum OptixDenoiserModelKind
{
OPTIX_DENOISER_MODEL_KIND_AOV = 0x2324,
OPTIX_DENOISER_MODEL_KIND_TEMPORAL_AOV = 0x2326,
OPTIX_DENOISER_MODEL_KIND_UPSCALE2X = 0x2327,
OPTIX_DENOISER_MODEL_KIND_TEMPORAL_UPSCALE2X = 0x2328,
OPTIX_DENOISER_MODEL_KIND_LDR = 0x2322,
OPTIX_DENOISER_MODEL_KIND_HDR = 0x2323,
OPTIX_DENOISER_MODEL_KIND_TEMPORAL = 0x2325
};
enum OptixDenoiserAlphaMode
{
OPTIX_DENOISER_ALPHA_MODE_COPY = 0,
OPTIX_DENOISER_ALPHA_MODE_DENOISE = 1
};
struct OptixDenoiserOptions
{
unsigned int guideAlbedo;
unsigned int guideNormal;
OptixDenoiserAlphaMode denoiseAlpha;
};
struct OptixDenoiserGuideLayer
{
OptixImage2D albedo;
OptixImage2D normal;
OptixImage2D flow;
OptixImage2D previousOutputInternalGuideLayer;
OptixImage2D outputInternalGuideLayer;
OptixImage2D flowTrustworthiness;
};
enum OptixDenoiserAOVType
{
OPTIX_DENOISER_AOV_TYPE_NONE = 0,
OPTIX_DENOISER_AOV_TYPE_BEAUTY = 0x7000,
OPTIX_DENOISER_AOV_TYPE_SPECULAR = 0x7001,
OPTIX_DENOISER_AOV_TYPE_REFLECTION = 0x7002,
OPTIX_DENOISER_AOV_TYPE_REFRACTION = 0x7003,
OPTIX_DENOISER_AOV_TYPE_DIFFUSE = 0x7004
};
struct OptixDenoiserLayer
{
OptixImage2D input;
OptixImage2D previousOutput;
OptixImage2D output;
OptixDenoiserAOVType type;
};
struct OptixDenoiserParams
{
CUdeviceptr hdrIntensity;
float blendFactor;
CUdeviceptr hdrAverageColor;
unsigned int temporalModeUsePreviousLayers;
};
struct OptixDenoiserSizes
{
size_t stateSizeInBytes;
size_t withOverlapScratchSizeInBytes;
size_t withoutOverlapScratchSizeInBytes;
unsigned int overlapWindowSizeInPixels;
size_t computeAverageColorSizeInBytes;
size_t computeIntensitySizeInBytes;
size_t internalGuideLayerPixelSizeInBytes;
};
class IOptixDenoiserAPI : public ISlangUnknown
{
public:
SLANG_COM_INTERFACE(0x746a5883, 0x2a7e, 0x4d67, {0xbe, 0x2e, 0x62, 0x65, 0x8c, 0x02, 0x9e, 0x89});
virtual ~IOptixDenoiserAPI() = default;
virtual SLANG_NO_THROW const char* SLANG_MCALL optixGetErrorName(OptixResult result) = 0;
virtual SLANG_NO_THROW const char* SLANG_MCALL optixGetErrorString(OptixResult result) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDeviceContextCreate(
CUcontext fromContext,
const OptixDeviceContextOptions* options,
OptixDeviceContext* context
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDeviceContextDestroy(OptixDeviceContext context) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserCreate(
OptixDeviceContext context,
OptixDenoiserModelKind modelKind,
const OptixDenoiserOptions* options,
OptixDenoiser* returnHandle
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserCreateWithUserModel(
OptixDeviceContext context,
const void* data,
size_t dataSizeInBytes,
OptixDenoiser* returnHandle
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserDestroy(OptixDenoiser handle) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserComputeMemoryResources(
const OptixDenoiser handle,
unsigned int maximumInputWidth,
unsigned int maximumInputHeight,
OptixDenoiserSizes* returnSizes
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserSetup(
OptixDenoiser denoiser,
CUstream stream,
unsigned int inputWidth,
unsigned int inputHeight,
CUdeviceptr denoiserState,
size_t denoiserStateSizeInBytes,
CUdeviceptr scratch,
size_t scratchSizeInBytes
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserInvoke(
OptixDenoiser handle,
CUstream stream,
const OptixDenoiserParams* params,
CUdeviceptr denoiserData,
size_t denoiserDataSize,
const OptixDenoiserGuideLayer* guideLayer,
const OptixDenoiserLayer* layers,
unsigned int numLayers,
unsigned int inputOffsetX,
unsigned int inputOffsetY,
CUdeviceptr scratch,
size_t scratchSizeInBytes
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserComputeIntensity(
OptixDenoiser handle,
CUstream stream,
const OptixImage2D* inputImage,
CUdeviceptr outputIntensity,
CUdeviceptr scratch,
size_t scratchSizeInBytes
) = 0;
virtual SLANG_NO_THROW OptixResult SLANG_MCALL optixDenoiserComputeAverageColor(
OptixDenoiser handle,
CUstream stream,
const OptixImage2D* inputImage,
CUdeviceptr outputAverageColor,
CUdeviceptr scratch,
size_t scratchSizeInBytes
) = 0;
};
} // namespace rhi::optix_denoiser
/// Create an instance of the IOptixDenoiserAPI for the specified OptiX version.
/// The format matches the OPTIX_VERSION macro, e.g. 90000 for version 9.0.0.
/// \param optixVersion The specific OptiX version to target or 0 to target the highest version available.
/// \param outAPI The created API instance.
/// \return SLANG_OK if successful, SLANG_E_NOT_AVAILABLE if the specified version is not available, or another error code if the creation failed.
extern "C" SLANG_RHI_API rhi::Result SLANG_STDCALL
rhiCreateOptixDenoiserAPI(uint32_t optixVersion, rhi::optix_denoiser::IOptixDenoiserAPI** outAPI);

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

+2
-3
Metadata-Version: 2.4
Name: slangpy
Version: 0.37.0
Version: 0.38.0
Summary: Easily call Slang functions and integrate with PyTorch auto diff directly from Python.

@@ -70,3 +70,2 @@ 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>

- [AsmJit](https://github.com/asmjit/asmjit) (Zlib)
- [BS::thread-pool](https://github.com/bshoshany/thread-pool) (MIT)
- [Dear ImGui](https://github.com/ocornut/imgui) (MIT)

@@ -106,5 +105,5 @@ - [doctest](https://github.com/doctest/doctest) (MIT)

note = {https://github.com/shader-slang/slangpy},
version = {0.37.0},
version = {0.38.0},
year = 2025
}
```
+39
-41
slangpy/__init__.py,sha256=PsbtOD5NRRgDcN2C7SbPnePNpAzce326xQM9tZhBT9M,1948
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/__init__.pyi,sha256=hdJCkGxZ44CBGW7CBAI4UP0jTjlJxOJfIXK1B4b2itU,201693
slangpy/libsgl.dylib,sha256=8ap9DUmUF91-xo_l1us9BlvVZgSJ0hGmWjypa41WRV8,8447232
slangpy/libslang-compiler.0.2025.21.dylib,sha256=ESIcIVVl-5DOWk3oDetBJGAZGHH80LT3sKv9AIu-3vU,19952128
slangpy/libslang-glsl-module-2025.21.dylib,sha256=J-oK3qy9Y7RSkxQYxXzueDKdct61fDO8PQEBSfBYjtw,1423296
slangpy/libslang-glslang-2025.21.dylib,sha256=uipHT1pgF9Y7P9Dy6EyR4gTvPq1Hm-8mxhGx0qVurNc,8067248
slangpy/libslang-rhi.a,sha256=9-9Snfg6ElYdssheypMNRCbSnppeytQcaEU-GxcHofE,74025760
slangpy/slangpy_ext.cpython-310-darwin.so,sha256=64OfxaMq_Foujaucg7HkjLzmV3M9MHYTYyS9KtAN6GA,6728464
slangpy/benchmarks/conftest.py,sha256=rAYyblUkfrklcEe_TbJ0UuSAzQ8b0pmAbrWG2_s1nrg,438

@@ -19,5 +18,6 @@ slangpy/benchmarks/test_benchmark_interop.py,sha256=7xkivr7F1sD7_VRUVivVy125whirpZkbuttauURqgDw,15467

slangpy/bindings/typeregistry.py,sha256=fHuoHVOdhHDVFVxYiHDWQAe46aOQO19amguaCJY18eM,1392
slangpy/builtin/__init__.py,sha256=rqfq4cqkgCXxbpmY2LLNRcJIPbPhD6SQRus86v-hGKQ,640
slangpy/builtin/__init__.py,sha256=EjJBF33M8uMQjGADFEyo_t1wP_63MIX4z7NnTgwLYNQ,683
slangpy/builtin/accelerationstructure.py,sha256=WqBN1Ts4sbielVaoDaFMJKq6or_8ma_wjbFHJlw5ZOM,1900
slangpy/builtin/array.py,sha256=AHO9oBKX4A9U71GI3S3DY5XXN6rnzbQKJBOCe73vGyE,5435
slangpy/builtin/array.py,sha256=ss0sBCIjUMqcLptoPVKkGhvnkaGPY3NBANLpn4E-E9o,5704
slangpy/builtin/descriptor.py,sha256=c31WjhZ0py3F_1NkzOszSG1UPiTztuD4-95WmG7Ugls,2782
slangpy/builtin/diffpair.py,sha256=SSsfyUs8M8fgS5K9SVeSRKsGEUg34U-0yq0XoB_P1BM,7457

@@ -35,5 +35,5 @@ slangpy/builtin/ndbuffer.py,sha256=YkVA1Wcmi_DVzwHpvAmuxQ_RlXeXMpLP-PtTN4AeLSE,16666

slangpy/core/__init__.py,sha256=TJYDzVSv8gf6xRO-8P6Fg8BpYxp3rjdxiUgt18yd_R4,94
slangpy/core/calldata.py,sha256=oVK6IexBHGWsp7Qffx1wS75QymE8V57HCRCKC-bmxUM,21458
slangpy/core/calldata.py,sha256=zeCgBN3egiSInusYYhkYJbAwS6MJPmIkvF64IXpGtkQ,21658
slangpy/core/callsignature.py,sha256=dH36kpZwi5-HCkl11WrNDEW_nrLxs-QGMk0ClwsaNmo,28330
slangpy/core/dispatchdata.py,sha256=S176OEjLyzVovpkomRllpxVproTy4KttSRnU38ie5Z0,10955
slangpy/core/dispatchdata.py,sha256=hALSKJxvclrhNiLp_ZW2uaoJOoWWIWcWxrZLHT_TOsU,11058
slangpy/core/enums.py,sha256=lLLVsfRqLWNMDOE7eaxOyy6t6KNzbXjv2JsvmepltU0,211

@@ -49,3 +49,3 @@ slangpy/core/function.py,sha256=25UwWJ2-Hjesiyk0GextPawvmnHLV5vgsMEr6QN6pDA,23663

slangpy/core/struct.py,sha256=cJmnWz_kTte8DYXdgJuZixKom61uPw_ww-HP7HWG0YU,5288
slangpy/core/utils.py,sha256=devEbbk-qd9LziCCI-C1dTVDfe6KM1A0KtGqbqsfNkI,9114
slangpy/core/utils.py,sha256=hz0f1G6qecUX6ZLqvq0x6lw4hl2lr8qprfELt46kQRw,9228
slangpy/data/.git,sha256=WvWYQUPc7kw3YKZLsDTuqgEidzs4hYfYnDtBpdOjEW0,29

@@ -107,7 +107,7 @@ slangpy/data/.gitattributes,sha256=GfW6_kw_fHty1NpYYsdjB7FDnFdaG8NH1jX7ykuUEaE,252

slangpy/include/slang-image-format-defs.h,sha256=Na2baM-oiRV7K_Sk7zkmO0rV8Pdg_-5mrKA0OOg2O80,2421
slangpy/include/slang-rhi-config.h,sha256=Em9yoqMRi3H21r1rWhJgTwSbWUk88IEQzrQ-ot2Ppf0,403
slangpy/include/slang-rhi.h,sha256=fQ4y3wlWXyTDj_Tj9JbxNt-IclRJooKbuNh3gSiDY8Y,106958
slangpy/include/slang-rhi-config.h,sha256=ohwkpTGf_x9M0msi11rP5Kebjo-CDTNAgDdDaS1s74A,493
slangpy/include/slang-rhi.h,sha256=Q3T_5acDM7mgYRYaNS3McqOqV8aQ0z6yItO54Uu8oyk,107429
slangpy/include/slang-user-config.h,sha256=-DTfKSDXKnCWR_NU6n96RYbQyYmM5ms2IFQH8UWNn7Y,151
slangpy/include/slang.h,sha256=sQbZxKt6WhP8F8wvU8EnyMzltucfmIWgQ_7tdZnhRvM,179036
slangpy/include/sgl/sgl.h,sha256=k_NcH7S5laDFiCdCBbX2fpEhsHC3YTKHaXyrzoSVRxU,610
slangpy/include/slang.h,sha256=tRIX8LBuy5aqmrqSR8exmEjzgm1yCGytsCwhLDeEjxM,179110
slangpy/include/sgl/sgl.h,sha256=7rBjNzv2tw158kNaGuEse7FFv7v5ghgKWftQbKL0JUI,610
slangpy/include/sgl/sgl_pch.h,sha256=SD1ALBpwwkcMlCnU_V8nHdSvS6-NZIXZOv5Rd6_r5z8,131

@@ -120,3 +120,3 @@ slangpy/include/sgl/app/app.h,sha256=tyvkNXNrsvsYWL98uSxVKcYesdiJ2ZRqdwJpfw9dbwA,2809

slangpy/include/sgl/core/dds_file.h,sha256=y0bUeGRtQa54E8K1-YR6YL3PqveIX1s9FvLn5bvCJ38,3023
slangpy/include/sgl/core/enum.h,sha256=D_ZS17JTYQ4_56pBgFAAE3n-FDVwENMwiAXVHXzL2cI,6205
slangpy/include/sgl/core/enum.h,sha256=bWmBLyBL8F7AMTyGa4ET6-ZBzl3otOLu-uYI0JurJ3g,6379
slangpy/include/sgl/core/error.h,sha256=o-Mi9Fo-j3sDX1BZnIljNdLQtRylKiJuPYr3AQvCCS0,6727

@@ -144,3 +144,3 @@ slangpy/include/sgl/core/file_stream.h,sha256=7JXL14o9sdLC4DJmKoyJ5jWyN6wIBdK1ALudklAXYQs,1509

slangpy/include/sgl/core/string.h,sha256=vtaxwKW1oCGp3rIsGGxQwDNG8jOPIxvj9F95DVoSmTg,8187
slangpy/include/sgl/core/thread.h,sha256=A9W4s8uQ2_BAxL-yUZlGZaIrWSngO9bMUZiGzyK7qpE,670
slangpy/include/sgl/core/thread.h,sha256=PHiwXJW6UYQeH7LDxlvhReHCqrkDQnhmX3txpuqEPog,9066
slangpy/include/sgl/core/timer.h,sha256=VfajHJRJi-N-EwJqrjYBLUxNlHjO3MsHjuuE0CqDZy4,1552

@@ -151,3 +151,3 @@ slangpy/include/sgl/core/traits.h,sha256=ePRnfVyGVpKLlHhP6oVujGJBEIChcIOUVosiXzk5NMw,284

slangpy/include/sgl/device/agility_sdk.h,sha256=xQqhWP4-IRyKhLaiIXpxVpnBUElKNQGAQyTFSdWd0-4,491
slangpy/include/sgl/device/blit.h,sha256=X7Ko36cdfdhcJWTP_JwLogEbSLWKeFr8NtA0Y7ekpyk,2983
slangpy/include/sgl/device/blit.h,sha256=PCxSaja50uiwrjlo8IHMZtDaht8WWvnWIKt82K0WPIg,3025
slangpy/include/sgl/device/buffer_cursor.h,sha256=tSIiHV_fOG99Ob226461yRM9dLn3N8uvV2T8G7ecRNA,6451

@@ -161,3 +161,3 @@ slangpy/include/sgl/device/command.h,sha256=cYCjBrQAcjDKc83PWGxbtju7vYEEheJTgrDVsJ_BUdw,14170

slangpy/include/sgl/device/debug_logger.h,sha256=hK98tQ8RvVBgI1Z5EoqJKuL9yBU_S2j4EdsWq-l4bGg,2502
slangpy/include/sgl/device/device.h,sha256=8sgNEo3z4kBAxj5RK-prlMXmnENP_gUr3eXu9xUSWM0,25216
slangpy/include/sgl/device/device.h,sha256=DgTVDbUP2em5sV-m_oIpIDSKM-u1VVtjJTJS78KOiYk,26084
slangpy/include/sgl/device/device_child.h,sha256=4euwuyohyciWFNpgWLHrNyCLWNQhEDsFSq9tSncvgt4,985

@@ -178,3 +178,3 @@ slangpy/include/sgl/device/fence.h,sha256=kA3A46D5lD56RD92eGWqIr-qh_NzFK2yfmFeTTo0g50,2875

slangpy/include/sgl/device/query.h,sha256=Md1qMjxaCo4GdTqJzCS4_Rw3Gr5E3LBQ5vtzuzM_Vzk,1382
slangpy/include/sgl/device/raytracing.h,sha256=GoorG0eP74PnJs42KN_0l0yPyq30rC17LwTnO9Bo3uc,10328
slangpy/include/sgl/device/raytracing.h,sha256=Sv44SDetN7Ly037g2Sccc6qab2H5ZZoa0RrHIZQiyMs,12903
slangpy/include/sgl/device/reflection.h,sha256=Tw51sL9nucX28bv-H2iJJJik-YnwMM12KYv-LSmLfaM,46464

@@ -199,3 +199,2 @@ slangpy/include/sgl/device/resource.h,sha256=XpiYTL4bPV9cfIwWiFh0shoIiDtB12LYMQlV9va9JA0,22866

slangpy/include/sgl/math/quaternion_types.h,sha256=fhcgHf9Hi-W3boDMWc_eKapv65t1trA_giAXYZ1OvpU,1747
slangpy/include/sgl/math/ray.h,sha256=QHABXTKPhNdIfO8ylQ0F8eLCyx2B0hheWTseta4Czz0,1204
slangpy/include/sgl/math/scalar_math.h,sha256=Y2gZQ_SM503BJfhEMRLtU7Nh3r3tVX6FVVtGn1TCnVE,12060

@@ -209,4 +208,4 @@ slangpy/include/sgl/math/scalar_types.h,sha256=gyYjxBOgFEsb9vQh-ygoB6pH7w0HfDoDPAJxP1yEOhk,2631

slangpy/include/sgl/ui/imgui_config.h,sha256=3JONP4QnGQh6Nm2t5sKd_8RzF_nL_nnsdxuJ_7yqcD0,3823
slangpy/include/sgl/ui/ui.h,sha256=BBakRpppt2dg50sAwMRZ7pS4AJK5LCaQVnrCZF8bfNU,1606
slangpy/include/sgl/ui/widgets.h,sha256=AU4q_HxS8injXrRiJH3mY787dqB-X2wCV4g24andcLc,25276
slangpy/include/sgl/ui/ui.h,sha256=PKS0FZz8L0r8B1V2Qsggcljgin-HxCqWr_0lhNiDl6E,2514
slangpy/include/sgl/ui/widgets.h,sha256=9NFzuUfBJg67P47dSBTfc0OutnNPhztrV-1aHKQzNsQ,24503
slangpy/include/sgl/utils/renderdoc.h,sha256=fml8Na0vRA_4CR4xGhfn5HDVwhMTDJmx-kLQv5MKTHE,1356

@@ -221,2 +220,3 @@ slangpy/include/sgl/utils/slangpy.h,sha256=Juw3QwQe13lU-WcF7A1lPf6r3nX6agCJFIberlzhPp0,4835

slangpy/include/slang-rhi/glfw.h,sha256=vQJ4DcyIo1KxTZKzBQYhi4jEFniddSy0FDttci0VC8I,679
slangpy/include/slang-rhi/optix-denoiser.h,sha256=4qV1L7YP5dzFtvscsCWTEGX5A0Yh3W90sgq5ODg1Qbc,9102
slangpy/include/slang-rhi/shader-cursor.h,sha256=sPTPAGy9u4_ugEWonK3QROtfJsd--c23DJana7Kk3mQ,18223

@@ -231,8 +231,6 @@ slangpy/math/__init__.py,sha256=iasSej-enqU0bZTocJyJYiXTfADJ9sd89NwHtF1PDI0,58

slangpy/renderdoc/__init__.pyi,sha256=tGkBiHP11-d0bCQWQa2rnw4L75VWWWEUCeinTaeYrqo,1315
slangpy/shaders/sgl/device/blit.slang,sha256=EjRhRmq9uATe1kG3oiT2W4ppBgDHSSYbdhMf58IYGm8,3219
slangpy/shaders/sgl/device/blit.slang,sha256=XPu39ATPRyO2qeMthHqTUtfvakdGgHSymysqmyB9JOs,3099
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=MGiY3N2wNPDxYgjppPLkOjc9Vx892-tS-diO5ehezKM,10185
slangpy/shaders/sgl/math/constants.slang,sha256=5A9YEQqB65jpbs0pmLyw8U10xAzD6HydwbbIioh4Jr8,121
slangpy/shaders/sgl/math/ray.slang,sha256=xeHNuWaAsTmubx0ilAvQ3ihRY9AXG2swnu2Oqg_9wKo,683
slangpy/shaders/sgl/device/print.slang,sha256=N4BAX-hvR3hxTbEdt6y6HAaQp1c8ksVgCGwvrTQN2q0,10500
slangpy/shaders/sgl/ui/imgui.slang,sha256=5CDPan4dRX2N4FqoeOTCbDvEb9O5sj9kj6vNBnBL10Y,1062

@@ -242,3 +240,3 @@ slangpy/slang/atomics.slang,sha256=D8rkPiNwYmf5PuTxSFOPEtLlw7qlJOuJDJQDeOlvIcQ,5310

slangpy/slang/callshape.slang,sha256=3mqdZcwViFxYQ1FDwbPKPeMHiL8ZAhrzwtKZg3bVjRc,4988
slangpy/slang/core.slang,sha256=58QxF4ZPBTKDVo9t_QTyWqRuWLCApnnzuc5I8j__kps,20145
slangpy/slang/core.slang,sha256=F7eUULHVaemgvNUrI6w6JivHG7MrTGw0mrtMcwVI9jY,21185
slangpy/slang/gridarg.slang,sha256=fi57KwLDPKlAVTJBmgI7__SdvV_GPVDacLGgHCZyhu8,1917

@@ -252,3 +250,3 @@ slangpy/slang/randfloatarg.slang,sha256=5nCHvBf15L4T3zaaoof68o3IAOs9TspndVI5vd7Wfzw,1193

slangpy/slangpy/__init__.py,sha256=iasSej-enqU0bZTocJyJYiXTfADJ9sd89NwHtF1PDI0,58
slangpy/slangpy/__init__.pyi,sha256=ETgClZZDNoMZqtHrORVjG7_J34Vp8EzyUpjBwOdpIEM,22491
slangpy/slangpy/__init__.pyi,sha256=OdKLM88fA0sKAHnShqC_3rRFh_3m4k7bEMJN6pPYeMg,23054
slangpy/testing/__init__.py,sha256=iasSej-enqU0bZTocJyJYiXTfADJ9sd89NwHtF1PDI0,58

@@ -273,3 +271,3 @@ slangpy/testing/helpers.py,sha256=aQBRM5wYX_MW11cqWzd_HBnjekS28KsHTEaOVOoaXQM,15087

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_blit.py,sha256=Sua7Dz1bLu_sNiBpDIhSBmS5v7xHJmYKVI_hl2Vo3VM,1635
slangpy/tests/device/test_buffer.py,sha256=I7aLlw06SOAJhl-iIuy50SuNNs6OJIVHnULZxDwtbjA,7159

@@ -386,3 +384,3 @@ slangpy/tests/device/test_buffer.slang,sha256=gteU9upzn-Bf8o4foGlzTjVzYoElUKOXAv4Ibtn0S2Y,1279

slangpy/tests/slangpy_tests/test_transforms.slang,sha256=b_fibfjIK5tH9Ax98OxzTQEhslqA7-CT_VUk0u18FnI,434
slangpy/tests/slangpy_tests/test_type_conformances.py,sha256=4iG0kQAuQqxxDwWIuX2N9WIUeNXmpPUYvJxiIV52B2w,1266
slangpy/tests/slangpy_tests/test_type_conformances.py,sha256=fdOjFKCJWKFwgKlWU2pvDICJdmGORWJh4VQNn9R8jnA,1300
slangpy/tests/slangpy_tests/test_vector_function_call.py,sha256=CUrF9JTb2tXROGdQ8Td0H_dw0xsNIW1wtxp5CCvkB4k,4316

@@ -395,3 +393,3 @@ slangpy/tests/slangpy_tests/test_vectorizing.py,sha256=k8amF303ZkJtdQkhOSC2MEKvfjWFfQr_4tDksx7dhOE,14052

slangpy/tests/utils/test_tev.py,sha256=Sk-6By-RvLQh6BpCr8onZqRBzCuuKNSqF8dmTaBM9IM,1215
slangpy/tests/utils/test_texture_loader.py,sha256=eioK2amTAuVEmL9okqLSVAeXpoZdhEdq3-yryk7bMmY,11044
slangpy/tests/utils/test_texture_loader.py,sha256=6rSNItFbtgTtBCra7D1TkooVNwyGVBYXOvlX9FBZFtM,11713
slangpy/tev/__init__.py,sha256=iasSej-enqU0bZTocJyJYiXTfADJ9sd89NwHtF1PDI0,58

@@ -405,3 +403,3 @@ slangpy/tev/__init__.pyi,sha256=sPFy-nFM05BR2ilk8uO2JqmztGReJLhjDjLxASN0Qtk,2745

slangpy/types/__init__.py,sha256=fmSHX1CNHOdyiFQ6Q2QVsTHghJiADss_Wf9Y23SruNU,731
slangpy/types/buffer.py,sha256=3cJBBREBwzLtiAIHaXn6woL3JCY-YAseInt3h2Npiu4,16584
slangpy/types/buffer.py,sha256=4OAvobmJrlSSTt819FS_1vVcgo3WGCRO4RonIb4k5jU,16531
slangpy/types/callidarg.py,sha256=hIPIfFw17TbzL5rpmBcpZN5lsQK4ge66ZAVwO9wc-yA,2623

@@ -416,7 +414,7 @@ slangpy/types/diffpair.py,sha256=K9C4kplAdFJbjeDoe6f7JYbM43Cs3S60ygjGonrrVqg,1627

slangpy/ui/__init__.py,sha256=iasSej-enqU0bZTocJyJYiXTfADJ9sd89NwHtF1PDI0,58
slangpy/ui/__init__.pyi,sha256=6oKnW1qupqQCPSe82znQzssxR5mw6zAuM4mGr3CaSvQ,30512
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,,
slangpy/ui/__init__.pyi,sha256=ufVijkyyxsGtuXbi8_L8uqzRopz0UAl3Wj2W80GRKng,30471
slangpy-0.38.0.dist-info/licenses/LICENSE,sha256=tzjZi3clQUtTTBGaxmEmh2uMvUCqiuSCENsZBxS4FnA,1490
slangpy-0.38.0.dist-info/METADATA,sha256=D24xMXdBPXHEmC2RJxDvBie7qhMqokwZ2GMZlqJcWlw,4389
slangpy-0.38.0.dist-info/WHEEL,sha256=QbwVjH-TlueSdsOKSic424jsJD30r52gknYt4wXVwF0,109
slangpy-0.38.0.dist-info/top_level.txt,sha256=Wo7_Eny8d-MI3ZHT-XHGGMEKKIK38FlAmUCz8AffxA0,8
slangpy-0.38.0.dist-info/RECORD,,

@@ -11,2 +11,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .structuredbuffer import BufferMarshall
from .descriptor import DescriptorMarshall
from .texture import TextureMarshall

@@ -13,0 +14,0 @@ from .array import ArrayMarshall

@@ -19,2 +19,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from slangpy.core.native import AccessType, CallContext, NativeValueMarshall, unpack_arg
from slangpy.core.utils import is_type_castable_on_host
import slangpy.reflection as kfr

@@ -37,2 +38,3 @@

self.slang_type = st
self.element_type = element_type
self.concrete_shape = shape

@@ -54,2 +56,6 @@

return self.slang_type.element_type
elif isinstance(bound_type, kfr.ArrayType):
if is_type_castable_on_host(self.element_type, bound_type.element_type):
return bound_type
return super().resolve_type(context, bound_type)

@@ -56,0 +62,0 @@

@@ -341,3 +341,5 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

self.pipeline = device.create_compute_pipeline(
program, defer_target_compilation=True
program,
defer_target_compilation=True,
label=f"{build_info.module.name}_{build_info.name}_compute_call",
)

@@ -385,2 +387,3 @@ build_info.module.pipeline_cache[hash] = self.pipeline

defer_target_compilation=True,
label=f"{build_info.module.name}_{build_info.name}_rt_call",
)

@@ -387,0 +390,0 @@ build_info.module.pipeline_cache[hash] = self.pipeline

@@ -211,3 +211,5 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

self.compute_pipeline = device.create_compute_pipeline(
program, defer_target_compilation=True
program,
defer_target_compilation=True,
label=f"{build_info.module.name}_{build_info.name}_dispatch",
)

@@ -214,0 +216,0 @@ self.device = device

@@ -15,2 +15,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

get_cuda_current_context_native_handles,
BindlessDesc,
)

@@ -31,2 +32,3 @@ from slangpy.reflection import SlangType

existing_device_handles: Optional[Sequence[NativeHandle]] = None,
bindless_options: Optional[BindlessDesc] = None,
):

@@ -65,2 +67,3 @@ """

existing_device_handles=existing_device_handles,
bindless_options=bindless_options,
)

@@ -67,0 +70,0 @@

@@ -38,3 +38,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

const auto& items = EnumInfo<T>::items;
auto it = std::find_if(items.begin(), items.end(), [value](const auto& item) { return item.first == value; });
auto it = std::find_if(
items.begin(),
items.end(),
[value](const auto& item)
{
return item.first == value;
}
);
if (it == items.end())

@@ -53,3 +60,10 @@ return fmt::format("{}({})", EnumInfo<T>::name, std::underlying_type_t<T>(value));

const auto& items = EnumInfo<T>::items;
auto it = std::find_if(items.begin(), items.end(), [name](const auto& item) { return item.second == name; });
auto it = std::find_if(
items.begin(),
items.end(),
[name](const auto& item)
{
return item.second == name;
}
);
if (it == items.end())

@@ -67,3 +81,10 @@ SGL_THROW("Invalid enum name \"{}\"", name);

const auto& items = EnumInfo<T>::items;
auto it = std::find_if(items.begin(), items.end(), [name](const auto& item) { return item.second == name; });
auto it = std::find_if(
items.begin(),
items.end(),
[name](const auto& item)
{
return item.second == name;
}
);
return it != items.end();

@@ -70,0 +91,0 @@ }

@@ -6,7 +6,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include "sgl/core/macros.h"
#include "sgl/core/error.h"
#include <BS_thread_pool.hpp>
#include <nanothread/nanothread.h>
#include <type_traits>
#include <future>
#include <mutex>
#include <vector>

@@ -18,13 +20,300 @@ namespace sgl::thread {

/// Block until all scheduled tasks are completed.
SGL_API void wait_for_tasks();
// Import nanothread symbols into sgl::thread namespace.
using ::Task;
using ::task_submit_dep;
using ::task_release;
using ::task_wait;
using ::task_wait_and_release;
using ::task_query;
using ::task_time;
using ::task_time_rel;
using ::task_retain;
SGL_API BS::thread_pool& global_thread_pool();
/// Task handle type.
using TaskHandle = Task*;
template<typename F, typename... A, typename R = std::invoke_result_t<std::decay_t<F>, std::decay_t<A>...>>
std::future<R> do_async(F&& task, A&&... args)
/// Run a function asynchronously in a new task.
/// See nanothread documentation on `task_submit_dep` for details.
/// \param func Function to call.
/// \param parents Parent tasks to wait for before executing.
/// \param parent_count Number of parent tasks.
/// \return The new task.
template<typename Func>
[[nodiscard]] TaskHandle do_async(Func&& func, const TaskHandle* parents, size_t parent_count)
{
return global_thread_pool().submit(std::forward<F>(task), std::forward<A>(args)...);
using BaseFunc = std::decay_t<Func>;
struct Payload {
BaseFunc func;
};
auto callback = [](uint32_t /* unused */, void* payload)
{
((Payload*)payload)->func();
};
if constexpr (std::is_trivially_copyable_v<BaseFunc> && std::is_trivially_destructible_v<BaseFunc>) {
// Payload is trivially copyable/destructible. Let nanothread manage the payload memory.
Payload payload{std::forward<Func>(func)};
return task_submit_dep(
nullptr, // default pool
parents,
(uint32_t)parent_count,
1,
callback,
&payload,
sizeof(Payload),
nullptr,
1
);
} else {
// Payload is non-trivially copyable/destructible. Manage payload manually.
Payload* payload = new Payload{std::forward<Func>(func)};
auto deleter = [](void* payload)
{
delete (Payload*)payload;
};
return task_submit_dep(
nullptr, // default pool
parents,
(uint32_t)parent_count,
1,
callback,
payload,
0,
deleter,
1
);
}
}
/// Run a function asynchronously in a new task.
/// See nanothread documentation on `task_submit_dep` for details.
/// \param func Function to call.
/// \param parents Parent tasks to wait for before executing.
/// \return The new task.
template<typename Func>
[[nodiscard]] TaskHandle do_async(Func&& func, std::initializer_list<TaskHandle> parents = {})
{
return do_async(std::forward<Func>(func), parents.begin(), parents.size());
}
template<typename Int>
struct blocked_range {
public:
blocked_range(Int begin, Int end, Int block_size = 1)
: m_begin(begin)
, m_end(end)
, m_block_size(block_size)
{
}
struct iterator {
Int value;
iterator(Int value)
: value(value)
{
}
Int operator*() const { return value; }
operator Int() const { return value; }
void operator++() { value++; }
bool operator==(const iterator& it) { return value == it.value; }
bool operator!=(const iterator& it) { return value != it.value; }
};
uint32_t blocks() const { return (uint32_t)((m_end - m_begin + m_block_size - 1) / m_block_size); }
iterator begin() const { return iterator(m_begin); }
iterator end() const { return iterator(m_end); }
Int block_size() const { return m_block_size; }
private:
Int m_begin;
Int m_end;
Int m_block_size;
};
/// Run a parallel for-loop and block until completed.
/// \param range Loop range.
/// \param func Function to execute (taking a `blocked_range<Int>` as an argument).
template<typename Int, typename Func>
void parallel_for(const blocked_range<Int>& range, Func&& func)
{
struct Payload {
Func* f;
Int begin, end, block_size;
};
Payload payload{&func, range.begin(), range.end(), range.block_size()};
auto callback = [](uint32_t index, void* payload)
{
Payload* p = (Payload*)payload;
Int begin = p->begin + p->block_size * (Int)index, end = begin + p->block_size;
if (end > p->end)
end = p->end;
(*p->f)(blocked_range<Int>(begin, end));
};
task_submit_and_wait(
nullptr, // default pool
range.blocks(),
callback,
&payload
);
}
/// Run a parallel for-loop asynchronously in a new task.
/// See nanothread documentation on `task_submit_dep` for details.
/// \param range Loop range.
/// \param func Function to execute (taking a `blocked_range<Int>` as an argument).
/// \param parents Parent tasks to wait for before executing.
/// \param parent_count Number of parent tasks.
/// \return The new task.
template<typename Int, typename Func>
[[nodiscard]] TaskHandle
parallel_for_async(const blocked_range<Int>& range, Func&& func, const TaskHandle* parents, size_t parent_count)
{
using BaseFunc = typename std::decay<Func>::type;
struct Payload {
BaseFunc f;
Int begin, end, block_size;
};
auto callback = [](uint32_t index, void* payload)
{
Payload* p = (Payload*)payload;
Int begin = p->begin + p->block_size * (Int)index, end = begin + p->block_size;
if (end > p->end)
end = p->end;
p->f(blocked_range<Int>(begin, end));
};
if constexpr (std::is_trivially_copyable<BaseFunc>::value && std::is_trivially_destructible<BaseFunc>::value) {
Payload payload{std::forward<Func>(func), range.begin(), range.end(), range.block_size()};
return task_submit_dep(
nullptr, // default pool
parents,
(uint32_t)parent_count,
range.blocks(),
callback,
&payload,
sizeof(Payload),
nullptr,
1
);
} else {
Payload* payload = new Payload{std::forward<Func>(func), range.begin(), range.end(), range.block_size()};
auto deleter = [](void* payload)
{
delete (Payload*)payload;
};
return task_submit_dep(
nullptr, // default pool
parents,
(uint32_t)parent_count,
range.blocks(),
callback,
payload,
0,
deleter,
1
);
}
}
/// Run a parallel for-loop asynchronously in a new task.
/// See nanothread documentation on `task_submit_dep` for details.
/// \param range Loop range.
/// \param func Function to execute (taking a `blocked_range<Int>` as an argument).
/// \param parents Parent tasks to wait for before executing.
/// \return The new task.
template<typename Int, typename Func>
[[nodiscard]] TaskHandle
parallel_for_async(const blocked_range<Int>& range, Func&& func, std::initializer_list<TaskHandle> parents = {})
{
return parallel_for_async(range, func, parents.begin(), parents.size());
}
/// Helper class for managing a group of tasks.
class SGL_API TaskGroup {
public:
TaskGroup() = default;
~TaskGroup()
{
std::lock_guard lock(m_mutex);
SGL_CHECK(
m_tasks.empty(),
"Cannot destroy task group with tasks potentially still running. Call wait() before the destructor."
);
}
/// Run a function asynchronously in a new task.
/// Adds the created task to this task group.
template<typename Func>
TaskHandle do_async(Func&& func, TaskHandle* parents, size_t parent_count)
{
TaskHandle task = thread::do_async(std::forward<Func>(func), parents, parent_count);
add_task(task);
return task;
}
/// Run a function asynchronously in a new task.
/// Adds the created task to this task group.
template<typename Func>
TaskHandle do_async(Func&& func, std::initializer_list<TaskHandle> parents = {})
{
TaskHandle task = thread::do_async(std::forward<Func>(func), parents);
add_task(task);
return task;
}
/// Add a task to this task group.
void add_task(TaskHandle task)
{
std::lock_guard lock(m_mutex);
m_tasks.push_back(task);
}
/// Wait for all tasks in this task group.
void wait()
{
std::vector<TaskHandle> tasks;
{
std::lock_guard lock(m_mutex);
std::swap(tasks, m_tasks);
}
for (TaskHandle task : tasks) {
task_wait_and_release(task);
}
}
SGL_NON_COPYABLE_AND_MOVABLE(TaskGroup);
private:
std::mutex m_mutex;
std::vector<TaskHandle> m_tasks;
};
/// Get the global task group.
/// This task group should mostly be used for fire-and-forget tasks without dependencies.
/// All tasks submitted to this group will be waited for on program shutdown.
SGL_API TaskGroup& global_task_group();
/// Wait for all tasks in the global task group.
SGL_API void wait_for_tasks();
} // namespace sgl::thread

@@ -66,3 +66,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

private:
enum class TextureDataType {
enum class TextureDataKind {
float_,

@@ -79,4 +79,7 @@ int_,

TextureLayout src_layout;
TextureDataType src_type;
TextureDataType dst_type;
TextureDataKind src_kind;
uint32_t src_channel_count;
Format dst_format;
TextureDataKind dst_kind;
uint32_t dst_channel_count;

@@ -86,6 +89,7 @@ auto operator<=>(const ProgramKey&) const = default;

std::string generate_defines(const ProgramKey& key);
ref<ShaderProgram> get_render_program(ProgramKey key);
ref<RenderPipeline> get_render_pipeline(ProgramKey key, Format dst_format);
ref<ShaderProgram> get_compute_program(ProgramKey key, Format dst_format);
ref<ComputePipeline> get_compute_pipeline(ProgramKey key, Format dst_format);
ref<RenderPipeline> get_render_pipeline(ProgramKey key);
ref<ShaderProgram> get_compute_program(ProgramKey key);
ref<ComputePipeline> get_compute_pipeline(ProgramKey key);

@@ -97,8 +101,8 @@ Device* m_device;

std::map<ProgramKey, ref<ShaderProgram>> m_render_program_cache;
std::map<std::pair<ProgramKey, Format>, ref<RenderPipeline>> m_render_pipeline_cache;
std::map<ProgramKey, ref<RenderPipeline>> m_render_pipeline_cache;
std::map<std::pair<ProgramKey, Format>, ref<ShaderProgram>> m_compute_program_cache;
std::map<std::pair<ProgramKey, Format>, ref<ComputePipeline>> m_compute_pipeline_cache;
std::map<ProgramKey, ref<ShaderProgram>> m_compute_program_cache;
std::map<ProgramKey, ref<ComputePipeline>> m_compute_pipeline_cache;
};
} // namespace sgl

@@ -89,2 +89,9 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

struct BindlessDesc {
uint32_t buffer_count{1024};
uint32_t texture_count{1024};
uint32_t sampler_count{128};
uint32_t acceleration_structure_count{128};
};
struct DeviceDesc {

@@ -116,2 +123,4 @@ /// The type of the device.

BindlessDesc bindless_options;
/// Path to the shader cache directory (optional).

@@ -183,2 +192,5 @@ /// If a relative path is used, the cache is stored in the application data directory.

uint64_t timestamp_frequency;
/// The version of OptiX used by the device (0 if OptiX is not supported).
/// The format matches the OPTIX_VERSION macro, e.g. 90000 for version 9.0.0.
uint32_t optix_version;
/// Limits of the device.

@@ -237,2 +249,8 @@ DeviceLimits limits;

/// List of slang capabilities supported by the device.
const std::vector<std::string>& capabilities() const { return m_capabilities; }
/// Check if the device supports a given capability.
bool has_capability(std::string_view capability) const;
/// True if the device supports CUDA interoperability.

@@ -665,2 +683,4 @@ bool supports_cuda_interop() const { return m_supports_cuda_interop; }

const std::vector<SlangCapabilityID>& _slang_capabilities() const { return m_slang_capabilities; }
Blitter* _blitter();

@@ -697,2 +717,4 @@ HotReload* _hot_reload() { return m_hot_reload; }

std::vector<Feature> m_features;
std::vector<std::string> m_capabilities;
std::vector<SlangCapabilityID> m_slang_capabilities;

@@ -699,0 +721,0 @@ ref<Fence> m_global_fence;

@@ -112,6 +112,74 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

struct AccelerationStructureBuildInputSpheres {
uint32_t vertex_count{0};
static_vector<BufferOffsetPair, MAX_ACCELERATION_STRUCTURE_MOTION_KEY_COUNT> vertex_position_buffers;
Format vertex_position_format{Format::undefined};
uint32_t vertex_position_stride{0};
static_vector<BufferOffsetPair, MAX_ACCELERATION_STRUCTURE_MOTION_KEY_COUNT> vertex_radius_buffers;
Format vertex_radius_format{Format::undefined};
uint32_t vertex_radius_stride{0};
BufferOffsetPair index_buffer;
IndexFormat index_format{IndexFormat::uint32};
uint32_t index_count{0};
AccelerationStructureGeometryFlags flags{AccelerationStructureGeometryFlags::none};
};
enum class LinearSweptSpheresIndexingMode {
list = static_cast<uint32_t>(rhi::LinearSweptSpheresIndexingMode::List),
successive = static_cast<uint32_t>(rhi::LinearSweptSpheresIndexingMode::Successive),
};
SGL_ENUM_INFO(
LinearSweptSpheresIndexingMode,
{
{LinearSweptSpheresIndexingMode::list, "list"},
{LinearSweptSpheresIndexingMode::successive, "successive"},
}
);
SGL_ENUM_REGISTER(LinearSweptSpheresIndexingMode);
enum class LinearSweptSpheresEndCapsMode {
none = static_cast<uint32_t>(rhi::LinearSweptSpheresEndCapsMode::None),
chained = static_cast<uint32_t>(rhi::LinearSweptSpheresEndCapsMode::Chained),
};
SGL_ENUM_INFO(
LinearSweptSpheresEndCapsMode,
{
{LinearSweptSpheresEndCapsMode::none, "none"},
{LinearSweptSpheresEndCapsMode::chained, "chained"},
}
);
SGL_ENUM_REGISTER(LinearSweptSpheresEndCapsMode);
struct AccelerationStructureBuildInputLinearSweptSpheres {
uint32_t vertex_count{0};
uint32_t primitive_count{0};
static_vector<BufferOffsetPair, MAX_ACCELERATION_STRUCTURE_MOTION_KEY_COUNT> vertex_position_buffers;
Format vertex_position_format{Format::undefined};
uint32_t vertex_position_stride{0};
static_vector<BufferOffsetPair, MAX_ACCELERATION_STRUCTURE_MOTION_KEY_COUNT> vertex_radius_buffers;
Format vertex_radius_format{Format::undefined};
uint32_t vertex_radius_stride{0};
BufferOffsetPair index_buffer;
IndexFormat index_format{IndexFormat::uint32};
uint32_t index_count{0};
LinearSweptSpheresIndexingMode indexing_mode{LinearSweptSpheresIndexingMode::list};
LinearSweptSpheresEndCapsMode end_caps_mode{LinearSweptSpheresEndCapsMode::none};
AccelerationStructureGeometryFlags flags{AccelerationStructureGeometryFlags::none};
};
using AccelerationStructureBuildInput = std::variant<
AccelerationStructureBuildInputInstances,
AccelerationStructureBuildInputTriangles,
AccelerationStructureBuildInputProceduralPrimitives>;
AccelerationStructureBuildInputProceduralPrimitives,
AccelerationStructureBuildInputSpheres,
AccelerationStructureBuildInputLinearSweptSpheres>;

@@ -118,0 +186,0 @@ struct AccelerationStructureBuildInputMotionOptions {

@@ -8,3 +8,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#define SGL_VERSION_MAJOR 0
#define SGL_VERSION_MINOR 37
#define SGL_VERSION_MINOR 38
#define SGL_VERSION_PATCH 0

@@ -11,0 +11,0 @@

@@ -27,2 +27,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

/// The main screen widget.
ref<Screen> screen() const { return m_screen; }

@@ -32,11 +33,28 @@

void new_frame(uint32_t width, uint32_t height);
void render(TextureView* texture_view, CommandEncoder* command_encoder);
void render(Texture* texture, CommandEncoder* command_encoder);
/// Begin a new ImGui frame and renders the main screen widget.
/// ImGui widget calls are generally only valid between `begin_frame` and `end_frame`.
/// \param width Render texture width
/// \param height Render texture height
void begin_frame(uint32_t width, uint32_t height);
/// End the ImGui frame and renders the UI to the provided texture.
/// \param texture_view Texture view to render to
/// \param command_encoder Command encoder to encode commands to
void end_frame(TextureView* texture_view, CommandEncoder* command_encoder);
/// End the ImGui frame and renders the UI to the provided texture.
/// \param texture Texture to render to
/// \param command_encoder Command encoder to encode commands to
void end_frame(Texture* texture, CommandEncoder* command_encoder);
/// Pass a keyboard event to the UI context.
/// \param event Keyboard event
/// \return Returns true if event was consumed.
bool handle_keyboard_event(const KeyboardEvent& event);
/// Pass a mouse event to the UI context.
/// \param event Mouse event
/// \return Returns true if event was consumed.
bool handle_mouse_event(const MouseEvent& event);
void process_events();
private:

@@ -43,0 +61,0 @@ RenderPipeline* get_pipeline(Format format);

@@ -20,6 +20,2 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

struct Event {
Widget* sender;
};
/// Base class for Python UI widgets.

@@ -112,10 +108,2 @@ /// Widgets own their children.

virtual void record_event(const Event& event)
{
if (m_parent)
m_parent->record_event(event);
}
virtual void dispatch_event(const Event& event) { SGL_UNUSED(event); }
protected:

@@ -139,14 +127,2 @@ Widget* m_parent;

virtual void render() override { Widget::render(); }
virtual void record_event(const Event& event) override { m_events.push_back(event); }
void dispatch_events()
{
for (const auto& event : m_events)
event.sender->dispatch_event(event);
m_events.clear();
}
private:
std::vector<Event> m_events;
};

@@ -360,2 +336,8 @@

void notify()
{
if (m_callback)
m_callback();
}
virtual void render() override

@@ -369,12 +351,5 @@ {

if (ImGui::Button(m_label.c_str()))
record_event({this});
notify();
}
virtual void dispatch_event(const Event& event) override
{
SGL_ASSERT(event.sender == this);
if (m_callback)
m_callback();
}
private:

@@ -408,5 +383,4 @@ std::string m_label;

virtual void dispatch_event(const Event& event) override
void notify()
{
SGL_ASSERT(event.sender == this);
if (m_callback)

@@ -440,3 +414,3 @@ m_callback(m_value);

if (ImGui::Checkbox(m_label.c_str(), &m_value))
record_event({this});
notify();
}

@@ -486,3 +460,3 @@ };

)) {
record_event({this});
notify();
}

@@ -530,3 +504,6 @@ }

&m_value,
[](void* user_data, int idx) { return static_cast<const ListBox*>(user_data)->m_items[idx].c_str(); },
[](void* user_data, int idx)
{
return static_cast<const ListBox*>(user_data)->m_items[idx].c_str();
},
this,

@@ -536,3 +513,3 @@ int(m_items.size()),

)) {
record_event({this});
notify();
}

@@ -587,3 +564,2 @@ }

using Widget::record_event;
using Widget::m_enabled;

@@ -593,2 +569,3 @@ using Widget::m_visible;

using Base::m_value;
using Base::notify;

@@ -653,3 +630,3 @@ using scalar_type = typename VectorTraits<T>::scalar_type;

if (changed)
record_event({this});
notify();
}

@@ -682,3 +659,2 @@

using Widget::record_event;
using Widget::m_enabled;

@@ -688,2 +664,3 @@ using Widget::m_visible;

using Base::m_value;
using Base::notify;

@@ -742,3 +719,3 @@ using scalar_type = typename VectorTraits<T>::scalar_type;

if (changed)
record_event({this});
notify();
}

@@ -795,3 +772,2 @@

using Widget::record_event;
using Widget::m_enabled;

@@ -801,2 +777,3 @@ using Widget::m_visible;

using Base::m_value;
using Base::notify;

@@ -855,3 +832,3 @@ using scalar_type = typename VectorTraits<T>::scalar_type;

if (changed)
record_event({this});
notify();
}

@@ -929,3 +906,3 @@

if (changed)
record_event({this});
notify();
}

@@ -932,0 +909,0 @@

#pragma once
#define SLANG_RHI_SHARED 0
#define SLANG_RHI_ENABLE_CPU 1

@@ -14,1 +15,2 @@ #define SLANG_RHI_ENABLE_D3D11 0

#define SLANG_RHI_ENABLE_WGPU 0
#define SLANG_RHI_OPTIX_VERSIONS_X(x) x(v9_0) x(v8_1) x(v8_0)

@@ -793,2 +793,18 @@ from collections.abc import Mapping, Sequence

class NativeDescriptorMarshall(NativeMarshall):
def __init__(self, slang_type: NativeSlangType, type: slangpy.DescriptorHandleType) -> None:
"""N/A"""
def write_shader_cursor_pre_dispatch(self, context: CallContext, binding: NativeBoundVariableRuntime, cursor: slangpy.ShaderCursor, value: object, read_back: list) -> None:
"""N/A"""
def get_shape(self, value: object) -> Shape:
"""N/A"""
@property
def type(self) -> slangpy.DescriptorHandleType: ...
@property
def slang_type(self) -> NativeSlangType: ...
class NativeTextureMarshall(NativeMarshall):

@@ -795,0 +811,0 @@ def __init__(self, slang_type: NativeSlangType, element_type: NativeSlangType, resource_shape: slangpy.TypeReflection.ResourceShape, format: slangpy.Format, usage: slangpy.TextureUsage, dims: int) -> None:

@@ -16,6 +16,2 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

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."
)

@@ -22,0 +18,0 @@ device = helpers.get_device(device_type)

@@ -29,3 +29,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

int getval() {
IVal val;
IVal val = createDynamicObject<IVal>(0, 0);
return val.get();

@@ -32,0 +32,0 @@ }

@@ -85,2 +85,4 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

FormatEntry(PixelFormat.rgb, ComponentType.uint8, Format.rgba8_unorm_srgb, Flags.load_as_srgb | Flags.extend_alpha),
# ya handling
FormatEntry(PixelFormat.ya, ComponentType.int8, Format.rgba8_sint, Flags.none),
]

@@ -208,2 +210,13 @@ # fmt: on

if format.pixel_format == PixelFormat.ya:
image = np.concatenate(
(
image[:, :, :1], # y
image[:, :, :1], # y
image[:, :, :1], # y
image[:, :, 1:], # a
),
axis=2,
)
# Load the bitmap as a texture

@@ -279,2 +292,5 @@ loader = TextureLoader(device)

loader = TextureLoader(device)
paths = [TEST_IMAGE_DIR / f for f in TEST_BITMAP_FILES]
textures = loader.load_textures(paths)
assert len(textures) == 2

@@ -287,2 +303,5 @@

loader = TextureLoader(device)
paths = [TEST_IMAGE_DIR / f for f in TEST_BITMAP_FILES]
texture = loader.load_texture_array(paths)
assert texture.array_length == 2

@@ -289,0 +308,0 @@

@@ -360,3 +360,3 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

shape=ndarray.shape,
usage=BufferUsage.shader_resource | BufferUsage.unordered_access,
usage=usage,
memory_type=memory_type,

@@ -363,0 +363,0 @@ )

@@ -14,9 +14,11 @@ from collections.abc import Callable, Iterator, Sequence

def new_frame(self, width: int, height: int) -> None: ...
def begin_frame(self, width: int, height: int) -> None:
"""N/A"""
@overload
def render(self, texture_view: slangpy.TextureView, command_encoder: slangpy.CommandEncoder) -> None: ...
def end_frame(self, texture_view: slangpy.TextureView, command_encoder: slangpy.CommandEncoder) -> None:
"""N/A"""
@overload
def render(self, texture: slangpy.Texture, command_encoder: slangpy.CommandEncoder) -> None: ...
def end_frame(self, texture: slangpy.Texture, command_encoder: slangpy.CommandEncoder) -> None: ...

@@ -27,4 +29,2 @@ def handle_keyboard_event(self, event: slangpy.KeyboardEvent) -> bool: ...

def process_events(self) -> None: ...
@property

@@ -76,3 +76,3 @@ def screen(self) -> Screen: ...

class Screen(Widget):
def dispatch_events(self) -> None: ...
pass

@@ -79,0 +79,0 @@ class Window(Widget):

// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#pragma once
#include "sgl/math/vector.h"
#include <limits>
namespace sgl {
/**
* Ray type.
* This should match the layout of DXR RayDesc.
*/
struct Ray {
float3 origin;
float t_min;
float3 dir;
float t_max;
/// Default constructor (uninitialized).
Ray() = default;
/// Constructor.
explicit Ray(float3 origin_, float3 dir_, float t_min_ = 0.f, float t_max_ = std::numeric_limits<float>::max())
: origin(origin_)
, t_min(t_min_)
, dir(dir_)
, t_max(t_max_)
{
}
/// Evaluate position on the ray at t.
[[nodiscard]] float3 eval(float t) const { return origin + t * dir; }
/// Evaluate position on the ray at t.
[[nodiscard]] float3 operator()(float t) const { return eval(t); }
};
// These are to ensure that the struct Ray match DXR RayDesc.
static_assert(offsetof(Ray, origin) == 0);
static_assert(offsetof(Ray, t_min) == sizeof(float3));
static_assert(offsetof(Ray, dir) == offsetof(Ray, t_min) + sizeof(float));
static_assert(offsetof(Ray, t_max) == offsetof(Ray, dir) + sizeof(float3));
static_assert(sizeof(Ray) == 32);
} // namespace sgl

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 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 not supported yet

Sorry, the diff of this file is too big to display