| Commit message (Collapse) | Author | Age |
| ... | |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add datalayout for constant buffers.
* Fixes.
* Fix test.
* Fix glsl codegen.
* Update spirv-specific doc.
* Fix test.
* Fix binding in the presense of specialization constants.
* address comments.
* Add a test for constant buffer layout.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Moved the pretty writer code from slang-reflection-test into core
* Moved reflection test code into the slang codebase and added the compiler option -reflection-json to store the reflection data in a separate file.
* Documented -reflection-json command line option
* moved PrettyWriter from core to compiler-core
* Fixed variable shadowing warning
* Use File::writeAllText instead of OSFilesystem and write to stdout if - is used as the path
* format code
* Fixed linker error
* Fix COM Ptr life time issues.
* Move enum to the end.
* Fix formatting.
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
| |
* Move switch statement bodies to their own lines
* format
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add support for write-only textures.
* Fix capabilities.
* Fix implementation.
* Fix.
* format code
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
|
| |
|
|
|
|
|
| |
* format
* Minor test fixes
* enable checking cpp format in ci
|
| |
|
|
|
| |
(#5415)
This commit changes the word "stdlib" or "standard library" to "core module" in the source code.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a breaking change in a way that the Slang API function names are changed. All of them are commented as "experimental" and we wouldn't provide a back-ward compatibility for them.
Following functions are renamed:
compileStdLib() -> compileCoreModule()
loadStdLib() -> loadCoreModule()
saveStdLib() -> saveCoreModule()
slang_createGlobalSessionWithoutStdLib() -> slang_createGlobalSessionWithoutCoreModule()
slang_getEmbeddedStdLib() -> slang_getEmbeddedCoreModule()
hasDeferredStdLib() -> hasDeferredCoreModule()
Following command-line arguments are renamed:
"-load-stdlib" -> "-load-core-module"
"-save-stdlib" -> "-save-core-module"
"-save-stdlib-bin-source" -> "-save-core-module-bin-source"
"-compile-stdlib" -> "-compile-core-module"
|
| |
|
|
|
| |
* Fix incorrect debug assert in `getLanguagePrelude`.
* Fix.
|
| |
|
|
|
| |
* Fix several bugs with `specializeWithArgTypes()`
* Make all types L-values for the purposes of reflection API resolution
|
| |
|
|
|
|
|
| |
* Add stdlib documentation for attributes and interfaces.
* Fix name mangling to avoid collision of functions in different extensions.
* Fix doc.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Overhaul docgen tool and setup CI to generate stdlib reference.
* Fix build error.
* Write parsed doc for all decls.
* fix.
* fix callout.
* Fix.
* Fix comment.
* Fix.
* Delete obsolete doc tests.
* Fix.
* Categorize functions and types.
* Fix CI.
* Update comments.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Use the assembly description as target when disassembling
I believe this is a bugfix.
It seems to have worked before because up until the WGSL case, the disassembler has been
the same executable as the one producing the binary to be disassembled.
* Add Tint as a downstream compiler
This closes issue #5104.
* Add downstream compiler for Tint.
* Tint is wrapped in a shared library, 'slang-tint' available from [1].
* The header file for slang-tint.dll is added in external/slang-tint-headers.
* Add some boilerplate for WGSL targets.
* Add an entry point test for WGSL.
[1] https://github.com/shader-slang/dawn/releases/tag/slang-tint-0
* Add WGSL_SPIRV as supported target for Glslang
* Add WebGPU support to slang-test
This helps to address issue #5051.
* Disable lots of crashing compute tests for 'wgpu'
This closes issue #5051.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement separate downstream library interface
Create a new com interface to house the methods for
precompiling slang modules to target code.
Add methods to count dependent modules and scrape
them for downstream target binaries such that the
downstream target binaries are linkabe outside
of slang, e.g. via spirv-link or dxc.
Fixes #5147
* Rename to _Experimental
Clearly identify this as an interface subject to change.
|
| |
|
|
|
|
|
| |
* Add COM API for querying metadata.
* Fix tests.
* fix test.
|
| |
|
|
|
|
|
|
|
|
|
| |
* Allow lookups of overloaded methods.
* Update slang-reflection-api.cpp
* Update slang.cpp
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
| |
* Add `FunctionReflection::specializeWithArgTypes()`
* Update slang.cpp
* Use a shared semantics context on linkage
Improve performance on reflection queries
* Try to fix linux/mac compile errors
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add WGSL as a target
This is required for #4807.
* C-like emitter: Allow the function header emission to be overloaded
WGSL-style function headers are pretty different from normal C-style headers:
Normal C-style headers:
ReturnType Func(...)
void VoidFunc(...)
WGSL-style headers:
fn Func(...) -> ReturnType
fn VoidFunc(...)
This change allows the header style to be overloaded, in order to accomodate WGSL-style
headers as required to resolve issue #4807, but retains normal C-style headers as the
default implementation.
[1] https://www.w3.org/TR/WGSL/#function-declaration-sec
* C-like emitter: Allow emission of switch case selectors to be overloaded
The C-like emitter will emit code like this:
switch(a.x)
{
case 0:
case 1:
{
...
} break;
...
}
This is not allowed in WGSL. Instead, selectors for cases that share a body must [1] be
separated by commas, like this:
switch(a.x)
{
case 0, 1:
{
...
} break;
...
}
To prepare for addressing issue #4807, this patch makes the emission of switch case
selectors overloadable.
[1] https://www.w3.org/TR/WGSL/#syntax-case_selectors
* C-like emitter: Support WGSL-style declarations
This patch helps to address issue 4807.
C-like languages declare variables like this:
i32 a;
WGSL declares variables like this:
var a : i32
The patch introduces overloads so that the forthcoming WGSL emitter can output WGSL-style
declarations, which helps to resolve #4807.
* C-like emitter: Support overloading of declarators
Unlike C-like languages, WGSL does not support the following types at the syntax level,
via declarators:
- arrays
- pointers
- references
For this reason, this patch introduces support for overloading the declarator emitter,
in order to help address issue #4807.
C-like languages:
int a[3]; // Array-ness of type is mixed into the "declarator"
WGSL:
var a : array<int, 3>; // Array-ness of type is part of the... type_specifier!
* C-like emitter: Allow struct declaration separator to be overridden
C-like languages use ';' as a separator, and languages like e.g. WGSL use ','.
This change prepares for addressing issue #4807.
* C-like emitter: Allow overriding of whether pointer-like syntax is necessary
Things like e.g. structured buffers map to "ptr-to-array" in WGSL, but ptr-typed
expressions don't always need C-style pointer-like syntax.
Therefore, make it overrideable whether or not such syntax is emitted in various cases in
order to address #4807.
* C-like emitter: Emit parenthesis to avoid warning about & and + precedence
This helps with #4807 because WGSL compilers (e.g. Tint) treat absence of parenthesis as
an error.
* C-like emitter: Add hook for emitting struct field attributes
WGSL requires @align attributes to specify explicit field alignment in certain cases.
Thus, this patch prepares for addressing #4807.
* C-like emitter: Add hook for emitting global param types
Declarations of structured buffers map to global array declarations in WGSL.
However, in all other cases such as when structured buffers are used in operands, their
types map to *ptr*-to-array.
This patch makes it possible for the WGSL back-end to say that structured buffers
generally map to "ptr-to-array" types, but still have a special case of just "array" when
declaring the global shader parameter.
Thus, this patch helps with addressing #4807.
* IR lowering: Use std140 for WGSL uniform buffers
This patch just cuts out some logic that prevented std140 to be chosen for WGSL uniform
buffers.
Note that WGSL buffers in the uniform address space is not quite std140, but for now it's
close enough to avoid compile issues.
Later on, a custom layout should be created for WGSL uniform buffers.
When that's done, this change will be revisited, but for now it helps to resolve #4807.
* Don't emit line directives in WGSL by default
WGSL does not support line directives [1].
The plan currently seems to be to instead support source-map [2].
This is part of addressing issue #4807.
[1] https://github.com/gpuweb/gpuweb/issues/606
[2] https://github.com/mozilla/source-map
* WGSL IR legalization: Map SV's
The implementation closely follows the cooresponding one for Metal.
Supported:
- DispatchThreadID
- GroupID
- GroupThreadID
- GroupThreadID
Unsupported:
- GSInstanceID
This is not complete, but it helps to address #4807.
* WGSL emitter: Add support for basic language constructs
A lot of the basics are added in order to generate correct WGSL code for basic Slang language constructs.
This addresses issue #4807.
This adds support for at least the following:
- statments
- if statements
- ternary operator
- while statement
- for statements
- variable declarations
- switch statements
- Note: Slang may emit non-constant case expressions, see issue 4834
- literals
- integer literals
- u?int[16|32|64]_t
- float and half literals
- bool literals
- vector literals and splatting (e.g 1.xxx)
- function definitions
- assignments
- +=, *=, /=
- array assignments
- vector assignments/updates
- swizzles of other vectors
- from matrix rows ('m[i]' notation)
- from matrix cols (using swizzle notation, e.g 'm._11_12_13')
- matrix assignments/updates
- to rows ('m[i]' notation)
- to cols (using swizzle notation, e.g 'm._11_12_13')
- declarations
- arrays
[1] https://www.w3.org/TR/WGSL/#syntax-switch_body
* Add some WGSL capabilities
This patch registers some WGSL capabilities required to pass many of the initial compute
shader compile tests.
Many capabilities still remain to be added -- this is just an initial set to help resolve
issue #4807.
- asint
- min and max
- cos and sin
- all and any
* WGSL and C-like emitters: Add hack to bitcast case expression
In WGSL, the switch condition and case types must match.
https://www.w3.org/TR/WGSL/#switch-statement
Slang currently allows these types to mismatch, as pointed out in #4921.
Issue #4921 should eventually be addressed in the front-end by a patch like [1].
However, at the moment that would break Falcor tests.
Thus, this patch temporarily works around the issue in the WGSL emitter only in order to
help resolve #4807.
In the future, the Falcor tests should be fixed, this patch should be dropped and [1]
should be merged instead.
[1] a32156ef52f43b8503b2c77f2f1d51220ab9bdea
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial -embed-spirv support
Add support for SPIR-V precompilation using the framework
established for DXIL.
Work on #4883
* SLANG_UNUSED
* Add linkage attributes to exported spirv functions
* Combine DXIL and SPIRV paths
* Whitespace fix
* Merge remaining precompiled spirv/dxil paths
* Change inst accessors to return codegentarget
* Add unit test for precompiled spirv
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
| |
* Support entrypoints defined in a namespace.
* Fix test.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Support mixture of precompiled and non-precompiled modules
This changes the implementation of precompile DXIL modules to
accept combinations of modules with precompiled DXIL, ones without,
and ones with a mixture of precompiled DXIL and Slang IR.
During precompilation, module IR is analyzed to find public functions
which appear to be capable of being compiled as HLSL, and those
functions are given a HLSLExport decoration, ensuring they are emitted
as HLSL and preserved in the precompiled DXIL blob. The IR for those
functions is then tagged with a new decoration AvailableInDXIL, which
marks that their implementation is present in the embedded DXIL blob.
The DXIL blob is attached to the IR as before, inside a EmbeddedDXIL
BlobLit instruction.
The logic that determines whether or not functions should be
precompiled to DXIL is a placeholder at this point, returning true
always. A subsequent change will add selection criteria.
During module linking, the full module IR is available, as well
as the optional EmbeddedDXIL blob. The IR for functions implemented
by the blob are tagged with AvailableInDXIL in the module IR.
After linking the IR for all modules to program level IR, the IR for
the functions marked AvailableInDXIL are deleted from the linked IR,
prior to emitting HLSL and compiling linking the result.
This change also changes the point of time when the module IR is
checked for EmbeddedDXIL blobs. Instead of happening at load time
as before, it happens during immediately before final linking, meaning
that the blob does not need to be independently stored with the module
separate from the IR as was done previously.
Work on #4792
* Clean up debug prints
* Call isSimpleHLSLDataType stub
* Address feedback on precompiled dxil support
Allow for IR filtering both before and after linking.
Only mark AvailableInDXIL those functions which pass
both filtering stages. Functions are corrlated using
mangled function names.
Rather than delete functions entirely when linking with
libraries that include precompiled DXIL, instead convert
the IR function definitions to declarations by gutting
them, removing child blocks.
* Use artifact metadata and name list instead of linkedir hack
* Use String instead of UnownedStringSlice
* Update tests
* Renaming
* Minor edits
* Don't fully remove functions post-link
* Unexport before collecting metadata
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Allow capabilities to be used with `[shader("...")]`
Fixes: #4917
Changes:
1. Allow using capabilities instead of `Stage`s with `EntryPointAttribute`.
2. When resolving capabilities for an entrypoint+profile (per entrypoint) in `resolveStageOfProfileWithEntryPoint` add our `EntryPointAttribute` and resolved capability
3. Added tests and some capabilities related clean-up
* fix a warning made by a mistake in syntax
* change fineStageByName to assume it is passed a stage without a '_'
* test with and without prefix '_'
* cleanup some profiles and reprisentation to work better with 'Stage' and 'Profile'
This use case is why we need to clean all profile-usage into `CapabilityName`s directly.
* change how we compare
* only change profiles
* let all capabilities be resolved by 'shader' profile for now
* fix warning checks I accidently broke
* meshshading_internal to _meshshading
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#4909)
* More reflection API features.
+ Lookup methods and members (by string) on types
+ Fix issue with looking up non-static members through the scope operator '::'
+ `GenericReflection`: Cast a decl to generic to access unspecialized generic parameter names and constraints
+ `GenericReflection`: Use `getGenericContainer()` from function, variable or type to access the 'nearest' generic parent along with specialization info
+ `GenericReflection::getConcreteType` and `GenericReflection::getConcreteIntVal`: to get the concrete type of a param in the context of the reflection object
+ `GenericReflection::getOuterGenericContainer` to go up one level and get the outer generic declarations (if there are more than one enclosing generic scopes)
+ `DeclReflection::getParent`: go to parent declaration.
+ Change `VariableReflection` to be a `DeclRef` rather than a decl (allows us to return properly substituted types for methods, members, and more)
* Fix Falcor issue
* Initial namespace reflection support
* FIx issue with specializing witness tables
* Add API method for specializing parameters of a generic decl
* Add ability to specialize generic references to functions, types and more
This PR adds the following end-points:
- `specializeGeneric()` method that can be called on a generic reflection to substitute arguments for generic type and value parameters. It returns another generic reflection, but this time with the appropriate substitution.
- `applySpecializations()` method to then copy these specializations onto an existing type or function reflection.
- `isSubType()` to check if a type is a subtype of another type (useful to check if a type is differentiable by checking `IDifferentiable`)
This PR also:
- Adds `DeclReflection::Kind::Namespace` so that namespace containers are correctly reflected when walking the decl-tree. the name can be obtained through `getName()` but there's no need to cast to a namespace (since there's nothing else we can do with a namespace decl)
- Fixes an issue with name-based lookups that fail if a type or function is referenced without specializations. Its helpful to be able to form a reference to a function with default substitutions, so that we can we can specialize it later (either directly, or via argument types).
* Update slang.h
* Fix up naming
* Update slang-compiler.h
* Update slang-reflection-api.cpp
* Update slang.cpp
* Update slang.cpp
* Update slang.cpp
* Use `checkGenericAppWithCheckedArgs` to do specialization
* Update slang-reflection-api.cpp
* Update slang-check-decl.cpp
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement `-fvk-use-dx-layout`
Fixes: #4126
Changes:
* Added fvk-use-dx-layout
* Modified `HLSLConstantBufferLayoutRulesImpl` for correctness (ex: Array is always 16 byte aligned)
* Added kFXCShaderResourceLayoutRulesFamilyImpl and kFXCConstantBufferLayoutRulesFamilyImpl to handle fvk-use-dx-layout
* Added `ConstantBufferLayoutRules` to manage constant buffer rules
* Added `alignCompositeElementOfNonAggregate`/`alignCompositeElementOfAggregate` to handle forced alignment of composites for ConstantBuffers
* `StructuredBuffer` rules are mostly equal to `scalar` layout, not much was needed to be changed to support this behavior.
* seperate legacy constant buffer and how Slang does constant-buffer normally
* undo an addition
* remove accidental test
* Address review and fix
Address review and remove GLSL support since GLSL requires a seperate legalization (need to linearlize structs like with `legalizeMetalIR` to assign explicit offsets)
* comments
* remove aggregate and non-aggregate logic
We don't need this distinction for the logic
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Make precompileForTargets work with Slang API
precompileForTargets, renamed to precompileForTarget, does not need
an EndToEndCompileRequest and some objects created from it are not
necessary either.
Take only a target enum and a diagnostic blob as input and handle
everything else internally, such as creating the TargetReq with
chosen profile.
Fixes #4790
* Update slang-module.cpp
* Update slang-module.cpp
|
| |
|
| |
Adds a new Github CI action for benchmarking the slangc compiler on the MDL shaders. For now, the results are only dumped to the output of the CI, which can be later viewed through raw logs. The next step is to use github-action-benchmark to push these results into a page which will show the benchmark results over time as commits are pushed.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* More reflection API features.
+ Lookup methods and members (by string) on types
+ Fix issue with looking up non-static members through the scope operator '::'
+ `GenericReflection`: Cast a decl to generic to access unspecialized generic parameter names and constraints
+ `GenericReflection`: Use `getGenericContainer()` from function, variable or type to access the 'nearest' generic parent along with specialization info
+ `GenericReflection::getConcreteType` and `GenericReflection::getConcreteIntVal`: to get the concrete type of a param in the context of the reflection object
+ `GenericReflection::getOuterGenericContainer` to go up one level and get the outer generic declarations (if there are more than one enclosing generic scopes)
+ `DeclReflection::getParent`: go to parent declaration.
+ Change `VariableReflection` to be a `DeclRef` rather than a decl (allows us to return properly substituted types for methods, members, and more)
* Fix Falcor issue
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add embedded precompiled binary IR ops
Add IR operations to embed precompiled DXIL or SPIR-V blobs
into IR. Adds a BlobLit literal that is mostly identical to
StringLit except for its inability to be displayed, e.g.
in dumped IR. In the future, the blob might be dumped as
hexadecimal, but for now it is summarized as "<binary blob>".
* EmbeddedDXIL and SPIR-V options
The options, '-embed-dxil' and '-embed-spirv' in slangc, will
cause a target dxil or spirv to be compiled and stored in the
translation unit IR when written to a slang-module. Subsequent
changes actually implement the options.
* Per-translation unit DXIL precompilation
When -embed-dxil is specified, perform a precompilation to DXIL of
each TU, linked only with stdlib. Embed the resulting DXIL for
the TU in a IR op. Being part of IR, the precompiled DXIL can be
serialized to disk in a slang-module.
Upon loading slang-modules, the new IR op will be searched for and
the precompiled DXIL blob is saved with the loaded Module. During
linking, if all the Modules have precompiled blobs they will be
sent to the downstream compile commands as libraries instead of
source, skipping the downstream compilation, using DXC only for
linking.
Fixes Issue #4580
* Remove placeholder embedded SPIRV support
Code was added only to sketch out how other precompiled bins
will be supported.
* Remove the rest of the SPIRV placeholder support
* Fix warnings, test error on non-windows
* Remove lib_6_6 hack, add dxil_lib capability
* Allocate blob value from irmodule memarena
* Add null check after memarena allocation
* Restore the request->e2erequest code path for generatewholeprogram
* Update capability handling, move EmbedDXIL enum to end to preserve abi
* Remove lib_6_6 hack
* Move ICompileRequest functions to end
|
| |
|
| |
Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
* Support parameter block in metal shader objects.
* Ingore parameter block tests on devices without tier2 argument buffer.
* Fix warning.
* Fix texture subscript test.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Initial implementation for decl-tree reflection API
This patch adds Slang API methods for walking all the declarations in the AST.
We expose this functionality through an abstract `DeclReflection` class that can be a type, function or a variable declaration.
We also provide ways to cast the decl to a `FunctionReflection`, `TypeReflection` or `VariableReflection` and traverse through the child nodes (for instance, a struct type will have component variable declarations)
This patch also adds `ISlangInternal` as an internal COM interface to allow us to cast IGlobalSession to the internal Session pointer while bypassing any wrappers (such as the capture interface)
* Update slang.h
* Remove `ISlangInternal` (its causing a diamond pattern w.r.t `ISlangUnknown`) and use `ComPtr` for proper ref management.
* Update unit-test-decl-tree-reflection.cpp
* Change `FunctionDeclBase` to use `DeclRef` instead of directly using the decl.
* Update slang-reflection-api.cpp
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Move the file public header files to `include` dir
Close the issue (#4635).
Move the following headers files to a `include` dir
located at root dir of slang repo:
slang-com-helper.h -> include/slang-com-helper.h
slang-com-ptr.h -> include/slang-com-ptr.h
slang-gfx.h -> include/slang-gfx.h
slang.h -> include/slang.h
Change cmake/SlangTarget.cmake to add include path to
every target, and change the source file to use
"#include <slang.h>" to include the public headers.
The source code update is by the script like follow:
```
fileNames_slang=$(grep -r "\".*slang\.h\"" source/ -l)
for fileName in "${fileNames_slang[@]}"
do
echo "$fileName"
sed -i "s/\".*slang\.h\"/\"slang\.h\"/" $fileName
done
```
* Fix the test issues
* Fix cpu test issues by adding include seach path
* Update cmake to not add include path for every target
Also change "#include <slang.h>" to "include "slang.h" " to
make the coding style consistent with other slang code.
* Change public include to private include for unit-test and slang-glslang
|
| |
|
| |
At the moment it is always "unknown"
|
| | |
|
| |
|
|
|
|
|
|
|
| |
* Cope with failed version parsing
* Better version parsing
* populate slang-tag-version with cmake
* Neaten cmake
|
| |
|
|
|
|
|
|
|
|
|
| |
* Add reflection API for functions.
This change adds `SlangFunctionReflection` type in the reflection API that provides methods for querying function result type, parameters and user-defined attributes.
`ProgramLayout::findFunctionByName` can now find a function with the given name and returns a `FunctionReflection`.
`IEntryPoint` now has a `getFunctionReflection` method that returns an `FunctionReflection` for the entrypoint.
* More modifiers; make reflection API consistent.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* capability upgrade warning/error
adjusted implementation + tests to support a warning/error if capabilities are implicitly upgraded and test accordingly.
* add glsl profile caps
* add GLSL and HLSL capabilities to the associated capability
* syntax error in capdef
* only error if user explicitly enables capabilities
1. changed testing infrastructure to not set a `profile` explicitly,
2. Added tests to be sure this works as intended with user API and with slangc command line
* Change capability atom definitions and how Slang manages them to fix errors
1. most `glsl_spirv` version atoms have been removed from `.capdef`, instead we will translate `spirv` version atoms into `glsl_spirv` since there is no point in writing the same code twice in `.capdef` files to define `spirv` versions.
2. add spirv version, and hlsl sm version (and equivlent) capability dependencies
3. removed some stage requirments which were set on objects, keep the wrapper capabilities. I am keeping the wrapper capabilities since I am unaware on if there are stage limitations (spec says code in practice does not work).
* check internal version instead of version profile (_spirv_1_5 vs. spirv_1_5)
* remove unused OpCapability. adjust SPIRV version'ing again for glsl_spirv
* apply workaround for glslang bug with rayquery usage
* ensure capabilities targetted by a profile and added together by a user are valid
* remove additions to `spirv_1_*` wrapper
* spirv_* -> glsl_spirv fix
* fix bug where incompatable profiles would cause invalid target caps
* try to avoid joining invalid capabilities
* fix the warning/error & printing
* run through tests to fix capability system and test mistakes
many mistakes were mesh shaders doing `-profile glsl_450+spirv_1_4`. This is not allowed for a few reasons
1. the test tooling does not handle arguments the same as `slangc`
2. glsl_450 core profile does not support mesh shaders, nor does spirv_1_4. sm_6_5 does work in this senario
* set some sm_4_1 intrinsics to sm_4_0
* replace `GLSL_` defs with `glsl_`
* swap the unsupported render-test syntax for working syntax
* set d3d11/d3d12 profile defaults
this is required since sm version changes compiled code & behavior
* adjusted nvapi capabilities with atomics + d3d11 set to use sm_5_0 as per default
* cleanup
* address review
* incorrect styling
* change `bitscanForward` to work as intended on 32 bit targets
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Default (zero'd) values with `-zero-initialize` flag
Adds `-zero-initialize` flag to set values to a __default() expression if they are missing a initExpr.
* address review and ensure __default calls ctor + zero's fields.
1. We must keep zero-initialize in SemanticsDeclHeaderVisitor. This is done because else a ctor will be initialized before we can set struct fields to `__default`.
2. IRDefaultCtorDecoration was added to track default ctor's with parent struct.
3. ParentAggTypeModifier was added to track ChildOfStruct->IRType for sharing data such as with functions. This is required to ensure we associate a lowered function with a lowered struct type
* Removed decoration to track defaultCtor in favor of field.
This was done since decorations are checked for IR objects, storing auxillary info does not work here as a result if usable object.
* address some review comments
Since `IDefaultInitializable` is taking a considerabley larger amount of time than anticipated I am pushing some of the other fixes requested. I did not remove the "IRStruct storing a default Ctor" hack yet.
mostly renamed/adjusted tests to work as intended
added test to ensure we don't synthisize a junk `= 0` when not in `zero initialize` mode
removed member in favor of sharedContext+dictionary.
* a working but incorrect impl
* default init without any IR hacks (fully working aside from generic/containored-types)
* Finish zero init code
1. IDefaultInitializer interface was added. If conforming, your type may be zero-initialized. To Conform a `__init()` is required
2. `[OnlyAutoInitIfForced]` was added. This attribute states that a default initializer should only be implicitly called if forced by the compiler (`zero-initialize` for example). This allows types which implicitly/explicitly conform to IDefaultInitialize to have optional auto-init behavior (which is Slang's default for user structs) to be disabled.
* note about `[OnlyAutoInitIfForced]`. This is required for std-lib to not automatically resolve init-expressions for std-lib, but it has the added benifit of allowing user made structs/classes to control the default behavior of initializing
* fix ErrType assumption
* testing why dx12 fails local but passes CI
* push vector changes to generic test
* push syntax adjustment, still figuring out what is wrong with cuda.
* remove debug changes & adjust style
* fix field-init expressions with structs initializers
don't init a static in a ctor. This would be illegal code and wrong code (init list in lower-to-ir)
* minor adjustments temporarily while the rest of the issue is discussed
* fix
* implement IDefaultInitializable
* remove a unneeded whitespace change
* fix type checking error
should be checking if a valid type is `Type`, not `BasicExpressionType`
* needs to be DeclRefType, not Type
* fix langguage server error
* change findinheritance for correctness + cleanup
* remove return false
verified the issue was `findInheritance`
* push attempt at language server fix
* still trying to fix inheritance
* added extension support, remove redundant code
Did not address all review comments yet, want to see if CI also passes my changes
* undo a change which caused CI to fail
* change logic + DefaultConstructExpr
setup code to use defaultConstructExpr when possible to construct a default without overhead of invoke/related
also changed code so parent's defaultInitializable propegates to derived member
* 1. fix error in `isSubtype` 2. add flag to isSubtype
`subtypeInheritanceIsNotFullyResolved` was added since we may not be done the lookup stage but still require `isSubtype` checking to verify usage of inheritance while working with inheritance. In This case we will just skip `ensureLookup` and "caching" (since we don't have a cache invalidation system, nor need)
* fix bug in logic + add test to better catch the bug
* address comment + isSubTypeOption + wrapper type test,
* fix wrong code adjustment
I checked on the CI and realized I caused a failure, mistake was made not negating some code
* syntax, class naming capital
* remove stdlib default initialize changes, replace with `__default()` for init
* remove redundant code + fix defaultConstruct emitting
previously defaultConstruct emitting was crashing due to having generics unresolved. By not resolving the default construct immediately, everything works.
* remove a coment
* add test to ensure static variables dont `init` inside a struct's `__init`
* fix Ptr members breaking struct use
* address review and add -zero-initialize test
`-zero-initialize` test was added to be sure debug pointers are not broken with default init values
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add APIs to get profile of compile time
Add serial time measurement
Add profiler to measure lots of stages in slang compilation, and it
can accumulate the time spent in each thread in multi-threads case and
finally report a serial timing info.
* Add invocation times to the profiler
* Simplify the profiler and provide a 'clear' option
Change the profiler design to only return the thread_local
profiler to user.
We create a ISlangProfiler interface to carry the thread_local
variable PerformanceProfilerImpl profiler to user.
In addition, we provide a new option in the input parameter to
control whether or not user want to clear the previous profile
data. So spGetCompileProfile() can always returns a fresh new
profiling data.
* Change to use slang container List
Stop using std::vector, instead use slang's container List.
Generate a UUID for ISlangProfiler
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* capture/relay: Add capture interface classes
Add `ModuleCapture` class for capturing `IModule`
- The `IModule` can only be created from
-- `ISession::loadModule`
-- `ISession::loadModuleFromIRBlob`
-- `ISession::loadModuleFromSource`
-- `ISession::loadModuleFromSourceString`
so, we create the `ModuleCapture` at those methods in `SessionCapture`
class. We use a hash map to store a map from `IModule` to `ModuleCapture`
to avoid creating new `ModuleCapture` when there is already an old one.
- In `SessionCapture::getLoadedModule`, we will assert on not finding
a `ModuleCapture` instance.
Add `EntryPointCapture` class for capturing `IEntryPoint`.
- The `IEntryPoint` can only be created from:
-- `IModule::findEntryPointByName`
-- `IModule::findAndCheckEntryPoint`
so, we create the `EntryPointCapture` at those methods in `ModuleCapture`.
Similarly, we use a hash map to store a map from `IEntryPoint` to
`EntryPointCapture`.
- In `IModule::getDefinedEntryPoint`, we will assert on not finding
a `EntryPointCapture` instance.
Add `CompositeComponentTypeCapture` class for capturing CompositeComponentType,
but since user is only exposed to `IComponentType`, so `CompositeComponentTypeCapture`
just inherits from `IComponentType`.
- `CompositeComponentType` can only be created from:
-- ISession::createCompositeComponentType
so create it here.
Add `TypeConformanceCapture` class for capturing `ITypeConformance`.
- The `ITypeConformance` can only be created from:
-- `ISession::createTypeConformanceComponentType`
so create it here.
In addition, because `EntryPointCapture` and `ModuleCapture` share a some
base class `IComponentType`, we generate the COM GUID for those two
classes to differentiate them.
* Fix the build issue
* Add nullptr check for output parameter
* define the SLANG_CAPTURE_ASSERT macro used in both debug and release build
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Capabilities System, Backing Logic Overhaul
Fixes #4015
Problems to address:
1. Currently the capabilities system spends anywhere from 25-50% of compile time on the CapabilityVisitor. Most of this time is spent on join logic: 1. Finding abstract atoms 2. Comparing list1<->list2. This should and can be made significantly faster.
2. Error system does not produce errors with auxiliary information. This will require a partial redesign to provide more useful semantic information for debugging.
What was addressed:
1. Array backed `CapabilityConjunctionSet` was replaced in-favor for a `UIntSet` backed `CapabilityTargetSets`. The design is described below.
Design:
* `CapabilityTargetSets` is a `Dictionary<targetAtom, CapabilityTargetSet>`. This is not an array for 2 reasons: 1. Easy to figure out which target is missing between two `CapabilityTargetSets` 2. To statically allocate an array requires the preprocessor to manually annotate which Capability is a target and link that Capability to an index. This means a dictionary is required for lookup regardless of implementation.
* `CapabilityTargetSet` is an intermediate representation of all capabilities for a singular `target` atom (`glsl`, `hlsl`, `metal`, ...). This structure contains a dictionary to all stage specific capability sets for fast lookup of stage capabilities supported by a `CapabilitySet` for a `target` atom. This reduces number of sets searched.
* `CapabilityStageSet` is an intermediate representation of all capabilities for a singular `stage` atom (`vertex`, `fragment`, ...). This structure holds all disjoint capability sets for a `stage`. A disjoint set is rare, but may exist in some scenarios (as an example): `{glsl, EXT_GL_FOO}{glsl, _GLSL_130, _GLSL_150}`. This reduces the number of sets searched.
* `UIntSet` is the main reason for the redesign for better performance and memory usage. All set operations only require a few operations, making all set logic trivial and with minimal cost to run. All algorithms were modified to focus around `UIntSet` operations.
2. Errors
* Semantic information are now better linked to the calling function to provide a connection of function<->function_body for when saving semantic information for errors.
* Missing targets now print errors much like other error code by finding code which could be a cause of incompatibility.
What is missing:
1. Add non naive support for non-stage specific capabilities such as `{hlsl, _sm_5_0}`. Currently non stage specific targets emulate the behavior through assigning such capabilities to every stage: `{hlsl, _sm_5_0, vertex} {hlsl, _sm_5_0, fragment}...`. Removal of this behavior would remove redundant shader stage sets being made at construction time (~80% of new implementation runtime). This is an addition, not an overhaul.
2. Optionally: `UIntSet` should be modified to support SIMD operations for significantly faster operations. This is not required immediately since `UIntSet` is already not a performance constraint.
Notes:
* UIntSet had implementation bugs which were fixed in this PR.
* The old capabilities system had bugs which were fixed in this PR when transforming to the new implementation.
* fix .natvis debug view
* Small optimizations I found while working on the addition
the AST building pass looks like so now:
1% = ~capabilitySet
2% = capabilitySet()
1.5% capabilitySet::unionWith()
0.8% capabilitySet::join()
1.5% auxillary info for debugging
~0.5-1% extra visitor overhead
~5% total for the visitor
~6.5% for total runtime costs
* fix caps which were wrong but worked
* push minor syntax fix (still looking for why other tests fail)
* perf & bug fixes
1. did not properly remake isBetterForTarget for this->empty case with that as Invalid. This is best case in this senario.
2. Remade seralizer for stdlib generation. Faster (more direct) & cleaner code.
NOTE: did not address review comments
* fix glsl.meta caps error
* fixing findBest logic again & UIntSet wrapper
findBest was not checking for 'more specialized' targets & was element counter was flawed
* faster getElements algorithm + natvis for UIntSet + wrong warning
* type incompatability of bitscanForward implementations
* try to fix warnings again
* remove ptr for clang intrinsic
* add missing header
* ifdef to allow clang compile
* compiler hackery to fix up platform/type independent operations
* bracket
* fix MSVC error
* missing template
* change types out again
* changes to fix compiling
* adjustment to parameter for Clang/GCC
* added iterator to delay processing all atomSets of a CapabilitySet
* add a few missing consts's
* ensure we never have more than 1 disjointSet
Added a wrapper + assert + union functionality to all possible disjoint sets. This was done in favor of a removal of the LinkedList for 2 reasons:
1. We still need 0-1 set functionality.
2. Might as well keep the code, just disallow the problematic functionality.
* address review comments
non linked-list refactor review comments addressed; add doc comments + remove redundant code
* comments + remove isValid for bool operator
* push removal of linkedlist for capabilities
* add missing break
* address review comments
minor adjustments of syntax
* push a fix to the `CapabilitySet({shader, missing target})` code
* quality + error
1. add iterator to UIntSet
2. do not specialize target_switch if profile is derived from case (GLSL_150 is not compatable with GLSL_400)
* fix target_switch erroring + temporarily remove UIntSet::Interator
temporarily remove UIntSet::Interator. It will be added after, testing code on CI first so I can multi-task fixing the UIntSet Iterator
* fix the UIntSet iterator
* Revert "fix the UIntSet iterator" temporarily to pull from master
* add metal error as per texture.slang
(took a while I realize this was why things were breaking, likely should adjust errors to reflect this)
* Rework UIntSet to have a template for output type
This is done so it is reasonable to debug the iterator output and not just dealing with messy int's
Fix problems with the iterators implemented + invalid capabilities handling
* removed incorrect `__target_switch` capability
barycentric was being used with anticipation of `profile glsl450`, this does not expand into `GL_EXT_fragment_shader_barycentric`, this instead caused an error which is hidden during cross-compile.
* remove some uses of getElements
* remove undeclared_stage for now
* remove redundant code associated with `undeclared_stage`
* remove unused variable
* address review
specifically to note removed static in a thread dangerous scope. Now using a `const static` for read only (thread safe) which precompile steps generate
* move GLSL_150 capdef change to sm_4_1 (more accurate)
* address most review comments
did not address: https://github.com/shader-slang/slang/pull/4145#discussion_r1602256776
* revert incorrect code review suggestion
* push changes for all code review suggestions
|
| | |
|