Skip to content

Commit 5be2f08

Browse files
authored
Merge branch 'master' into conform-integer-literals
2 parents a34827e + 2f42388 commit 5be2f08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+390
-184
lines changed

docs/scripts/Program.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ public static string getAnchorId(string title)
1111
{
1212
StringBuilder sb = new StringBuilder();
1313
title = title.Trim().ToLower();
14+
1415
foreach (var ch in title)
1516
{
1617
if (ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9'
17-
|| ch == '-')
18+
|| ch == '-'|| ch =='_')
1819
sb.Append(ch);
19-
else if (ch==' ' || ch =='_')
20+
else if (ch == ' ' )
2021
sb.Append('-');
2122
}
2223
return sb.ToString();

docs/user-guide/09-targets.md

+41
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,47 @@ Slang's CPU compute target supports only a compute pipeline.
412412

413413
Because CPU target support flexible pointer-based addressing and large low-latency caches, a compute kernel can simply be passed a small fixed number of pointers and be relied upon to load parameter values of any types via indirection through those pointers.
414414

415+
## WebGPU
416+
417+
> #### Note
418+
>
419+
> Slang support for WebGPU is work in progress.
420+
421+
WebGPU is a graphics and compute API.
422+
It is similar in spirit to modern APIs, like Metal, Direct3D 12 and Vulkan, but with concessions to portability and privacy.
423+
424+
WebGPU is available both in browsers as a JavaScript API, and natively as a C/C++ API.
425+
[Dawn](https://github.com/google/dawn), is a native WebGPU implementation used by the Chrome browser.
426+
427+
By combining Slang, [Dawn](https://github.com/google/dawn) and [Emscripten](https://emscripten.org/),
428+
an application can easily target any native API, and the web, with a single codebase consisting of C++ and Slang code.
429+
430+
WebGPU shader modules are created from WGSL (WebGPU Shading Language) source files.
431+
WebGPU does not use an intermediate representation - WGSL code is compiled to backend-specific code by
432+
compilers provided by the WebGPU implementation.
433+
434+
### Pipelines
435+
436+
WebGPU supports render and compute pipelines.
437+
438+
The WebGPU render pipeline includes the following programmable stages:
439+
440+
- The vertex stage outputs vertex data
441+
442+
- The fragment stage outputs fragments
443+
444+
### Parameter Passing
445+
446+
WebGPU uses groups of bindings called bind groups to bind things like textures, buffers and samplers.
447+
Bind group objects are passed as arguments when encoding bind group setting commands.
448+
449+
There is a notion of equivalence for bind groups, and a notion of equivalence for pipelines defined in
450+
terms of bind group equivalence.
451+
This equivalence allows an application to save some bind group setting commands, when switching between
452+
pipelines, if bindings are grouped together appropriately.
453+
454+
Which bindings are grouped together can be controlled using Slang's `ParameterBlock` generic type.
455+
415456
## Summary
416457

417458
This chapter has reviewed the main target platforms supported by the Slang compiler and runtime system.

docs/user-guide/toc.html

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<li data-link="convenience-features#subscript-operator"><span>Subscript Operator</span></li>
4343
<li data-link="convenience-features#tuple-types"><span>Tuple Types</span></li>
4444
<li data-link="convenience-features#optionalt-type"><span>`Optional&lt;T&gt;` type</span></li>
45-
<li data-link="convenience-features#if-let-syntax"><span>`if_let` syntax</span></li>
45+
<li data-link="convenience-features#if_let-syntax"><span>`if_let` syntax</span></li>
4646
<li data-link="convenience-features#reinterprett-operation"><span>`reinterpret&lt;T&gt;` operation</span></li>
4747
<li data-link="convenience-features#pointers-limited"><span>Pointers (limited)</span></li>
4848
<li data-link="convenience-features#extensions"><span>Extensions</span></li>
@@ -66,7 +66,7 @@
6666
<li data-link="capabilities#conflicting-capabilities"><span>Conflicting Capabilities</span></li>
6767
<li data-link="capabilities#requirements-in-parent-scope"><span>Requirements in Parent Scope</span></li>
6868
<li data-link="capabilities#inference-of-capability-requirements"><span>Inference of Capability Requirements</span></li>
69-
<li data-link="capabilities#inference-on-target-switch"><span>Inference on target_switch</span></li>
69+
<li data-link="capabilities#inference-on-target_switch"><span>Inference on target_switch</span></li>
7070
<li data-link="capabilities#capability-aliases"><span>Capability Aliases</span></li>
7171
<li data-link="capabilities#validation-of-capability-requirements"><span>Validation of Capability Requirements</span></li>
7272
</ul>
@@ -135,6 +135,7 @@
135135
<li data-link="targets#metal"><span>Metal</span></li>
136136
<li data-link="targets#cuda-and-optix"><span>CUDA and OptiX</span></li>
137137
<li data-link="targets#cpu-compute"><span>CPU Compute</span></li>
138+
<li data-link="targets#webgpu"><span>WebGPU</span></li>
138139
<li data-link="targets#summary"><span>Summary</span></li>
139140
</ul>
140141
</li>

include/slang-deprecated.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ extern "C"
101101
int targetIndex,
102102
bool val);
103103

104-
/*! @see slang::ICompileRequest::setIngoreCapabilityCheck */
104+
/*! @see slang::ICompileRequest::setIgnoreCapabilityCheck */
105105
SLANG_API void spSetIgnoreCapabilityCheck(slang::ICompileRequest* request, bool val);
106106

107107
/*! @see slang::ICompileRequest::setCodeGenTarget */
@@ -936,11 +936,11 @@ extern "C"
936936
/// Count should *NOT* include terminating zero.
937937
SLANG_API SlangUInt32 spComputeStringHash(const char* chars, size_t count);
938938

939-
/// Get a type layout representing reflection information for the global-scope prameters.
939+
/// Get a type layout representing reflection information for the global-scope parameters.
940940
SLANG_API SlangReflectionTypeLayout* spReflection_getGlobalParamsTypeLayout(
941941
SlangReflection* reflection);
942942

943-
/// Get a variable layout representing reflection information for the global-scope prameters.
943+
/// Get a variable layout representing reflection information for the global-scope parameters.
944944
SLANG_API SlangReflectionVariableLayout* spReflection_getGlobalParamsVarLayout(
945945
SlangReflection* reflection);
946946

@@ -1409,7 +1409,7 @@ struct ICompileRequest : public ISlangUnknown
14091409
virtual SLANG_NO_THROW void const* SLANG_MCALL getCompileRequestCode(size_t* outSize) = 0;
14101410

14111411
/** Get the compilation result as a file system.
1412-
The result is not written to the actual OS file system, but is made avaiable as an
1412+
The result is not written to the actual OS file system, but is made available as an
14131413
in memory representation.
14141414
*/
14151415
virtual SLANG_NO_THROW ISlangMutableFileSystem* SLANG_MCALL

include/slang.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ convention for interface methods.
305305
/// SLANG_INLINE exists to have a way to inline consistent with SLANG_ALWAYS_INLINE
306306
#define SLANG_INLINE inline
307307

308-
// If explicilty disabled and not set, set to not available
308+
// If explicitly disabled and not set, set to not available
309309
#if !defined(SLANG_HAS_EXCEPTIONS) && defined(SLANG_DISABLE_EXCEPTIONS)
310310
#define SLANG_HAS_EXCEPTIONS 0
311311
#endif
@@ -488,9 +488,9 @@ convention for interface methods.
488488
#define SLANG_UNALIGNED_ACCESS 0
489489
#endif
490490

491-
// One endianess must be set
491+
// One endianness must be set
492492
#if ((SLANG_BIG_ENDIAN | SLANG_LITTLE_ENDIAN) == 0)
493-
#error "Couldn't determine endianess"
493+
#error "Couldn't determine endianness"
494494
#endif
495495

496496
#ifndef SLANG_NO_INTTYPES
@@ -551,7 +551,7 @@ typedef uint32_t SlangSizeT;
551551
{
552552
SLANG_SEVERITY_DISABLED = 0, /**< A message that is disabled, filtered out. */
553553
SLANG_SEVERITY_NOTE, /**< An informative message. */
554-
SLANG_SEVERITY_WARNING, /**< A warning, which indicates a possible proble. */
554+
SLANG_SEVERITY_WARNING, /**< A warning, which indicates a possible problem. */
555555
SLANG_SEVERITY_ERROR, /**< An error, indicating that compilation failed. */
556556
SLANG_SEVERITY_FATAL, /**< An unrecoverable error, which forced compilation to abort. */
557557
SLANG_SEVERITY_INTERNAL, /**< An internal error, indicating a logic error in the compiler.
@@ -811,10 +811,10 @@ typedef uint32_t SlangSizeT;
811811
{
812812
SLANG_DEBUG_INFO_LEVEL_NONE = 0, /**< Don't emit debug information at all. */
813813
SLANG_DEBUG_INFO_LEVEL_MINIMAL, /**< Emit as little debug information as possible, while
814-
still supporting stack trackes. */
814+
still supporting stack trackers. */
815815
SLANG_DEBUG_INFO_LEVEL_STANDARD, /**< Emit whatever is the standard level of debug
816816
information for each target. */
817-
SLANG_DEBUG_INFO_LEVEL_MAXIMAL, /**< Emit as much debug infromation as possible for each
817+
SLANG_DEBUG_INFO_LEVEL_MAXIMAL, /**< Emit as much debug information as possible for each
818818
target. */
819819
};
820820

@@ -823,7 +823,7 @@ typedef uint32_t SlangSizeT;
823823
enum SlangDebugInfoFormat : SlangDebugInfoFormatIntegral
824824
{
825825
SLANG_DEBUG_INFO_FORMAT_DEFAULT, ///< Use the default debugging format for the target
826-
SLANG_DEBUG_INFO_FORMAT_C7, ///< CodeView C7 format (typically means debugging infomation is
826+
SLANG_DEBUG_INFO_FORMAT_C7, ///< CodeView C7 format (typically means debugging information is
827827
///< embedded in the binary)
828828
SLANG_DEBUG_INFO_FORMAT_PDB, ///< Program database
829829

@@ -1958,14 +1958,14 @@ public: \
19581958
// This `MyParams` type introduces two existential type parameters:
19591959
// one for `material` and one for `lights`. Even though `lights`
19601960
// is an array, it only introduces one type parameter, because
1961-
// we need to hae a *single* concrete type for all the array
1961+
// we need to have a *single* concrete type for all the array
19621962
// elements to be able to generate specialized code.
19631963
//
19641964
SLANG_PARAMETER_CATEGORY_EXISTENTIAL_TYPE_PARAM,
19651965

19661966
// An existential object parameter represents a value
19671967
// that needs to be passed in to provide data for some
1968-
// interface-type shader paameter.
1968+
// interface-type shader parameter.
19691969
//
19701970
// Consider this example:
19711971
//
@@ -2025,13 +2025,13 @@ public: \
20252025
parameters of different types as occupying the same binding space for layout
20262026
(e.g., in SPIR-V both a `Texture2D` and `SamplerState` use the same space of
20272027
`binding` indices, and are not allowed to overlap), while those same types
2028-
map to different types of bindingsin the API (e.g., both textures and samplers
2028+
map to different types of bindings in the API (e.g., both textures and samplers
20292029
use different `VkDescriptorType` values).
20302030
20312031
When you want to answer "what register/binding did this parameter use?" you
20322032
should use `SlangParameterCategory`.
20332033
2034-
When you wnat to answer "what type of descriptor range should this parameter use?"
2034+
When you want to answer "what type of descriptor range should this parameter use?"
20352035
you should use `SlangBindingType`.
20362036
*/
20372037
typedef SlangUInt32 SlangBindingTypeIntegral;
@@ -3601,7 +3601,7 @@ struct IGlobalSession : public ISlangUnknown
36013601
*/
36023602
virtual SLANG_NO_THROW ISlangSharedLibraryLoader* SLANG_MCALL getSharedLibraryLoader() = 0;
36033603

3604-
/** Returns SLANG_OK if a the compilation target is supported for this session
3604+
/** Returns SLANG_OK if the compilation target is supported for this session
36053605
36063606
@param target The compilation target to test
36073607
@return SLANG_OK if the target is available
@@ -3611,7 +3611,7 @@ struct IGlobalSession : public ISlangUnknown
36113611
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
36123612
checkCompileTargetSupport(SlangCompileTarget target) = 0;
36133613

3614-
/** Returns SLANG_OK if a the pass through support is supported for this session
3614+
/** Returns SLANG_OK if the pass through support is supported for this session
36153615
@param session Session
36163616
@param target The compilation target to test
36173617
@return SLANG_OK if the target is available
@@ -3689,7 +3689,7 @@ struct IGlobalSession : public ISlangUnknown
36893689
* @param argc The number of command line arguments.
36903690
* @param argv An input array of command line arguments to parse.
36913691
* @param outSessionDesc A pointer to a SessionDesc struct to receive parsed session desc.
3692-
* @param outAuxAllocation Auxillary memory allocated to hold data used in the sesion desc.
3692+
* @param outAuxAllocation Auxiliary memory allocated to hold data used in the session desc.
36933693
*/
36943694
virtual SLANG_NO_THROW SlangResult SLANG_MCALL parseCommandLineArguments(
36953695
int argc,
@@ -3815,7 +3815,7 @@ information.
38153815
38163816
In order to be able to load code, the session owns a set
38173817
of active "search paths" for resolving `#include` directives
3818-
and `import` declrations, as well as a set of global
3818+
and `import` declarations, as well as a set of global
38193819
preprocessor definitions that will be used for all code
38203820
that gets `import`ed in the session.
38213821
@@ -3880,7 +3880,7 @@ struct ISession : public ISlangUnknown
38803880
function will return null.
38813881
38823882
It is an error to create a composite component type that recursively
3883-
aggregates the a single module more than once.
3883+
aggregates a single module more than once.
38843884
*/
38853885
virtual SLANG_NO_THROW SlangResult SLANG_MCALL createCompositeComponentType(
38863886
IComponentType* const* componentTypes,
@@ -3953,7 +3953,7 @@ struct ISession : public ISlangUnknown
39533953
to explicitly specify which implementation types should be included in the final compiled
39543954
code. For example, if an module defines `IMaterial` interface and `AMaterial`,
39553955
`BMaterial`, `CMaterial` types that implements the interface, the user can exclude
3956-
`CMaterial` implementation from the resulting shader code by explcitly adding
3956+
`CMaterial` implementation from the resulting shader code by explicitly adding
39573957
`AMaterial:IMaterial` and `BMaterial:IMaterial` conformances to a composite
39583958
`IComponentType` and get entry point code from it. The resulting code will not have
39593959
anything related to `CMaterial` in the dynamic dispatch logic. If the user does not
@@ -4006,7 +4006,7 @@ struct IMetadata : public ISlangCastable
40064006
SLANG_COM_INTERFACE(0x8044a8a3, 0xddc0, 0x4b7f, {0xaf, 0x8e, 0x2, 0x6e, 0x90, 0x5d, 0x73, 0x32})
40074007

40084008
/*
4009-
Returns whether a resource parameter at the specifieid binding location is actually being used
4009+
Returns whether a resource parameter at the specified binding location is actually being used
40104010
in the compiled shader.
40114011
*/
40124012
virtual SlangResult isParameterLocationUsed(
@@ -4136,7 +4136,7 @@ struct IComponentType : public ISlangUnknown
41364136
41374137
Has the same requirements as getEntryPointCode.
41384138
4139-
The result is not written to the actual OS file system, but is made avaiable as an
4139+
The result is not written to the actual OS file system, but is made available as an
41404140
in memory representation.
41414141
*/
41424142
virtual SLANG_NO_THROW SlangResult SLANG_MCALL getResultAsFileSystem(
@@ -4166,7 +4166,7 @@ struct IComponentType : public ISlangUnknown
41664166
IComponentType** outSpecializedComponentType,
41674167
ISlangBlob** outDiagnostics = nullptr) = 0;
41684168

4169-
/** Link this component type against all of its unsatisifed dependencies.
4169+
/** Link this component type against all of its unsatisfied dependencies.
41704170
41714171
A component type may have unsatisfied dependencies. For example, a module
41724172
depends on any other modules it `import`s, and an entry point depends
@@ -4179,7 +4179,7 @@ struct IComponentType : public ISlangUnknown
41794179
It is an error to try to generate/access compiled kernel code for
41804180
a component type with unresolved dependencies, so if dependencies
41814181
remain after whatever manual composition steps an application
4182-
cares to peform, the `link()` function can be used to automatically
4182+
cares to perform, the `link()` function can be used to automatically
41834183
compose in any remaining dependencies. The order of parameters
41844184
(and hence the global layout) that results will be deterministic,
41854185
but is not currently documented.

source/slang/slang-capabilities.capdef

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// This file will be parsed and processed by the slang-capability-generator
55
// tool during the build process to produce slang-generated-capability-defs.h
66
// and slang-generated-capability-defs-impl.h files that constitute the final
7-
// C++ source of the compiler. New capabilties should be added by editing
7+
// C++ source of the compiler. New capabilities should be added by editing
88
// this file instead of the generated .h files.
99
//
1010
// A capability atom represent a basic unit that characterizes a single code-gen target or
@@ -1885,7 +1885,7 @@ alias subgroup_arithmetic = GL_KHR_shader_subgroup_arithmetic | _sm_6_0 | _cuda_
18851885
/// Capabilities required to use GLSL-style subgroup operations 'subgroup_shuffle'
18861886
/// [Compound]
18871887
alias subgroup_shuffle = GL_KHR_shader_subgroup_shuffle | _sm_6_0 | _cuda_sm_7_0;
1888-
/// Capabilities required to use GLSL-style subgroup operations 'subgroup_shufle_relative'
1888+
/// Capabilities required to use GLSL-style subgroup operations 'subgroup_shuffle_relative'
18891889
/// [Compound]
18901890
alias subgroup_shufflerelative = GL_KHR_shader_subgroup_shuffle_relative | _sm_6_0 | _cuda_sm_7_0;
18911891
/// Capabilities required to use GLSL-style subgroup operations 'subgroup_clustered'

source/slang/slang-ir-autodiff-fwd.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,7 @@ InstPair ForwardDiffTranscriber::transcribeInstImpl(IRBuilder* builder, IRInst*
20762076
case kIROp_GetArrayLength:
20772077
case kIROp_SizeOf:
20782078
case kIROp_AlignOf:
2079+
case kIROp_Printf:
20792080
return transcribeNonDiffInst(builder, origInst);
20802081

20812082
// A call to createDynamicObject<T>(arbitraryData) cannot provide a diff value,

tests/compute/constexpr.slang

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//TEST(compute):COMPARE_COMPUTE_EX:-slang -gcompute -shaderobj
33
//DISABLED://TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -gcompute -shaderobj
44
//TEST(compute):COMPARE_COMPUTE_EX:-mtl -gcompute -shaderobj
5+
//TEST(compute):COMPARE_COMPUTE_EX:-wgpu -gcompute -shaderobj
56

67
//TEST_INPUT: Texture2D(size=4, content = one):name tex
78
//TEST_INPUT: Sampler:name samp

tests/metal/nested-struct-fragment-input.slang

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
22
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
3+
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
34

45
// METAL: COARSEVERTEX_7
56
// METAL: COARSEVERTEX_6
@@ -63,6 +64,16 @@ float4 fragmentMain(FragmentStageInput input)
6364
// METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}=
6465
// METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}=
6566

67+
// WGSL-DAG: {{.*}}._S{{.*}}=
68+
69+
// WGSL-DAG: {{.*}}.p2{{.*}}._S{{.*}}=
70+
// WGSL-DAG: {{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}=
71+
// WGSL-DAG: {{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}=
72+
73+
// WGSL-DAG: {{.*}}.p3{{.*}}._S{{.*}}=
74+
// WGSL-DAG: {{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}=
75+
// WGSL-DAG: {{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}=
76+
6677
outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1;
6778
return float4(0, 0, 0, 0);
6879
}

tests/metal/nested-struct-fragment-output.slang

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain
22
//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain
3+
//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain
34

45
//METAL-DAG: color(0)
56
//METAL-DAG: color(1)
@@ -10,6 +11,15 @@
1011
//METAL-DAG: color(6)
1112
//METAL-NOT: color(7)
1213

14+
//WGSL-DAG: location(0)
15+
//WGSL-DAG: location(1)
16+
//WGSL-DAG: location(2)
17+
//WGSL-DAG: location(3)
18+
//WGSL-DAG: location(4)
19+
//WGSL-DAG: location(5)
20+
//WGSL-DAG: location(6)
21+
//WGSL-NOT: location(7)
22+
1323
//METALLIB: @fragmentMain
1424

1525
RWStructuredBuffer<float> outputBuffer;
@@ -69,6 +79,16 @@ FragmentStageOutput fragmentMain(FragmentStageInput input)
6979
// METAL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}.p1
7080
// METAL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}.p1
7181

82+
// WGSL-DAG: ={{.*}}._S{{.*}}
83+
84+
// WGSL-DAG: ={{.*}}.p2{{.*}}._S{{.*}}
85+
// WGSL-DAG: ={{.*}}.p2{{.*}}.p2{{.*}}._S{{.*}}
86+
// WGSL-DAG: ={{.*}}.p2{{.*}}.p3{{.*}}._S{{.*}}
87+
88+
// WGSL-DAG: ={{.*}}.p3{{.*}}._S{{.*}}
89+
// WGSL-DAG: ={{.*}}.p3{{.*}}.p2{{.*}}._S{{.*}}
90+
// WGSL-DAG: ={{.*}}.p3{{.*}}.p3{{.*}}._S{{.*}}
91+
7292
outputBuffer[0] = 1;
7393
return output;
7494
}

0 commit comments

Comments
 (0)