Skip to content

Commit 053f540

Browse files
committedOct 5, 2024
Overhaul docgen tool and setup CI to generate stdlib reference.
1 parent 82c05f4 commit 053f540

22 files changed

+2134
-639
lines changed
 

‎.github/workflows/release.yml

+18
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,21 @@ jobs:
194194
${{ steps.notarize.outputs.SLANG_NOTARIZED_DIST }}
195195
env:
196196
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197+
198+
- name: Checkout stdlib reference
199+
if: matrix.os == 'windows' && matrix.platform == 'x86_64'
200+
uses: actions/checkout@v3
201+
with:
202+
repository: shader-slang/stdlib-reference
203+
path: docs/stdlib-reference/
204+
token: ${{ secrets.UPDATE_STDLIB_REFERENCE_PAT }}
205+
- name: Update stdlib reference
206+
if: matrix.os == 'windows' && matrix.platform == 'x86_64'
207+
shell: powershell
208+
run: |
209+
cd docs/
210+
ls
211+
& ".\build_reference.ps1"
212+
env:
213+
GITHUB_TOKEN: ${{ secrets.UPDATE_STDLIB_REFERENCE_PAT }}
214+

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ prelude/*.h.cpp
6767
/docs/_site
6868
/docs/Gemfile.lock
6969
/docs/Gemfile
70+
/docs/stdlib-reference
7071
/source/slang/slang-stdlib-generated.h
7172

7273
/examples/heterogeneous-hello-world/shader.cpp

‎docs/build_reference.ps1

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# If stdlib-reference folder does not exist, clone from github repo
2+
if (-not (Test-Path ".\stdlib-reference")) {
3+
git clone https://github.com/shader-slang/stdlib-reference/
4+
}
5+
else {
6+
cd stdlib-reference
7+
git pull
8+
cd ../
9+
}
10+
Remove-Item -Path ".\stdlib-reference\global-decls" -Recurse -Force
11+
Remove-Item -Path ".\stdlib-reference\interfaces" -Recurse -Force
12+
Remove-Item -Path ".\stdlib-reference\types" -Recurse -Force
13+
14+
cd stdlib-reference
15+
& ../../build/Release/bin/slangc -compile-stdlib -doc
16+
Move-Item -Path ".\toc.html" -Destination ".\_includes\stdlib-reference-toc.html" -Force
17+
git config user.email "bot@shader-slang.com"
18+
git config user.name "Stdlib Reference Bot"
19+
git add .
20+
git commit -m "Update stdlib reference"
21+
git push
22+
cd ../
23+

‎source/slang/core.meta.slang

+49-9
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ interface IRWArray<T> : IArray<T>
446446
// argument. The left-to-right evaluation order guaranteed by Slang then ensures that
447447
// `left` is evaluated before `right`.
448448
//
449+
//@hidden:
449450
__generic<T,U>
450451
[__unsafeForceInlineEarly]
451452
U operator,(T left, U right)
@@ -457,20 +458,29 @@ U operator,(T left, U right)
457458
// follow that definition for the scalar condition overload, so this declaration just serves
458459
// for type-checking purpose only.
459460

460-
__generic<T> __intrinsic_op(select) T operator?:(bool condition, T ifTrue, T ifFalse);
461+
//@hidden:
462+
__generic<T> __intrinsic_op(select) T operator?: (bool condition, T ifTrue, T ifFalse);
463+
464+
//@hidden:
461465
__generic<T, let N : int> __intrinsic_op(select) vector<T,N> operator?:(vector<bool,N> condition, vector<T,N> ifTrue, vector<T,N> ifFalse);
462466

463467
// Users are advised to use `select` instead if non-short-circuiting behavior is intended.
468+
//@public:
464469
__generic<T> __intrinsic_op(select) T select(bool condition, T ifTrue, T ifFalse);
465470
__generic<T, let N : int> __intrinsic_op(select) vector<T,N> select(vector<bool,N> condition, vector<T,N> ifTrue, vector<T,N> ifFalse);
466471

467472
// Allow real-number types to be cast into each other
473+
//@hidden:
468474
__intrinsic_op($(kIROp_FloatCast))
469475
T __realCast<T : __BuiltinRealType, U : __BuiltinRealType>(U val);
476+
//@hidden:
470477
__intrinsic_op($(kIROp_CastIntToFloat))
471-
T __realCast<T : __BuiltinRealType, U : __BuiltinIntegerType>(U val);
478+
T __realCast<T : __BuiltinRealType, U : __BuiltinIntegerType>(U val);
479+
//@hidden:
472480
__intrinsic_op($(kIROp_IntCast))
473-
T __intCast<T : __BuiltinType, U : __BuiltinType>(U val);
481+
T __intCast<T : __BuiltinType, U : __BuiltinType>(U val);
482+
483+
//@hidden:
474484
${{{{
475485
// We are going to use code generation to produce the
476486
// declarations for all of our base types.
@@ -716,17 +726,20 @@ ${{{{
716726
// (eventually we can have the traditional syntax sugar for this)
717727
}}}}
718728

729+
//@hidden:
719730
__magic_type(NullPtrType)
720731
struct NullPtr
721732
{
722733
};
723734

735+
//@hidden:
724736
__magic_type(NoneType)
725737
__intrinsic_type($(kIROp_VoidType))
726738
struct __none_t
727739
{
728740
};
729741

742+
//@public:
730743
__generic<T, let addrSpace : uint64_t = $( (uint64_t)AddressSpace::UserPointer)ULL>
731744
__magic_type(PtrType)
732745
__intrinsic_type($(kIROp_PtrType))
@@ -752,6 +765,7 @@ struct Ptr
752765
}
753766
};
754767

768+
//@hidden:
755769
__intrinsic_op($(kIROp_Load))
756770
T __load<T, let addrSpace : uint64_t>(Ptr<T, addrSpace> ptr);
757771

@@ -788,6 +802,7 @@ __generic<T, let addrSpace : uint64_t>
788802
__intrinsic_op($(kIROp_Eql))
789803
bool operator ==(Ptr<T, addrSpace> p1, Ptr<T, addrSpace> p2);
790804

805+
//@public:
791806
extension bool : IRangedValue
792807
{
793808
__generic<T, let addrSpace : uint64_t>
@@ -847,6 +862,7 @@ extension uintptr_t : IRangedValue
847862
static const int size = $(SLANG_PROCESSOR_X86_64?"8":"4");
848863
}
849864

865+
//@hidden:
850866
__generic<T>
851867
__magic_type(OutType)
852868
__intrinsic_type($(kIROp_OutType))
@@ -873,6 +889,7 @@ struct ConstRef
873889

874890
typealias __Addr<T> = Ptr<T, $( (uint64_t)AddressSpace::Generic)ULL>;
875891

892+
//@public:
876893
__generic<T>
877894
__magic_type(OptionalType)
878895
__intrinsic_type($(kIROp_OptionalType))
@@ -895,6 +912,7 @@ struct Optional
895912
__init(T val);
896913
};
897914

915+
//@hidden:
898916
__generic<T>
899917
[__unsafeForceInlineEarly]
900918
bool operator==(Optional<T> val, __none_t noneVal)
@@ -920,6 +938,7 @@ bool operator!=(__none_t noneVal, Optional<T> val)
920938
return val.hasValue;
921939
}
922940

941+
//@public:
923942
__generic<each T>
924943
__magic_type(TupleType)
925944
struct Tuple
@@ -936,7 +955,7 @@ Tuple<T, U> concat<each T, each U>(Tuple<T> t, Tuple<U> u)
936955
return makeTuple(expand each t, expand each u);
937956
}
938957

939-
958+
//@hidden:
940959
[__unsafeForceInlineEarly]
941960
bool __assign(inout bool v, bool newVal)
942961
{
@@ -978,6 +997,7 @@ void __tupleGreaterKernel<T : IComparable>(inout bool result, inout bool exit, T
978997
}
979998
}
980999

1000+
//@public:
9811001
__generic<each T : IComparable>
9821002
extension Tuple<T> : IComparable
9831003
{
@@ -1027,6 +1047,7 @@ interface IDifferentiableFunc<TR : IDifferentiable, each TP : IDifferentiable> :
10271047
TR operator()(expand each TP p);
10281048
}
10291049

1050+
//@hidden:
10301051
__generic<T>
10311052
__magic_type(NativeRefType)
10321053
__intrinsic_type($(kIROp_NativePtrType))
@@ -1049,6 +1070,7 @@ T __attachToNativeRef(NativeRef<T> nativeVal)
10491070
return result;
10501071
}
10511072

1073+
//@public:
10521074
__magic_type(StringType)
10531075
__intrinsic_type($(kIROp_StringType))
10541076
struct String
@@ -1133,11 +1155,14 @@ extension Ptr<void>
11331155
__init(NativeRef<T> ptr);
11341156
}
11351157

1158+
//@hidden:
11361159
__magic_type(DynamicType)
11371160
__intrinsic_type($(kIROp_DynamicType))
11381161
struct __Dynamic
11391162
{};
11401163

1164+
//@public:
1165+
11411166
extension half : IRangedValue
11421167
{
11431168
static const half maxValue = half(65504);
@@ -1225,9 +1250,11 @@ struct vector : IRWArray<T>
12251250
int getCount() { return N; }
12261251
}
12271252

1228-
const int kRowMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_ROW_MAJOR);
1229-
const int kColumnMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_COLUMN_MAJOR);
1253+
//@hidden:
1254+
static const int kRowMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_ROW_MAJOR);
1255+
static const int kColumnMajorMatrixLayout = $(SLANG_MATRIX_LAYOUT_COLUMN_MAJOR);
12301256

1257+
//@public:
12311258
/// A matrix with `R` rows and `C` columns, with elements of type `T`.
12321259
__generic<T = float, let R : int = 4, let C : int = 4, let L : int = $(SLANG_MATRIX_LAYOUT_MODE_UNKNOWN)>
12331260
__magic_type(MatrixExpressionType)
@@ -1248,9 +1275,11 @@ struct matrix : IRWArray<vector<T,C>>
12481275
int getCount() { return R; }
12491276
}
12501277

1278+
//@hidden:
12511279
__intrinsic_op($(kIROp_Eql))
1252-
vector<bool, N> __vectorEql<T, let N:int>(vector<T, N> left, vector<T,N> right);
1280+
vector<bool, N> __vectorEql<T, let N : int>(vector<T, N> left, vector<T, N> right);
12531281

1282+
//@public:
12541283
__generic<T:__BuiltinFloatingPointType, let N : int>
12551284
extension vector<T,N> : IFloat
12561285
{
@@ -1360,10 +1389,12 @@ extension matrix<int16_t,R,C,L>
13601389
__init(int value) { this = matrix<T,R,C,L>(T(value)); }
13611390
}
13621391

1392+
//@hidden:
13631393
__intrinsic_op(makeVector)
13641394
__generic<T, let N:int>
13651395
vector<T,N*2> __makeVector(vector<T,N> vec1, vector<T,N> vec2);
13661396

1397+
//@public:
13671398
__generic<T>
13681399
extension vector<T, 4>
13691400
{
@@ -1385,6 +1416,7 @@ extension matrix<T, 2, 2, L>
13851416
}
13861417
}
13871418

1419+
//@hidden:
13881420
${{{{
13891421
static const struct {
13901422
char const* name;
@@ -1573,7 +1605,7 @@ struct OutputPrimitives
15731605
}
15741606
};
15751607

1576-
//@ hidden:
1608+
//@ public:
15771609

15781610
// Need to add constructors to the types above
15791611

@@ -1757,6 +1789,7 @@ ${{{{
17571789
}
17581790
}}}}
17591791

1792+
//@ hidden:
17601793
__generic<T, U>
17611794
__intrinsic_op(0)
17621795
T __slang_noop_cast(U u);
@@ -2267,6 +2300,8 @@ int __SyntaxError()
22672300
}
22682301
}
22692302

2303+
//@ hidden:
2304+
22702305
/// For downstream compilers that allow sizeof/alignof/offsetof
22712306
/// Can't be called in the C/C++ style. Need to use __size_of<some_type>() as opposed to sizeof(some_type).
22722307
__generic<T>
@@ -2350,7 +2385,7 @@ __generic<E : __EnumType>
23502385
__intrinsic_op($(kIROp_Neq))
23512386
bool operator!=(E left, E right);
23522387

2353-
//@ public:
2388+
//@ hidden:
23542389

23552390
// public interfaces for generic arithmetic types.
23562391

@@ -2722,6 +2757,7 @@ __Addr<T> __getLegalizedSPIRVGlobalParamAddr(T val);
27222757
__intrinsic_op($(kIROp_RequireComputeDerivative))
27232758
void __requireComputeDerivative();
27242759

2760+
//@ public:
27252761
// Atomic<T>
27262762

27272763
enum MemoryOrder
@@ -2767,6 +2803,7 @@ struct Atomic<T : IAtomicable>
27672803
MemoryOrder failOrder = MemoryOrder.Relaxed);
27682804
}
27692805

2806+
/// These addtional members are only available when `T` conforms to `IArithmeticAtomicable`.
27702807
extension<T : IArithmeticAtomicable> Atomic<T>
27712808
{
27722809
__intrinsic_op($(kIROp_AtomicAdd))
@@ -2779,6 +2816,7 @@ extension<T : IArithmeticAtomicable> Atomic<T>
27792816
[__ref] T min(T value, MemoryOrder order = MemoryOrder.Relaxed); // returns original value
27802817
}
27812818

2819+
/// These addtional members are only available when `T` conforms to `IBitAtomicable`.
27822820
extension<T : IBitAtomicable> Atomic<T>
27832821
{
27842822
__intrinsic_op($(kIROp_AtomicAnd))
@@ -2793,6 +2831,8 @@ extension<T : IBitAtomicable> Atomic<T>
27932831
[__ref] T decrement(MemoryOrder order = MemoryOrder.Relaxed);
27942832
}
27952833

2834+
//@ hidden:
2835+
27962836
__generic<T : IArithmeticAtomicable>
27972837
[ForceInline]
27982838
T operator +=(__ref Atomic<T> v, T value)

0 commit comments

Comments
 (0)