https://github.com/shader-slang/slang
Revision a16f712bb99e426519c9a556b17b54bcc4d1d22d authored by Jay Kwak on 07 February 2024, 20:12:15 UTC, committed by GitHub on 07 February 2024, 20:12:15 UTC
* Implement basic GLSL built-in functions Partially resolves #3362 This change implemented GLSL build-in functions described in the following sections of "OpenGL Spec" document. 8.1. Angle and Trigonometry Functions 8.2. Exponential Functions 8.3. Common Functions 8.5. Geometric Functions 8.7. Vector Relational Functions 8.8. Integer Functions About 40 functions are newly implemented and about 150 functions were preexisted on HLSL side implementation. The implementation of new functions hasn't been tested yet. * Unify some of GLSL functions into hlsl.meta.slang Partially resoves #3362 This change moves Some of GLSL functions from glsl.meta.slang to hlsl.meta.slang, because those functions are generic enough to be used for HLSL. Those functions are: dot, normalize, fma, and reflect. There was "fma" for double in hlsl.meta.slang and it is converted to use __BuiltinFloatingPointType type, which required some modifications in diff.meta.slang. The implementation for "fma" in diff.meta.slang is very similar to how "mad" is implemented. * Implement more GLSL built-in functions Partially resolves #3362 This change implements more GLSL built-in functions mentioned in the following sections. 8.4. Floating-Point Pack and Unpack Functions 8.6. Matrix Functions This change implemented 11 new GLSL built-in functions and there were 3 already working functions. The mistake in "normalize" is fixed. "refract" function is moved from glsl.meta.slang to hlsl.meta.slang. * Implement basic GLSL built-in functions Partially resolves #3362 This change implemented GLSL build-in functions described in the following sections of "OpenGL Spec" document. 8.1. Angle and Trigonometry Functions 8.2. Exponential Functions 8.3. Common Functions 8.5. Geometric Functions 8.7. Vector Relational Functions 8.8. Integer Functions About 40 functions are newly implemented and about 150 functions were preexisted on HLSL side implementation. The implementation of new functions hasn't been tested yet. * Unify some of GLSL functions into hlsl.meta.slang Partially resoves #3362 This change moves Some of GLSL functions from glsl.meta.slang to hlsl.meta.slang, because those functions are generic enough to be used for HLSL. Those functions are: dot, normalize, fma, and reflect. There was "fma" for double in hlsl.meta.slang and it is converted to use __BuiltinFloatingPointType type, which required some modifications in diff.meta.slang. The implementation for "fma" in diff.meta.slang is very similar to how "mad" is implemented. * Implement more GLSL built-in functions Partially resolves #3362 This change implements more GLSL built-in functions mentioned in the following sections. 8.4. Floating-Point Pack and Unpack Functions 8.6. Matrix Functions This change implemented 11 new GLSL built-in functions and there were 3 already working functions. The mistake in "normalize" is fixed. "refract" function is moved from glsl.meta.slang to hlsl.meta.slang. * Fix a few minor bugs on GLSL builtin functions Partially resovles #3362 Following bugs were addressed: 1. "bitCounts" had to have a "Capability" on its function declaration. 2. "roundEven" is implemented. It is almost same to "round()" but the behaivor is slightly different the given value is 1.5, 3.5, 5.5 and so on. 3. umulExtended and imulExtended are simplified. 4. exp2 is implemented with "__target_switch" for GLSL and SPIR-V. 5. "tests/glsl-intrinsic/intrinsic-basic.slang" checks the results from the GLSL functions. Currently it is mainly to test if the functions exist or not, but it can now also test for a simple case where the input value is zero and the result is most of the time zero or one. * Disable GLSL exp2 double type tests This change disables some of GLSL exp2 related tests as a workaround. The spir-v needs to handle the double-type argument for exp2 properly. * Fix exp2(double) problem for SPIR-V SPIR-V can handle a double-type input for exp2 with this change. However, the slang-test is will failing to test it with an error message saying, "abort compilation:". With a simpler test case, I verified that SPIR-V assembly code is properly generated for exp2(double) and I am not sure why slang-test is still failing. We will need to revisit this issue later. The simple testing is done with a following line: outputBuffer.result[0] = float(exp2(double(outputBuffer.result[0]))); And it generated following lines and it looks correct: ; Function main %main = OpFunction %void None %3 %5 = OpLabel %16 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0 %17 = OpLoad %float %16 %19 = OpFConvert %double %17 %20 = OpFConvert %float %19 %21 = OpExtInst %float %1 Exp2 %20 %22 = OpAccessChain %_ptr_Uniform_float %outputBuffer_0 %int_0 %uint_0 OpStore %22 %21 OpReturn OpFunctionEnd * Add __floatCast that is safer than slang_noop_cast Adding __floatCast that can be used for exp2 function.
1 parent a95b753
Tip revision: a16f712bb99e426519c9a556b17b54bcc4d1d22d authored by Jay Kwak on 07 February 2024, 20:12:15 UTC
Implement basic GLSL built-in functions (#3525)
Implement basic GLSL built-in functions (#3525)
Tip revision: a16f712
File | Mode | Size |
---|---|---|
.github | ||
build | ||
cmake | ||
deps | ||
docs | ||
examples | ||
external | ||
extras | ||
prelude | ||
source | ||
tests | ||
tools | ||
.editorconfig | -rw-r--r-- | 984 bytes |
.gitattributes | -rw-r--r-- | 95 bytes |
.gitignore | -rw-r--r-- | 1.5 KB |
.gitmodules | -rw-r--r-- | 1.2 KB |
.mailmap | -rw-r--r-- | 84 bytes |
CMakeLists.txt | -rw-r--r-- | 19.3 KB |
CMakePresets.json | -rw-r--r-- | 4.0 KB |
CODE_OF_CONDUCT.md | -rw-r--r-- | 3.1 KB |
CONTRIBUTION.md | -rw-r--r-- | 10.0 KB |
LICENSE | -rw-r--r-- | 1.1 KB |
README.md | -rw-r--r-- | 7.3 KB |
github_build.sh | -rw-r--r-- | 1.3 KB |
github_macos_build.sh | -rw-r--r-- | 1.2 KB |
github_test.sh | -rw-r--r-- | 1.1 KB |
make-slang-tag-version.bat | -rw-r--r-- | 210 bytes |
premake.bat | -rw-r--r-- | 120 bytes |
premake5.lua | -rw-r--r-- | 65.4 KB |
slang-com-helper.h | -rw-r--r-- | 4.9 KB |
slang-com-ptr.h | -rw-r--r-- | 5.0 KB |
slang-gfx.h | -rw-r--r-- | 87.6 KB |
slang-tag-version.h | -rw-r--r-- | 36 bytes |
slang.h | -rw-r--r-- | 197.3 KB |
slang.sln | -rw-r--r-- | 51.5 KB |
test.bat | -rw-r--r-- | 1.4 KB |
test.ps1 | -rw-r--r-- | 154 bytes |
Computing file changes ...