yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
90c34e3db
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type 2//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type 3 4// Test that we can disambiguiate subscript decls by prefering the candidate that contains a super set of 5// accessors than the other candidates. 6interface IBuf<T> 7{ 8 T read(int x); 9} 10interface IRWBuf<T> : IBuf<T> 11{ 12 [mutating] 13 void write(int x, T v); 14} 15 16#pragma warning(disable:30856) 17extension<T, U : IBuf<T>> U 18{ 19 __subscript(int x) -> T { get { return read(x); } } 20} 21 22extension<T, U : IRWBuf<T>> U 23{ 24 __subscript(int x)->T { get { return read(x); } set { write(x, newValue); } } 25} 26 27struct MyArray<T> : IRWBuf<T> 28{ 29 T data[4]; 30 T read(int x) { return data[x]; } 31 [mutating] 32 void write(int x, T v) { data[x] = v; } 33} 34 35 36//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 37RWStructuredBuffer<int> outputBuffer; 38 39[numthreads(1,1,1)] 40void computeMain() 41{ 42 MyArray<int> arr = {{1, 2, 3, 4}}; 43 arr[0] = 1; 44 arr[1] = 2; 45 // CHECK: 1 46 // CHECK: 2 47 outputBuffer[0] = arr[0]; 48 outputBuffer[1] = arr[1]; 49}