summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-05-31 10:50:28 -0700
committerGitHub <noreply@github.com>2018-05-31 10:50:28 -0700
commit8d77db3c4e357329c8693457d37b99fc1f48a9f7 (patch)
treef8023402d286034072f2f10083e0a2e983352835 /source/slang/slang.cpp
parent8c593ae0d9894d79295a8e739ac9a33a0e149d4c (diff)
Add options to control matrix layout rules (#583)
* Add options to control matrix layout rules Up to this point, the Slang compiler has assumed that the default matrix layout conventions for the target API will be used. This means column-major layout for D3D, and *row major* layout for GL/Vulkan (note that while GL/Vulkan describe the default as "column major" there is an implicit swap of "row" and "column" when mapping HLSL conventions to GLSL). This commit introduces two main changes: 1. The default layout convention is switched to column-major on all targets, to ensure that D3D and GL/Vulkan can easily be driven by the same application logic. I would prefer to make the default be row-major (because this is the "obvious" convention for matrices), but I don't want to deviate from the defaults in existing HLSL compilers. 2. Command-line and API options are introduced for setting the matrix layout convention to use (by default) for each code generation target. It is still possible for explicit qualifiers like `row_major` to change the layout from within shader code. I also added an API to query the matrix layout convention that was used for a type layout (which should be of the `SLANG_TYPE_KIND_MATRIX` kind), but this isn't yet exercised. I added a reflection test case to make sure that the offsets/sizes we compute for matrix-type fields are appropriately modified by the flag that gets passed in. In a future change we could possibly switch the default convention to row-major, if we also changed our testing to match, since there are currently not many clients to be adversely impacted by the change. * Fixup: silence 64-bit build warning
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 3cb580f00..57f0e8917 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -952,6 +952,16 @@ SLANG_API void spSetTargetFlags(
req->targets[targetIndex]->targetFlags = flags;
}
+SLANG_API void spSetTargetMatrixLayoutMode(
+ SlangCompileRequest* request,
+ int targetIndex,
+ SlangMatrixLayoutMode mode)
+{
+ auto req = REQ(request);
+ req->targets[targetIndex]->defaultMatrixLayoutMode = Slang::MatrixLayoutMode(mode);
+}
+
+
SLANG_API void spSetOutputContainerFormat(
SlangCompileRequest* request,
SlangContainerFormat format)