| Age | Commit message (Collapse) | Author |
|
(#3881)
* Refactor memory qualifier decorators to be a bit-flag set.
replace GloballyCoherent, ReadOnly, WriteOnly, Volatile, and Restrict memory modifiers and decorations with a bit flag set to more efficiently manage memory qualifiers.
added `restrict` modifier to test to ensure the code works when dropping a `restrict` memory qualifier
* Refine tests & add SSBO memory qualifer support
add CHECK's to tests to ensure memory qualifiers emit as intended
added tests and changed code to ensure memory qualifiers work on SSBO objects (SPIR-V & GLSL)
* add memory qualifiers & fixes.
Add to StructuredBuffer & ByteAddressBuffer `ReadOnly`/NonWritable qualifier.
* Memory qualifiers must be decorated on a variable inst. Due to this the qualifier is added after `lowerStructuredBufferType`
Fixed an error where ReadOnly->NonReadable & WriteOnly->NonWritable
* Adjusted tests accordingly
Added back the removed `globallycoherent` memory qualifier emit'ing code in hlsl-emit (was incorrectly removed).
undo hlsl.meta changes
cleanup
|
|
The following PR implements 8.14-8.19 of the [OpenGL-GLSL specification](https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf).
Fully implements all functions and built-in type's, resolves https://github.com/shader-slang/slang/issues/3692 for GLSL & SPRI-V targets.
_Notes:_
Testing Tools:
* Fragment shaders cannot test computational results. Only OpCodes are checked for proper emitting.
Implementation Notes:
* SubpassInput requires an unknown image format.
* SubpassInput is disjoint from TextureType: __SubpassImpl (.slang) & SubpassInputType (Compiler) to reduce code generation required.
* SubpassInput required an additional input layout modifier, input_attachment_index, this was added as a new parameter binding attribute. Since the following qualifiers can overlap with different resources (`layout(input_attachment_index = 0, binding = 0, set = 0)`) input_attachment_index is checked for overlapping resource bindings separately from other qualifiers with `LayoutResourceKind::InputAttachmentIndex`.
* `GLSLInputAttachmentIndexLayoutModifier` was added to enforce function parameters only accepting `in` decorated variables.
* `in` decorated variables needed to have emitting modified to allow directly emitting the variable into function calls if used as a parameter, normally Slang has a "global variable" shadow as a "global parameter" through a copy. This does not work and is solved using `GlobalVariableShadowingGlobalParameterDecoration` to build a relationship of "global variable" to "global parameter", we then resolve this relationship and replace "global variable" uses later in compile.
* `AtomicCounterMemory` memory-constraint requires `OpCapability AtomicStorage`, `AtomicStorage` is invalid for Vulkan targets. glslang outputs for `barrier`, `memoryBarrier`, and `groupMemoryBarrier` `AtomicCounterMemory` as a memory constraint. This compiles as valid SPIR-V for Vulkan since `OpCapability AtomicStorage` is not declared. This behavior of glslang is undefined as per [3.31.Capability of the SPIR-V specification](https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_capability). We will omit `AtomicCounterMemory` from our barrier calls.
|
|
resolves #3587 for GLSL & SPIR-V targets #3631 (#3810)
* [early push of code since memory qualifiers may be made into a seperate branch & pr and I rather make it simple to split the implementation if required]
all type & functions impl. for GLSL image type
added all memory qualifiers & tests for direct read/write [GLSL syntax] (DID NOT test or implement parameter qualifiers, that is next commit)
* this inlcudes emit-glsl & emit-spirv for qualifier decorations
* this also includes error handling
* this includes parsing
* full implementation other than Rect; all errors and basic tests are done & working
what is left:
1. need to now add Rect type support (additional TextureImpl flag)
2. tests
3. testing infrastructure to support variety of types
* testing framework now works with images of all types and imageBuffers -- next steps are actual tests
* push code for mostly working image atomics; missing int64/uint64 tests and slightly broken feature
likley due to missing code from master which I pushed for regular atomics
* fix all remaining shader image atomic issues and tests to work with float & i64/u64 fully
will now clean up code and squash the commits (since they are quite all over the place)
* refactor code to work & look correct, fix all regressions
Turned off tests for texture format R64 due to the shader use limitation of currently being only for storage buffers on most hardware (test fail cause, this is not allowed)
Changed raygen.slang & nv-ray-tracing-motion-blur.slang since both cross-compiled with glslang, which does not respect layout(rgba8) for RWBuffer's, in this scenario making the type into a SPIR-V rgba32f, which is incorrect and a known problem, this causes different code to be outputted from Slang & HLSL+GLSL->Slang paths
Clean up all code and better explain the "why" for the gimageDim definition we use various strings of Slang code, the gist is:
1. Parameters are structured as per IMAGE_PARAM keyword in spec, and we respect this in order to match specification (to allow easy code iteration)
2. sample parameters are required for functions
3. types are inconsistently named
fixed regression of breaking l-value lowering when r-value should be lowered (lower-to-ir)
fix compiler warnings
remove unneeded lambdas
`expr->type.isLeftValue = isMutableGLSLBufferBlockVarExpr(baseExpr) && (expr->type.hasReadOnlyOnTarget == false);` is an adjustment made such that a buffer block is mutable only if the block is mutable and the base expression is mutable (to handle case of readonly buffer block, immutable)
* remove rectangle parameter
* use proper const syntax and struct naming
* adjust syntax
* adjust modifier capabilitites: HLSL+GLSL --> GLSL. Notice most specifically, if the parent is a global struct we can put a memory qualifier, this does not include, struct inside a struct, with a member variable with a memory qualifier (since then you could use the struct in invalid ways). Added test for struct inside struct with member variable with memory qualifier.
adjust syntax and remove code which will rot
* adjust formatting for consistency
* addressing review feedback
addressing review feedback:
change testing code to handle int and float/half correctly in all cases
adjust testing code syntax as requested
change vkdevice code to fit a different form as requested
* adjust code as per requested for review:
1. adjusted testing code logic to handle non 0-1 values appropriately, notice int8_t will likley be the range and set order of {[0,127],[-1,-128]}, this is intentional
2. syntax adjustments for correctness
* trying to fix falcor regressions
* add back removed code for regression testing
* test removing changes which may break falcor
* Revert "test removing changes which may break falcor"
This reverts commit 240da97f06c23e98a26ac23cf1d385995c67b251.
* disable R64 support in attempt to fix falcor tests
* Revert "disable R64 support in attempt to fix falcor tests"
This reverts commit 317cb632eb2f47e980fc4aeafe418f8060f4c473.
* disable major device changes (still trying to figure out falcor fails -- locally working different than CI)
* test removing d3d changes
* remove all format changes
* add back removed code for regression testing
* try something to get code to work with falcor
* address review
* Add way to handle constref/ref/encapsulated texture objects with memory qualifiers as a parameter.
Fixed an issue (and improved codegen) for when we have a store(dst,load(src)) pattern, where dst is supposed to be equal to src for when resolving globalParam's (no need for work-arounds anymore)
* move recent-fix/change to textureType loading into a proper optimization pass which now runs after SPIR-V legalization to catch odd SPIR-V emitting after legalizing types for SPIR-V
* Revert most recent optimization pass change, add work around getting a unmangled global parameter address through a intrinsic op instead of spir-v intrinsic (works same as `__imagePointer()`)
* remove unneeded changes
* remove unneeded `__constref` in glsl.meta
* move memory qualifier checks to visitInvoke of check-expr.cpp
move GetLegalizedSPIRVGlobalParamAddr resolving to spirv-legalization pass
move error for "if using non texture type with memory qualifer in param" earlier such that we error with this first. No point in telling user "you are not putting correct memory qualifiers" when memory qualifiers should not have been used.
* add memory qualifier folding modifier 'MemoryQualifierCollectionModifier' to reduce searching and processing (later will be adapted to whole system) as suggested/asked.
The utility is a method to track memory qualifiers without doing a expensive linked-list traversal (image's have 4 modifiers normally).
* properly pass multiple qualifiers from checkModifier down to the `modifier`s list
* addressing review comments:
* change implementation to properly handle restrict modifier
* add comments about implementation for clarity
|
|
(#3675)
The following PR implements raytracing extensions (GLSL_EXT_ray_tracing, GLSL_EXT_ray_query, GLSL_NV_shader_invocation_reorder & GLSL_NV_ray_tracing_motion_blur); for GLSL & SPIR-V targets. Fully implements all functions, built-in variables, & syntax; resolves #3560 for GLSL & SPIR-V Targets.
notes of worth:
* __rayPayloadFromLocation, __rayAttributeFromLocation, and __rayCallableFromLocation, were added as SPIR-V Intrinsics to refer to location's of raytracing objects in SPIR-V for when using GLSL syntax.
|
|
extension(s); resolves #3587 for GLSL & SPIR-V targets (#3755)
The following commit implements atomic operations & types associated with OpenGL 4.6, GL_EXT_vulkan_glsl_relaxed, GLSL_EXT_shader_atomic_float, GLSL_EXT_shader_atomic_float2, for GLSL & SPIR-V targets.
Fully implements all functions, and built-in type's, resolves https://github.com/shader-slang/slang/issues/3560 for GLSL & SPRI-V targets.
[Atomic extensions for GLSL can be found here](https://github.com/KhronosGroup/GLSL/tree/main)
Notes of worth:
* atomic_uint is well defined in GLSL->OpenGL, although was removed in GLSL->VK unless a compiler extension is supported (GL_EXT_vulkan_glsl_relaxed). This support entails transforming all atomic_uint operations and references into a storage buffer. SPIR-V has AtomicCounter+AtomicStorage (atomic_uint parallel) but does not implement these capabilities for SPIR-V->VK in any scenario. Due to the case we transform atomic_uint ourselves (GLSL_Syntax->Slang_IR) to accommodate transforming atomic_uint into valid syntax.
* GLSL_EXT_shader_atomic_float2 (all float16_t & some float/double operations) support is minimal and worth watching out for if enabling the tests.
|
|
* Implement short-circuit logic operator
Implement short-circuit evaluation for logic && and ||
operator.
The short-circuit behavior is only used when the operands
involved are scalar and the parent function is non-differentiable.
In implementation, we define a new class 'LogicOperatorShortCircuitExpr'
derived from 'OperatorExpr'. In the visitInvoke() call, we will create
a new expression object 'LogicOperatorShortCircuitExpr' if the
expression is logic && or ||. So that we can generate new IR code in the
new visit function 'visitLogicOperatorShortCircuitExpr' to implement the
short-circuit behavior.
Add new test to test the short-circuit behavior.
* Fix an compile issue occurred in Falcon test
Previously, we early return when at least one of the operands of
"&&" or "||" is vector in convertToLogicOperatorExpr call. However,
in that case the arguments involved in the expression have already been
type checked. When it falls-back to 'visitInvokeExpr', it will check
the arguments again, and some unexpected behavior could occur
which could in turn cause some internal error.
So we add a check in the 'visitInvokeExpr' to avoid double type checking
of arguments.
* Update glsl subgroup test to not use short-circuit
Since the short-circuit evaluation could cause the threads
diverging in subgroup intrinsics. So change the test to not
using "&&" to chain those subgroup intrinsics together. Instead,
using "&" to chain them together because those test functions have
the return value as bool.
* Disable short-circuit in few situations
Disable short-circuit in following situations:
1. generic parameter list
2. static const varible initialization
* Use a flag to indicate the enablement of short-circuit
Instead of using a struct to indicate the state of the outer
environment of current expression, use a simple bool flag to
indicate whether or not apply the short-circuit to current
expression because there few situations where we will disable
short-circuiting and in those circumstances, there is no nested.
Therefore, a flag is good enough to indicate the case.
* Disable short-circuit in index expression
Also fix the build issue. (A cleanup for the last change.)
* check both 'static' and 'const' modifiers
Previously we only check HLSLStaticModifier to decide whether or
not using short-circuit, but we really should check both 'static'
and 'const' modifiers together, because we only want to disable
the short circuit for init expression for 'static const' variable.
* relax the restriction of short-circuit for index expression
Disable the short-circuit for index expression only when declare
an array.
* Simplify the logic by creating subVisitor
Simplify the logic by create a sub expression visitor so
that we don't need to introduce extra recursion.
* Call convertToLogicOperatorExpr after args check
Change to call convertToLogicOperatorExpr after arguments
check in visitInvokeExpr such that we don't have to check
whether the arguments checked to avoid the double checking
issue.
|
|
(#3580)
* Partially Implement with tests, functions and built-in variables apart of GL_KHR_shader_subgroup; Partially resolves #3548
Partially Implement with tests, functions and built-in variables apart of GL_KHR_shader_subgroup; Partially resolves #3548
GL_KHR_shader_subgroup implemented based on https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt
Implementation is broken down into seperate glsl extensions due to the ***large differences*** in implementation of each section, and functionality/testing.
GL_KHR_shader_subgroup_basic{
**Partially implemented**
Implementation:
* All 9 built-in variables have been stubbed without proper value; implementation is still required for these system variables; related to #411.
* Functions were reimplemented despite nearly mirrored HLSL functions due to:
* hlsl.meta implementations targetting workgroups rather than a warp/wave/subgroup:
* `__syncwarp` vs `__syncthreads`
* `SubgroupMemory` vs `WorkgroupMemory`
* etc.
* hlsl.meta implementations target broader SPIR-V memory targets to block on:
* ImageMemory|UniformMemory versus SPIR-V specifying barriers for ImageMemory and seperately an option for UniformMemory
* `subgroupElect` for CUDA has a different implementation than `WaveIsFirstLane`, this is because spec states that `subgroupElect()` only returns the lowest active gl_SubgroupInvocationID; therefore we are supposed to fetch the current active mask even if some invocations are turned off by branches
Testing:
tests for the variable -- `tests/glsl/shader-subgroup-built-in-variables.slang`
* these tests do not test functionality since not implemented yet
tests for the functions -- `tests/glsl/shader-subgroup-basic.slang`
* concurrency is tested for using SubgroupMemory, UniformMemory through attempting to create a GPU side race condition with writing and reading memory
* due to testing tools avaible there are no tests for ImageMemory
* subgroupElect is tested to return invocation #0, the lowest invocation that will always run; wave size is 32, therefore #0 is always active and will always be the elected invocation.
}
GL_KHR_shader_subgroup_vote{
**Fully implemented**
Implementation:
* 3/3 functions are using the hlsl.meta implementation
Testing:
`tests/glsl/shader-subgroup-vote.slang`
* Testing each a positive (returns true) and negative (returns false) test case to ensure vote results are correct
}
GL_KHR_shader_subgroup_ballot{
**Partially implemented**
Implementation:
There are 10/10 functions that are implemented:
* 3 are using hlsl.meta implementation
* 7 are using new implementations -- only support GLSL, SPIR-V, HLSL, CUDA
* These implementations do not exist in hlsl.meta, so they were added
* `subgroupInverseBallot` lacks an analog function to call; this feature was emulated:
* in CUDA through knowing waves are 32bit and lanes are 0 indexed, this implys that ` (ballotResult >> YOUR_INVOCATION) & 1` checks if your invocation is active, for example, `(0b11001 >> 3) & 1` would mean that only invocation 5, 4, and 1 is active, 3 would mean `YOUR_INVOCATION` is the fourth invocation in the subgroup. `(0b11001>>3) & 1` would return true since your bit is toggled and evaluates to `0b11 & 0b1`
* in HLSL through testing if the wave count is 32 or less (use the same logic as CUDA in this case); else find the index `YOUR_INVOCATION` corrisponds with where each vector has 32bits (32 waves); avoid division in the process. then run the same algorithm cuda employs.
* `subgroupBallotBitExtract` is logically the same as `subgroupInverseBallot`
* 5 implementations do not have a CUDA, HLSL, and CPP imlementation yet (subgroupBallotFindMSB, subgroupBallotFindLSB, subgroupBallotExclusiveBitCount, subgroupBallotInclusiveBitCount, subgroupBallotBitCount) due to being out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-ballot.slang`
* the function tests for an expected value of each ballot function; tests try inputting larger than 32 toggled bits as function parameters to ensure the implementation correctly identifies values up to a maximum of the subgroup invocation count as per extension specification (otherwise the functionality is fairly trivial to test)
}
GL_KHR_shader_subgroup_arithmetic{
**Partially implemented**
Implementation:
* There are 21 functions to implement:
* 14 functions are using the hlsl.meta implementation
* 7 functions are new implementations -- only implemented for GLSL and SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
* CUDA, CPP, HLSL are out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-arithmetic.slang`
* all tests silently kill the shader; outputted GLSL was checked, could not see an issue
* these tests only check basic functionality and correctness of all functions implemented; not an exaustive test [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_shuffle{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* 1 function is using the existing hlsl.meta implmentation
* 1 function is using a new implmentation (subgroupShuffleXor) -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle.slang`
* these tests only check basic functionality and correctness of all functions implemented; not an exaustive test [further continued in "Other notes of worthy" at end of commit]
* tests fail with cpp due to `kIROp_WaveGetActiveMask` failing to be called
}
GL_KHR_shader_subgroup_shuffle_relative{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* all 2 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-relative.slang`
* these tests only check basic functionality and correctness of all functions implemented; not an exaustive test [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_clustered{
**Partially implemented**
Implementation:
* There are 7 functions to implement:
* all 7 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-clustered.slang`
* these tests only check basic functionality and correctness of all functions implemented; not an exaustive test [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_quad{
**Partially implemented**
Implementation:
* There are 4 functions to implement:
* all 4 functions are using hlsl.meta implmentations -- only implemented for GLSL & SPIR-V & HLSL
Testing:
`tests/glsl/shader-subgroup-shuffle-quad.slang`
* these tests only check basic functionality and correctness of all functions implemented; not an exaustive test [further continued in "Other notes of worthy" at end of commit]
}
---------
Failing tests and why:
Note: due to system variables not being implemented largly for CUDA and CPP, these tests will fail (#3 and #4){
tests/glsl/shader-subgroup-arithmetic.slang.3
tests/glsl/shader-subgroup-arithmetic.slang.4
tests/glsl/shader-subgroup-ballot.slang.4
tests/glsl/shader-subgroup-basic.slang.3
tests/glsl/shader-subgroup-basic.slang.4
tests/glsl/shader-subgroup-quad.slang.3
tests/glsl/shader-subgroup-quad.slang.4
tests/glsl/shader-subgroup-vote.slang.3
tests/glsl/shader-subgroup-vote.slang.4
}
Note: due to kIROp_WaveGetActiveMask not being loaded for cpp the following test will fail{
tests/glsl/shader-subgroup-shuffle.slang.4
}
Note: due to a unknown silent error the following will fail [could not spot an error in the generated glsl and spir-v]{
tests/glsl/shader-subgroup-arithmetic.slang.5 (vk)
tests/glsl/shader-subgroup-arithmetic.slang.6 (vk)
}
Other notes of worthy:{
* only a few types are checked currently in tests due to equality templates not allowing freely casting to int/uint, meaning to test types en-mass is not trivial and will most likley be completly replaced once templates can cast & check equality more freely.
* did not implement vector types for any functions that may use them (mostly in reference to SPIR-V, since many may accept scalar or vector inputs); applicable to subgroup-shuffle, subgroup-shuffle-relative, subgroup-arithmetic, subgroup-shuffle, subgroup_clustered, subgroup_quad
* did not implement checks for half floats
* CUDA, CPP, HLSL implementations were largly out of scope and if not implemented, this is due to the implementation not being trivial
}
Random fixes encountered:{
* hlsl.meta incorrectly sets `OpCapability` as `GroupNonUniformBallot` when the `OpCapability` should be `GroupNonUniformVote`; this is as per SPIR-V spec for all SPIR-V calls used in `GL_KHR_shader_subgroup_vote`: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpGroupNonUniformAll
}
* added vector types and tests;
Partially Implement with tests, functions and built-in variables apart of GL_KHR_shader_subgroup; Partially resolves #3548
GL_KHR_shader_subgroup implemented based on https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt
GL_KHR_shader_subgroup_* & GLSL ref:
* https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt
* https://www.khronos.org/blog/vulkan-subgroup-tutorial
* https://www.khronos.org/assets/uploads/developers/library/2018-vulkan-devday/06-subgroups.pdf
HLSL ref:
* https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-intrinsic-functions
* https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics
CUDA ref:
* https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html
SPIR-V ref:
* https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_memory_semantics_id
Implementation is broken down into seperate glsl extensions due to the ***large differences*** in implementation of each section, and functionality/testing.
GL_KHR_shader_subgroup_basic{
**Partially implemented**
Implementation:
* All 9 built-in variables have been stubbed without proper value; implementation is still required for these system variables; related to #411.
* Functions were reimplemented despite nearly mirrored HLSL functions due to:
* hlsl.meta implementations targetting workgroups rather than a warp/wave/subgroup:
* `__syncwarp` vs `__syncthreads`
* `SubgroupMemory` vs `WorkgroupMemory`
* etc.
* hlsl.meta implementations target broader SPIR-V memory targets to block on:
* ImageMemory|UniformMemory versus SPIR-V specifying barriers for ImageMemory and seperately an option for UniformMemory
* `subgroupElect` for CUDA has a different implementation than `WaveIsFirstLane`, this is because spec states that `subgroupElect()` only returns the lowest active gl_SubgroupInvocationID; therefore we are supposed to fetch the current active mask even if some invocations are turned off by branches
Testing:
tests for the variable -- `tests/glsl/shader-subgroup-built-in-variables.slang`
* these tests do not test functionality since not implemented yet
tests for the functions -- `tests/glsl/shader-subgroup-basic.slang`
* concurrency is tested for using SubgroupMemory, UniformMemory through attempting to create a GPU side race condition with writing and reading memory
* due to testing tools avaible there are no tests for ImageMemory
* subgroupElect is tested to return invocation #0, the lowest invocation that will always run; wave size is 32, therefore #0 is always active and will always be the elected invocation.
}
GL_KHR_shader_subgroup_vote{
**Fully implemented**
Implementation:
* 3/3 functions are using the hlsl.meta implementation
Testing:
`tests/glsl/shader-subgroup-vote.slang`
* Testing each a positive (returns true) and negative (returns false) test case to ensure vote results are correct
}
GL_KHR_shader_subgroup_ballot{
**Partially implemented**
Implementation:
There are 10/10 functions that are implemented:
* 3 are using hlsl.meta implementation
* 7 are using new implementations -- only support GLSL, SPIR-V, HLSL, CUDA
* These implementations do not exist in hlsl.meta, so they were added
* `subgroupInverseBallot` lacks an analog function to call; this feature was emulated:
* in CUDA through knowing waves are 32bit and lanes are 0 indexed, this implys that ` (ballotResult >> YOUR_INVOCATION) & 1` checks if your invocation is active, for example, `(0b11001 >> 3) & 1` would mean that only invocation 5, 4, and 1 is active, 3 would mean `YOUR_INVOCATION` is the fourth invocation in the subgroup. `(0b11001>>3) & 1` would return true since your bit is toggled and evaluates to `0b11 & 0b1`
* in HLSL through testing if the wave count is 32 or less (use the same logic as CUDA in this case); else find the index `YOUR_INVOCATION` corrisponds with where each vector has 32bits (32 waves); avoid division in the process. then run the same algorithm cuda employs.
* `subgroupBallotBitExtract` is logically the same as `subgroupInverseBallot`
* 5 implementations do not have a CUDA, HLSL, and CPP imlementation yet (subgroupBallotFindMSB, subgroupBallotFindLSB, subgroupBallotExclusiveBitCount, subgroupBallotInclusiveBitCount, subgroupBallotBitCount) due to being out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-ballot.slang`
* the function tests for an expected value of each ballot function; tests try inputting larger than 32 toggled bits as function parameters to ensure the implementation correctly identifies values up to a maximum of the subgroup invocation count as per extension specification (otherwise the functionality is fairly trivial to test)
}
GL_KHR_shader_subgroup_arithmetic{
**Partially implemented**
Implementation:
* There are 21 functions to implement:
* 14 functions are using the hlsl.meta implementation
* 7 functions are new implementations -- only implemented for GLSL and SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
* CUDA, CPP, HLSL are out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-arithmetic.slang`
* all tests silently kill the shader; outputted GLSL was checked, could not see an issue
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_shuffle{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* 1 function is using the existing hlsl.meta implmentation
* 1 function is using a new implmentation (subgroupShuffleXor) -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
* tests fail with cpp due to `kIROp_WaveGetActiveMask` failing to be called
}
GL_KHR_shader_subgroup_shuffle_relative{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* all 2 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-relative.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_clustered{
**Partially implemented**
Implementation:
* There are 7 functions to implement:
* all 7 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-clustered.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_quad{
**Partially implemented**
Implementation:
* There are 4 functions to implement:
* all 4 functions are using hlsl.meta implmentations -- only implemented for GLSL & SPIR-V & HLSL
Testing:
`tests/glsl/shader-subgroup-shuffle-quad.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
---------
Failing tests and why:
Note: test numbers are assuming none of the existing tests are toggled off
Note: due to system variables not being implemented largly for CUDA and CPP, these tests will fail (#3 and #4){
tests/glsl/shader-subgroup-arithmetic.slang.3
tests/glsl/shader-subgroup-arithmetic.slang.4
tests/glsl/shader-subgroup-ballot.slang.4
tests/glsl/shader-subgroup-basic.slang.3
tests/glsl/shader-subgroup-basic.slang.4
tests/glsl/shader-subgroup-quad.slang.3
tests/glsl/shader-subgroup-quad.slang.4
tests/glsl/shader-subgroup-vote.slang.3
tests/glsl/shader-subgroup-vote.slang.4
}
Note: due to kIROp_WaveGetActiveMask not being loaded for cpp the following test will fail{
tests/glsl/shader-subgroup-shuffle.slang.4
tests/glsl/shader-subgroup-shuffle-relative.slang.4
tests/glsl/shader-subgroup-basic.slang.4
}
Note: due to a unknown silent error the following will fail [could not spot an error in the generated glsl and spir-v]{
tests/glsl/shader-subgroup-arithmetic.slang.5 (vk)
tests/glsl/shader-subgroup-arithmetic.slang.6 (vk)
}
Other notes of worthy:{
* only a few types are checked currently in arithmetic test; this is due to the test silently failing, meaning I can't actually test anything implemented
* did not implement checks for half floats
* CUDA, CPP, HLSL implementations were largly out of scope and not implemented, this is due to the implementation being non trivial for many functions
}
Random fixes encountered:{
* hlsl.meta incorrectly sets `OpCapability` as `GroupNonUniformBallot` when the `OpCapability` should be `GroupNonUniformVote`; this is as per SPIR-V spec for all SPIR-V calls used in `GL_KHR_shader_subgroup_vote`: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpGroupNonUniformAll
}
* Partially Implement with tests, functions and built-in variables apart of GL_KHR_shader_subgroup; Partially resolves #3548
Partially Implement with tests, functions and built-in variables apart of GL_KHR_shader_subgroup; Partially resolves #3548
GL_KHR_shader_subgroup implemented based on https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt
GL_KHR_shader_subgroup_* & GLSL ref:
* https://github.com/KhronosGroup/GLSL/blob/main/extensions/khr/GL_KHR_shader_subgroup.txt
* https://www.khronos.org/blog/vulkan-subgroup-tutorial
* https://www.khronos.org/assets/uploads/developers/library/2018-vulkan-devday/06-subgroups.pdf
HLSL ref:
* https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-intrinsic-functions
* https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics
CUDA ref:
* https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html
SPIR-V ref:
* https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_memory_semantics_id
Implementation is broken down into seperate glsl extensions due to the ***large differences*** in implementation of each section, and functionality/testing.
GL_KHR_shader_subgroup_basic{
**Partially implemented**
Implementation:
* All 9 built-in variables have been stubbed without proper value; implementation is still required for these system variables; related to #411.
* Functions were reimplemented despite nearly mirrored HLSL functions due to:
* hlsl.meta implementations targetting workgroups rather than a warp/wave/subgroup:
* `__syncwarp` vs `__syncthreads`
* `SubgroupMemory` vs `WorkgroupMemory`
* etc.
* hlsl.meta implementations target broader SPIR-V memory targets to block on:
* ImageMemory|UniformMemory versus SPIR-V specifying barriers for ImageMemory and seperately an option for UniformMemory
* `subgroupElect` for CUDA has a different implementation than `WaveIsFirstLane`, this is because spec states that `subgroupElect()` only returns the lowest active gl_SubgroupInvocationID; therefore we are supposed to fetch the current active mask even if some invocations are turned off by branches
Testing:
tests for the variable -- `tests/glsl/shader-subgroup-built-in-variables.slang`
* these tests do not test functionality since not implemented yet
tests for the functions -- `tests/glsl/shader-subgroup-basic.slang`
* concurrency is tested for using SubgroupMemory, UniformMemory through attempting to create a GPU side race condition with writing and reading memory
* due to testing tools avaible there are no tests for ImageMemory
* subgroupElect is tested to return invocation #0, the lowest invocation that will always run; wave size is 32, therefore #0 is always active and will always be the elected invocation.
}
GL_KHR_shader_subgroup_vote{
**Fully implemented**
Implementation:
* 3/3 functions are using the hlsl.meta implementation
Testing:
`tests/glsl/shader-subgroup-vote.slang`
* Testing each a positive (returns true) and negative (returns false) test case to ensure vote results are correct
}
GL_KHR_shader_subgroup_ballot{
**Partially implemented**
Implementation:
There are 10/10 functions that are implemented:
* 3 are using hlsl.meta implementation
* 7 are using new implementations -- only support GLSL, SPIR-V, HLSL, CUDA
* These implementations do not exist in hlsl.meta, so they were added
* `subgroupInverseBallot` lacks an analog function to call; this feature was emulated:
* in CUDA through knowing waves are 32bit and lanes are 0 indexed, this implys that ` (ballotResult >> YOUR_INVOCATION) & 1` checks if your invocation is active, for example, `(0b11001 >> 3) & 1` would mean that only invocation 5, 4, and 1 is active, 3 would mean `YOUR_INVOCATION` is the fourth invocation in the subgroup. `(0b11001>>3) & 1` would return true since your bit is toggled and evaluates to `0b11 & 0b1`
* in HLSL through testing if the wave count is 32 or less (use the same logic as CUDA in this case); else find the index `YOUR_INVOCATION` corrisponds with where each vector has 32bits (32 waves); avoid division in the process. then run the same algorithm cuda employs.
* `subgroupBallotBitExtract` is logically the same as `subgroupInverseBallot`
* 5 implementations do not have a CUDA, HLSL, and CPP imlementation yet (subgroupBallotFindMSB, subgroupBallotFindLSB, subgroupBallotExclusiveBitCount, subgroupBallotInclusiveBitCount, subgroupBallotBitCount) due to being out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-ballot.slang`
* the function tests for an expected value of each ballot function; tests try inputting larger than 32 toggled bits as function parameters to ensure the implementation correctly identifies values up to a maximum of the subgroup invocation count as per extension specification (otherwise the functionality is fairly trivial to test)
}
GL_KHR_shader_subgroup_arithmetic{
**Partially implemented**
Implementation:
* There are 21 functions to implement:
* 14 functions are using the hlsl.meta implementation
* 7 functions are new implementations -- only implemented for GLSL and SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
* CUDA, CPP, HLSL are out of scope for the commit
Testing:
`tests/glsl/shader-subgroup-arithmetic.slang`
* all tests silently kill the shader; outputted GLSL was checked, could not see an issue
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_shuffle{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* 1 function is using the existing hlsl.meta implmentation
* 1 function is using a new implmentation (subgroupShuffleXor) -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
* tests fail with cpp due to `kIROp_WaveGetActiveMask` failing to be called
}
GL_KHR_shader_subgroup_shuffle_relative{
**Partially implemented**
Implementation:
* There are 2 functions to implement:
* all 2 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-relative.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_clustered{
**Partially implemented**
Implementation:
* There are 7 functions to implement:
* all 7 functions are using a new implmentation -- only implmented for GLSL & SPIR-V
* GLSL & SPIR-V both use their related functions, no emulation required
Testing:
`tests/glsl/shader-subgroup-shuffle-clustered.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
GL_KHR_shader_subgroup_quad{
**Partially implemented**
Implementation:
* There are 4 functions to implement:
* all 4 functions are using hlsl.meta implmentations -- only implemented for GLSL & SPIR-V & HLSL
Testing:
`tests/glsl/shader-subgroup-shuffle-quad.slang`
* these tests only check basic functionality and correctness of all functions implemented; [further continued in "Other notes of worthy" at end of commit]
}
---------
Failing tests and why:
Note: test numbers are assuming none of the existing tests are toggled off
Note: due to system variables not being implemented largly for CUDA and CPP, these tests will fail (#3 and #4){
tests/glsl/shader-subgroup-arithmetic.slang.3
tests/glsl/shader-subgroup-arithmetic.slang.4
tests/glsl/shader-subgroup-ballot.slang.4
tests/glsl/shader-subgroup-basic.slang.3
tests/glsl/shader-subgroup-basic.slang.4
tests/glsl/shader-subgroup-quad.slang.3
tests/glsl/shader-subgroup-quad.slang.4
tests/glsl/shader-subgroup-vote.slang.3
tests/glsl/shader-subgroup-vote.slang.4
}
Note: due to kIROp_WaveGetActiveMask not being loaded for cpp the following test will fail{
tests/glsl/shader-subgroup-shuffle.slang.4
tests/glsl/shader-subgroup-shuffle-relative.slang.4
tests/glsl/shader-subgroup-basic.slang.4
}
Other notes of worthy:{
* added preamble function and macros for implementing subgroup functionality (and tests) to make it possible to iterate on the functionality with reasonable effort in the future
* CUDA, CPP, HLSL implementations were largly out of scope and not implemented, this is due to the implementation being non trivial for many functions
* doubles cause a silent crash on most subgroup functions tested (silent shader hang)
* __requireGLSLExtension does not work as intended inside glsl.meta; as a result half, int16, int64 int8, all are ommited from testing
}
Random fixes encountered:{
* hlsl.meta incorrectly sets `OpCapability` as `GroupNonUniformBallot` when the `OpCapability` should be `GroupNonUniformVote`; this is as per SPIR-V spec for all SPIR-V calls used in `GL_KHR_shader_subgroup_vote`: https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#OpGroupNonUniformAll
* hlsl.meta incorrectly uses for WaveMaskPrefixBitOr (SPIR-V) OpGroupNonUniformBitwiseAnd intead of OpGroupNonUniformBitwiseOr; this was fixed
}
* redesign tests under suggestions that they should be smaller, more maintainable, and test the most amount of data reasonabley possible (balance with fast iterations);
optional double testing
varying parameter testing
most tests chain results now
* fix missing impl and merge conflict resolutions
* reundant test code cleanup and organization
move tests to proper location (glsl-intrinsic)
clean up redundant code (input buffers)
* add missing logical operands support (and remove hlsl/cuda code reuse due to the functional differences) under all And, Or, Xor ops
redesign tests to conform to a better testing paradigm
* testing code style change to not use white space as a toggle for tests
* provided crash reason for doubles (intel iris gpu's crash in glsl with doubles due to missing support in device caps [as per vulkan validation layer)
uncommented the `__requireGLSLExtension` code so once it is fixed int16/8/64/half wil work with subgroup not requiring future intervention
* fixing some vk validation layer errors (OpMemoryBarrier, Shuffle operations)
modified style of tests; removed redundancy (extra code that does nothing); fixed some incorrect run targets; added error reasons for all encountered problems (and if needed, a #define/#if toggle)
* remove comments of important tests inplace of #define over the broken feature of extended shader_subgroup types
* removed macros inside glsl.meta
removed erroneous __target_switch to directly call hlsl.meta function
added elaboration on the problem with __requireGLSLExtension
changed WaveMaskPrefixBit[or|and|xor] to support the expected type of <int> only as per `HLSL Shader Model 6.5` specs
removed "precision highp" since it does not affect tests
* changes some hlsl.meta functions used to be more appropriate (as per suggested)
WaveMask -> WaveActive.*
WaveMaskPrefix.* -> WavePrefix.*
remove __target_switch case's for unimplemented case's of intrinsics
fix _getLaneId() being removed from some regex used earlier
* fix usage of __target_intrinsic instead of __intrinsic_asm; silently would cause only arguments to be emmitted as return
changed usage of `__requireGLSLExtension` because now it causes a crash from the missing intrinsic (instead of a silent error)
* fix shader subgroup extended types support for GLSL and SPIR-V:
1. seperate intrinsic/__requireGLSL generating functionality of shader_subgroup_preamble into child function calls due to otherwise `__requireGLSLExtension` being ignored if the calling function of shader_subgroup_preamble calls an `__intrinsic_asm`
2. fixed HLSL.meta logic for wave operations (Add, Mul, exclusiveAdd, exclusiveMul) to no longer cast the input type T into a uint due to cost-of-op & crash.
* Int8_t bit casted into uint32_t crashed the compiler. As per SPIR-V spec, OpGroupNonUniformI.* work on uint and int types meaning the function has no need to cast to a unit.
3. removed erroneous __target_switch for subgroupShuffle
* 1. ignore tests gracefully
2. remove un-needed SPIRV capability specifying (with OpCapability)
3. clean up structure of typeRequireChecks_shader_subgroup_GLSL
4. explain why HLSL/CUDA are not targeted for shader-subgroup-arithmetic.slang
* syntax changes + `property` declaration fix + builtin var glsl implementation + changed incorrect HLSL.meta assumptions
(#1)`property` declaration as *non member* implementation change/fix (all of the changes to `slang-lower-to-ir.cpp`)
using (#1), implemented subgroup builtin's for GLSL/SPIR-V; did not implement built'ins completly for HLSL/CUDA due to non trivial implementations. CPP has no implementation due to missing support of system values
changed some incorrect HLSL.meta subgroup implementation assumptions of type usage (bit casting 8bit->32bit, wrong capabilities causing errors)
dumping ast crash with spir-v when using builtin's fixed by adding the `builtin` spirv case (all of the changes to `slang-ast-dump.cpp`)
[ForceInline] addition to functions missing it
return instead of spirv_asm when empty blocks are used
* syntax & organization of tests adjustment (specifically how if'def's are managed)
* figuring out where ci fails
* figuring out where ci fails -- testing with enclusive & regular
* testing CI with exclusive, regular, inclusive
* remove unneeded white space
test CI inconsistency issues further with arithmetic.slang
* testing if the ci run fails due to some timeout/recovery issue
* split up arithmetic tests and push to test with CI
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|
|
* 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.
|
|
* Implement GLSL texture related built-in functions
Partially resolves #3362
This change implemented GLSL build-in functions described in the
following sections of "OpenGL Spec" document.
8.9.1. Texture Query Functions
8.9.2. Texel Lookup Functions
8.9.4. Texture Gather Functions
8.9.5. Compatibility Profile Texture Functions
About 200 functions are newly implemented.
Most of the functions are calling the HLSL implementation so they are
expected to work for all targets but they haven't been tested throughly
yet.
__TextureImpl got a new generic parameter, "isRectangle", to support
sampler2DRect and sampler2DRectShadow. It is a sampler for rectangular
texture with no mipmaps. For the reason, its "GetDimentions()" doesn't
return mip information. The sampling needs to happen in an integer
coordinate not in a normalized [0,1] range. but this hasn't been
implemenented yet.
Texture functions whose name include "Offset" takes an integer type
parameter and those values are required to be a compile-time constant.
However, our currentl implementation of slangc seems to make the values
not-compile-time constant. As a workaround, the test case uses __LINE__
macro to use a unique numbers so that slangc wouldn't collect them into
a runtime variable. I put "constexpr" on "offset" parameters as much as
possible. But the issue was still reproduced when targetting SPIRV.
Texture functions whose name include "Proj" are emulated by dividing the
coordinate value with its last component. For that reason, they take one
additional component for its coordinate value. As an example, following
function takes two components for sampler1D, instead of one:
vec4 textureProj(sampler1D sampler, vec2 p);
All shadow samplers stores depth-compare-value at the last component.
But sampler1DShadow take one extra component, which is vec3 not vec2.
It is unclear what the reason is but the second component is unused in
this case. Here is an example,
float texture(sampler1DShadow sampler, vec3 p);
samplerCubeArrayShadow takes five components for its coordinate and
the depth-compare-value cannot be stored in the last component of the
cooridnate. It is separated out as an independent parameter,
float texture(samplerCubeArrayShadow sampler, vec4 p, float compare);
TextureGather functions got some modifications. The existing
implementation was calling textureGatherOffset[s] with the parameters in
a wrong order. This mistake is corrected.
* Bring back GatherCmpRed/Green/Blue/Alpha
HLSL has GatherCmpRed/Green/Blue/Alpha functions and it was removed from
my previous change by a mistake.
This change brings them back.
* Disabling two failing tests in intrinsic-texture
The new test file, intrinsic-texture.slang, has five test settings and
two of them are currently failing; they are targetting HLSL and CPP.
This change disables them to avoid confusion.
* Remove "isRectangle" parameter from __TextureInfo
Partially resolves #3362
This commit has a few changes based on the feedback from the code
reviews.
1. Remove "isRectangle" parameter from __TextureInfo, because
"sampler2DRect" can be replaced with "sampler2D" that always uses
lod level 0. All functions associated to "Rect" are also removed.
2. Enabled tests for "samplerBuffer".
3. Removed "__target_intrinsic(glsl)" from glsl.meta.slang, because we
want to stay away from it in the future.
4. Some tests in intrinsic-texture.slang are disabled if the functions
take constant offset values or take MultiSample samplers.
---------
Co-authored-by: Yong He <yonghe@outlook.com>
|