diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2025-08-07 00:22:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-07 07:22:22 +0000 |
| commit | 063cbeaaea2fb00a10c6058ea4a9632092772ea5 (patch) | |
| tree | b4412347d6c264c3b1a84ec971921a5e2fe76134 /prelude/slang-cpp-types.h | |
| parent | 9e2685853033f4286feaf22d04a755a7395d95ce (diff) | |
Initial copy elision pass (#8042)
Fixes #7574
Changes:
* Add an initial (fairly simple) optimization pass which is able to
eliminate redundant copies.
* Our current existing optimizer passes remove redundant load/store very
robustly, this pass will focus on other cases of copy elimination
* Primary approach is to make all functions which are `in T` and `T` is
trivial to copy into a `__constref T`. We then (depending on scenario)
manually insert a variable+load if a pass-by-reference is not possible;
otherwise we pass by `constref`.
* Added optimizations to eliminate redundant code which causes
`constref` to fail to compile
---------
Co-authored-by: Harsh Aggarwal <haaggarwal@nvidia.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'prelude/slang-cpp-types.h')
| -rw-r--r-- | prelude/slang-cpp-types.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/prelude/slang-cpp-types.h b/prelude/slang-cpp-types.h index 010ab8d6c..491438c80 100644 --- a/prelude/slang-cpp-types.h +++ b/prelude/slang-cpp-types.h @@ -440,7 +440,7 @@ struct Texture1D texture->Sample(samplerState, &loc, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, float loc, float level) + T SampleLevel(SamplerState samplerState, float loc, float level) const { T out; texture->SampleLevel(samplerState, &loc, level, &out, sizeof(out)); @@ -500,7 +500,7 @@ struct Texture2D texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float2& loc, float level) + T SampleLevel(SamplerState samplerState, const float2& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); @@ -566,7 +566,7 @@ struct Texture3D texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float3& loc, float level) + T SampleLevel(SamplerState samplerState, const float3& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); @@ -620,7 +620,7 @@ struct TextureCube texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float3& loc, float level) + T SampleLevel(SamplerState samplerState, const float3& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); @@ -680,7 +680,7 @@ struct Texture1DArray texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float2& loc, float level) + T SampleLevel(SamplerState samplerState, const float2& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); @@ -747,7 +747,7 @@ struct Texture2DArray texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float3& loc, float level) + T SampleLevel(SamplerState samplerState, const float3& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); @@ -808,7 +808,7 @@ struct TextureCubeArray texture->Sample(samplerState, &loc.x, &out, sizeof(out)); return out; } - T SampleLevel(SamplerState samplerState, const float4& loc, float level) + T SampleLevel(SamplerState samplerState, const float4& loc, float level) const { T out; texture->SampleLevel(samplerState, &loc.x, level, &out, sizeof(out)); |
