diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2017-10-18 11:08:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-18 11:08:47 -0700 |
| commit | a12480fe49d5ba7c0a9c2ac63363dc76b599ddbd (patch) | |
| tree | 6344dec2a432f2f5cb1cdd981d0aafe21ea6a443 /source/slang/hlsl.meta.slang | |
| parent | f12c2552b3f494cbc8245edb90b32b93ca8a1539 (diff) | |
Work on IR-based cross-compilation (#222)
There are two big changes here:
- Add logic during the initial IR cloning pass for an entry point + target that tries to pick the best possible version of any target-overloaded function. This allows us to pick the intrinsic version of `saturate()` when compiling for HLSL output, but then pick the non-intrinsic version (that is implemented in terms of `clamp()`) when targetting GLSL.
- Add an initial specialization pass that tries to deal with generics. This required some fixing work to IR generation, so that we correctly generate explicit operations to specialize a generic for specific types (this is currently implemented as a `specialize` instruction that takes the generic to specialize plus a declaration-reference that represents the specialized form). With that work in place, we can scan for `specialize` instructions inside of non-generic functions, and use them to trigger generation of specialized code. We rely on the name-mangling scheme to help us find pre-existing specializations when possible.
There are also a bunch of cleanups encountered along the way:
- Don't use the explicit `layout(offset=...)` for uniforms, because it isn't supported by all current drivers. For now we will just assume that our layout rules compute the same values that the driver would for un-marked-up code. We can come back later and try to implement a workaround in the cases where this doesn't apply (e.g., by re-running the layout logic as part of emission, and dropping layout modifiers from variables that don't need explicit layout).
- Fix some issues in IR dump printing so that we print function declarations more nicely.
- Testing: print out failing pixel when image-diff fails
Diffstat (limited to 'source/slang/hlsl.meta.slang')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 81e9931e8..dc1d4d8e8 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -326,9 +326,9 @@ __generic<T : __BuiltinFloatingPointType, let N : int, let M : int> __intrinsic_ __intrinsic_op bool CheckAccessFullyMapped(uint status); // Clamp (HLSL SM 1.0) -__generic<T : __BuiltinArithmeticType> __intrinsic_op T clamp(T x, T min, T max); -__generic<T : __BuiltinArithmeticType, let N : int> __intrinsic_op vector<T,N> clamp(vector<T,N> x, vector<T,N> min, vector<T,N> max); -__generic<T : __BuiltinArithmeticType, let N : int, let M : int> __intrinsic_op matrix<T,N,M> clamp(matrix<T,N,M> x, matrix<T,N,M> min, matrix<T,N,M> max); +__generic<T : __BuiltinArithmeticType> T clamp(T x, T min, T max); +__generic<T : __BuiltinArithmeticType, let N : int> vector<T,N> clamp(vector<T,N> x, vector<T,N> min, vector<T,N> max); +__generic<T : __BuiltinArithmeticType, let N : int, let M : int> matrix<T,N,M> clamp(matrix<T,N,M> x, matrix<T,N,M> min, matrix<T,N,M> max); // Clip (discard) fragment conditionally __generic<T : __BuiltinFloatingPointType> __intrinsic_op void clip(T x); |
