summaryrefslogtreecommitdiffstats
path: root/source/core/slang-random-generator.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-03-02 12:52:34 -0800
committerGitHub <noreply@github.com>2021-03-02 12:52:34 -0800
commitb81e8d4c8b718e97c6d6fc65b09850f19fb80502 (patch)
treebc8d7100a53633abab5b659686ba597a56f0a680 /source/core/slang-random-generator.cpp
parent837a155b3d33035ee0739858f4ab25c65048ad6c (diff)
Add command-line control over SPIR-V version (#1730)
* Add command-line control over SPIR-V version By default the Slang compiler policy is usually to produce output with the fewest dependencies possible. If input code can be encoded as SPIR-V 1.0, that is what we will use by default. The catch here is that in some cases later SPIR-V versions introduced improvements to the encoding that can affect performance (e.g., around large global arrays of constants), so that a user might explicitly want to require a newer SPIR-V version (restricting the driver versions their code can work on) in the hopes of seeing better performance. This change uses the system of capabilities that was previously introduced so that an option like `-profile glsl_450+spirv_1_5` can be used to explicitly request a specific SPIR-V version. Consistent with the existing implementation, the requested version will be taken as a minimum, and the final version might be higher based on other requirements (e.g., use of intrinsic functions that require a higher version). The test case included here is a little iffy in terms of long-term maintanenace. It relies on having both a `.slang` file and a `.glsl` file that we compile with the same options and then compare the SPIR-V, but that means there is no direct testing that the output SPIR-V actually uses the necessary version. If we break the inference of SPIR-V versions for both the regular and pass-through paths at once, this test won't flag the problem. A better test is probably needed soon. This change *only* adds support for controlling the SPIR-V version via capabilities specified via the command line or API. It would be nice to a future change to allow something like `[require(spirv_1_5)]` to be added to an entry point function to allow the user to embed their expectation/requirement into the source code. * fixup: clang warning
Diffstat (limited to 'source/core/slang-random-generator.cpp')
-rw-r--r--source/core/slang-random-generator.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/source/core/slang-random-generator.cpp b/source/core/slang-random-generator.cpp
index ec06336f1..315678f0a 100644
--- a/source/core/slang-random-generator.cpp
+++ b/source/core/slang-random-generator.cpp
@@ -8,7 +8,7 @@ namespace Slang {
float RandomGenerator::nextUnitFloat32()
{
int32_t intValue = nextInt32();
- return (intValue & 0x7fffffff) * (1.0f / 0x7fffffff);
+ return (intValue & 0x7fffffff) * (1.0f / float(0x7fffffff));
}
bool RandomGenerator::nextBool()