diff options
| author | Jay Kwak <82421531+jkwak-work@users.noreply.github.com> | 2024-07-10 10:55:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 10:55:07 -0700 |
| commit | 59343c18928e476b7949a8700c5a792820da8656 (patch) | |
| tree | d4dfd04c760cfa8c7b24b929ce0a64c793945821 /source | |
| parent | 4a247244715e35872ab2359e9bc7cd55b5ea27d4 (diff) | |
Support status argument for GatherXXX (#4490)
* Support status argument for GatherXXX
This commit adds an argument to all texture GatherXXX functions.
The new argument is for "status" as described in SM5.0 definision.
Close #4466
Limit Gather with status to HLSL
Exclude Gather-status test from VK
* Fix capability errors
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/hlsl.meta.slang | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 5564094db..17e2822a3 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -2328,55 +2328,88 @@ ${{{{ { auto componentName = componentNames[componentId]; auto glslComponent = (isCmp ? "" :glslComponentNames[componentId == 0 ? 0 : componentId - 1]); - }}}} + + for (bool isStatus : { false, true }) + { + const char* statusDecl = isStatus ? ", out uint status" : ""; + const char* statusInit = isStatus ? " status = 0;\n" : ""; + const char* statusCapWithMetal = isStatus ? "hlsl" : "glsl_hlsl_metal_spirv"; + const char* statusCapWithoutMetal = isStatus ? "hlsl" : "glsl_hlsl_spirv"; +}}}} [ForceInline] - [require(glsl_hlsl_metal_spirv, texture_gather)] - vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam)) + [require($(statusCapWithMetal), texture_gather)] + vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam) $(statusDecl)) { + $(statusInit) __target_switch { case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)"; +${{{{ + if (!isStatus) + { +}}}} case metal: return __texture_gather$(cmp)<T>($(getTexture),$(getSampler) location $(compareArg) $(glslComponent)); case glsl: case spirv: return __texture_gather$(cmp)<T>(this,$(samplerStateParam) location $(compareArg) $(glslComponent)); +${{{{ + } // if(!isStatus) +}}}} } } [ForceInline] - [require(glsl_hlsl_metal_spirv, texture_gather)] - vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam), constexpr vector<int, Shape.planeDimensions> offset) + [require($(statusCapWithMetal), texture_gather)] + vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam), constexpr vector<int, Shape.planeDimensions> offset $(statusDecl)) { + $(statusInit) __target_switch { case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)"; +${{{{ + if (!isStatus) + { +}}}} case metal: return __texture_gather$(cmp)_offset<T>($(getTexture),$(getSampler) location $(compareArg), offset $(glslComponent)); case glsl: case spirv: return __texture_gather$(cmp)_offset<T>(this,$(samplerStateParam) location $(compareArg), offset $(glslComponent)); +${{{{ + } // if(!isStatus) +}}}} } } [ForceInline] - [require(glsl_hlsl_spirv, texture_gather)] + [require($(statusCapWithoutMetal), texture_gather)] vector<T,4> Gather$(cmp)$(componentName)($(samplerStateType)$(samplerStateParam) vector<float, Shape.dimensions+isArray> location $(cmpParam), constexpr vector<int, Shape.planeDimensions> offset1, constexpr vector<int, Shape.planeDimensions> offset2, constexpr vector<int, Shape.planeDimensions> offset3, - constexpr vector<int, Shape.planeDimensions> offset4) + constexpr vector<int, Shape.planeDimensions> offset4 + $(statusDecl)) { + $(statusInit) __target_switch { case hlsl: __intrinsic_asm ".Gather$(cmp)$(componentName)"; +${{{{ + if (!isStatus) + { +}}}} case glsl: case spirv: return __texture_gather$(cmp)_offsets<T>(this,$(samplerStateParam) location $(compareArg), offset1,offset2,offset3,offset4 $(glslComponent)); +${{{{ + } // if(!isStatus) +}}}} } } - ${{{{ +${{{{ + } // for (isStatus) } // for (componentId) } // for (isCmp) - }}}} +}}}} } // end extension for gather ${{{{ |
