From 27c6e9b01f7386263bde90e16812be46327015c2 Mon Sep 17 00:00:00 2001 From: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Date: Wed, 21 May 2025 21:11:01 -0700 Subject: Initial `dyn` keyword support & `-lang 2026` compiler option (#7172) fixes: [#7143](https://github.com/shader-slang/slang/issues/7143) fixes: [#7146](https://github.com/shader-slang/slang/issues/7146) Goal of PR: * This PR is part of the larger #7115 refactor to how dynamic dispatch works. * The first step is to add the `-std ` flag. * The second step is to provide basic `dyn` keyword support in AST. This does not include `varDecl` support since most of these interactions require `some` keyword support. Future PR(s) goal: * Support `some` keyword in AST. With this we will also implement all varDecl interactions between `dyn` and `some`. * Add IR support for `some` and `dyn`. Breakdown of PR: * most of the logic is in `validateDyn.*`. This was done so that in the future when we implement more features we will have an easy time removing/adding restrictions to `dyn` interfaces. Breaking changes: * As per spec (https://github.com/shader-slang/spec/pull/14/files), any type conforming to a `dyn` interface errors if member list contains one of the following: opaque type, non copyable type, or unsized type. * Due to the breaking change, the test `tests\compute\dynamic-dispatch-bindless-texture.slang` is incorrect. This has been fixed. --- .../dynamic-dispatch-bindless-texture.slang | 36 +++++++++------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'tests/compute/dynamic-dispatch-bindless-texture.slang') diff --git a/tests/compute/dynamic-dispatch-bindless-texture.slang b/tests/compute/dynamic-dispatch-bindless-texture.slang index b02ca9686..ec21afeda 100644 --- a/tests/compute/dynamic-dispatch-bindless-texture.slang +++ b/tests/compute/dynamic-dispatch-bindless-texture.slang @@ -2,37 +2,29 @@ //TEST(compute):COMPARE_COMPUTE:-cpu //TEST(compute):COMPARE_COMPUTE:-cuda -[anyValueSize(16)] -interface IInterface +// Type must be marked `public` to ensure it is visible in the generated DLL. + +export struct MyImpl { - float run(); -} + Texture2D tex; + float run() + { + return tex.Load({0, 0, 0}).x; + } +}; //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=gOutputBuffer RWStructuredBuffer gOutputBuffer; -//TEST_INPUT: set gCb = new StructuredBuffer{new MyImpl{Texture2D(size=8, content = one), Sampler}} -StructuredBuffer gCb; +//TEST_INPUT: set gCb = new StructuredBuffer{new MyImpl{Texture2D(size=8, content = one)}} +StructuredBuffer gCb; [numthreads(4, 1, 1)] -void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) +void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) { let tid = dispatchThreadID.x; let inputVal : int = tid; - IInterface v0 = gCb.Load(0); - SamplerState sampler; + MyImpl v0 = gCb.Load(0); let outputVal = v0.run(); gOutputBuffer[tid] = uint(trunc(outputVal)); -} - - -// Type must be marked `public` to ensure it is visible in the generated DLL. -export struct MyImpl : IInterface -{ - Texture2D tex; - SamplerState sampler; - float run() - { - return tex.Sample(sampler, float2(0.0, 0.0)).x; - } -}; +} \ No newline at end of file -- cgit v1.2.3