summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/command-line-slangc.md49
-rw-r--r--source/slang/slang-type-layout.cpp12
-rw-r--r--source/slang/slang-type-layout.h4
3 files changed, 48 insertions, 17 deletions
diff --git a/docs/command-line-slangc.md b/docs/command-line-slangc.md
index 9eaf2343a..5d4119db7 100644
--- a/docs/command-line-slangc.md
+++ b/docs/command-line-slangc.md
@@ -161,7 +161,7 @@ The mechanism used here is based on the `-X` mechanism used in GCC, to specify a
-Xlinker option
```
-When used, option is not interpreted by GCC, but is passed to the linker once compilation is complete. Slang extends this idea in several ways. First there are many more 'downstream' stages available to Slang. These different stages are known as `SlangPassThrough` types in the API and have the following names
+When used, `option` is not interpreted by GCC, but is passed to the linker once compilation is complete. Slang extends this idea in several ways. First there are many more 'downstream' stages available to Slang than just `linker`. These different stages are known as `SlangPassThrough` types in the API and have the following names
* `fxc` - FXC HLSL compiler
* `dxc` - DXC HLSL compiler
@@ -172,13 +172,13 @@ When used, option is not interpreted by GCC, but is passed to the linker once co
* `genericcpp` - A generic C++ compiler (can be any one of visual studio, clang or gcc depending on system and availability)
* `nvrtc` - NVRTC CUDA compiler
-The Slang command line allows you to specify an argument to these downstream compilers, by using their name after the -X. So for example to send an option `-Gfa` through to DXC you can use
+The Slang command line allows you to specify an argument to these downstream compilers, by using their name after the `-X`. So for example to send an option `-Gfa` through to DXC you can use
```
-Xdxc -Gfa
```
-Note that if an option is available via normal Slang command line options then these should be used. This will work on multiple targets, but also avoids options clashing. As it stands Slang does not determine if a command line setting using the `-X` option clashes with regular Slang options in any way. This mechanism is best used for options that are unavailable through normal Slang mechanisms.
+Note that if an option is available via normal Slang command line options then these should be used. This will generally work across multiple targets, but also avoids options clashing which is undefined behavior currently. The `-X` mechanism is best used for options that are unavailable through normal Slang mechanisms.
If you want to pass multiple options using this mechanism the `-Xdxc` needs to be in front of every options. For example
@@ -186,30 +186,53 @@ If you want to pass multiple options using this mechanism the `-Xdxc` needs to b
-Xdxc -Gfa -Xdxc -Vd
```
+Would reach `dxc` as
+
+```
+-Gfa -Vd
+```
+
This can get a little repetitive especially if there are many parameters, so Slang adds a mechanism to have multiple options passed by using an ellipsis `...`. The syntax is as follows
```
-Xdxc... -Gfa -Vd -X.
```
-The `...` at the end indicates all the following parameters should be sent to DXC until it reaches the terminating `-X` or the end of the command line.
+The `...` at the end indicates all the following parameters should be sent to `dxc` until it reaches the matching terminating `-X.` or the end of the command line.
It is also worth noting that `-X...` options can be nested. This would allow a GCC downstream compilation to control linking, for example with
```
--Xgcc -Xlinker --split -X
+-Xgcc -Xlinker --split -X.
+```
+
+In this example gcc would see
+
+```
+-Xlinker --split
+```
+
+And the linker would see (as passed through by gcc)
+
+```
+--split
```
Setting options for tools that aren't used in a Slang compilation has no effect. This allows for setting `-X` options specific for all downstream tools on a command line, and they are only used as part of a compilation that needs them.
-NOTE! Not all tools that Slang uses downstream make command line argument parsing available. Of note `FXC` and `GLSLANG` currently do not have any command line argument passing as part of their integration.
+NOTE! Not all tools that Slang uses downstream make command line argument parsing available. `FXC` and `GLSLANG` currently do not have any command line argument passing as part of their integration, although this could change in the future.
-The `-X` mechanism is also supported by render-test tool. In this usage `slang` becomes a downstream tool. Thus you can use the DXC option `-Gfa` in a render-test via
+The `-X` mechanism is also supported by render-test tool. In this usage `slang` becomes a downstream tool. Thus you can use the `dxc` option `-Gfa` in a render-test via
```
-Xslang... -Xdxc -Gfa -X.
```
+Means that the dxc compilation in the render test (assuming dxc is invoked) will receive
+
+```
+-Gfa
+```
### Specifying where dlls/shared libraries are loaded from
@@ -217,11 +240,19 @@ On windows if you want a dll loaded from a specific path, the path must be speci
On linux it's similar, but any path (relative or not) will override the regular search mechanism. See *'dlopen'* for more details.
-* `-dxc-path`: Sets the path where dxc dlls are loaded from (dxcompiler.dll & dxil).
+* `-dxc-path`: Sets the path where dxc dll/shared libraries are loaded from (dxcompiler & dxil).
* `-fxc-path`: Sets the path where fxc dll is loaded from (d3dcompiler_47.dll).
-* `-glslang-path`: Sets where the slang specific 'slang-glslang' is loaded from
+* `-glslang-path`: Sets where the Slang specific 'slang-glslang' is loaded from
+
+Paths can specify a directory that holds the appropriate binaries. It can also be used to name a specific downstream binary - be it a shared library or an executable. Note that if it is a shared library, it is not necessary to provide the full filesystem name - just the path and/or name that will be used to load it. For example on windows `fxc` can be loaded from `D:/mydlls` with
+
+* `D:/mydlls' - will look for `d3dcompiler_47.dll` in this directory
+* `D:/mydlls/d3dcompiler_47` - it's not necessary to specify .dll to load a dll on windows
+* `D:/mydlls/d3dcompiler_47.dll` - it is also possible name the shared library explicitly for example
+
+That if you name the shared library/executable you can use a name other than the default for a specific version, for example by using `D:/mydlls/dxcompiler-some-version` for a specific version of `dxc`.
Limitations
-----------
diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp
index 0fc7958d0..fe32c93b1 100644
--- a/source/slang/slang-type-layout.cpp
+++ b/source/slang/slang-type-layout.cpp
@@ -369,6 +369,8 @@ struct HLSLConstantBufferLayoutRulesImpl : DefaultLayoutRulesImpl
}
};
+/* CPU layout requires that all sizes are a multiple of alignment.
+*/
struct CPULayoutRulesImpl : DefaultLayoutRulesImpl
{
typedef DefaultLayoutRulesImpl Super;
@@ -385,6 +387,7 @@ struct CPULayoutRulesImpl : DefaultLayoutRulesImpl
return SimpleLayoutInfo( LayoutResourceKind::Uniform, 1, 1 );
}
+ // This always returns a layout where the size is the same as the alignment.
default: return Super::GetScalarLayout(baseType);
}
}
@@ -519,14 +522,7 @@ struct CUDALayoutRulesImpl : DefaultLayoutRulesImpl
// Nothing is aligned more than 16
alignment = std::min(alignment, size_t(16));
- // TODO(JS): It's not 100% clear what is right in terms of size in respect of *alignment*. If the size is the 'used' bytes, then
- // it can be less that the aligned size. If that's the case the GetArrayLayout (and MatrixLayout) is *wrong* in that on the last element
- // it uses the size (not the aligned size/stride).
- //
- // Here I am assuming it's reasonable for the size to be the aligned size. That being the case the GetArrayLayout/GetMatrixLayout will be
- // correct without special handling.
- //
- // The assert below checks that is indeed the case.
+ // For CUDA the size must be a multiple of alignment, as this is the amount of bytes used 'exclusively' by the type.
// The size must be a multiple of the alignment
SLANG_ASSERT(_isAligned(size, alignment));
diff --git a/source/slang/slang-type-layout.h b/source/slang/slang-type-layout.h
index be7ccdf8f..8c50b4eb3 100644
--- a/source/slang/slang-type-layout.h
+++ b/source/slang/slang-type-layout.h
@@ -251,6 +251,10 @@ struct SimpleLayoutInfo
LayoutResourceKind kind;
// How many resources of that kind?
+ //
+ // For uniform, the size is the number of bytes "reserved" exclusively for an instance of that type.
+ // In *general* it is not necessary for a size to be rounded up to the alignment. Some targets do
+ // though - for example C++ and CUDA targets always have size as a multiple of alignment.
LayoutSize size;
// only useful in the uniform case