diff options
| author | Tim Foley <tfoleyNV@users.noreply.github.com> | 2018-05-03 16:34:49 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-03 16:34:49 -0700 |
| commit | 00afea1e59e8929324df882009618534d3065138 (patch) | |
| tree | 384eb8724b51e345d3dbd2d4026cab8fe6bd58d4 /tests/hlsl | |
| parent | f8472940229e8582ec9f941069fc9576bd09b94c (diff) | |
Pass through original names for most declarations (#547)
The basic idea here is that when lowering to the IR, the front-end will attach a "name hint" to the IR instruction(s) that represent a given declaration, and then the passes that work on the IR will try to preserve and propagate those names, and then finally the emit logic will use them in place of mangled or unique names when available.
This change does *not* try to deal with the issues that arise when we try to use those variable names in the output without any modification (e.g., handling cases where they might clash with keywords or builtins in the target language). Instead, it tries to establish baseline behavior for propagating through names, so that a later change can concentrate on the issue of using those names exactly when it is legal to do so.
In order to avoid issues around the name "hints" causing problems we take two main steps:
1. We "scrub" each name to reduce it down to the allowed set of identifier characters in C-like languages, and then ensure that it doesn't do things that would be illegal in some downstream languages (e.g., consecutive underscores are not allowed in GLSL) or could clash with Slang's mangled names. This process isn't guaranteed to give distinct results for distinct inputs (it isn't a mangling scheme, after all).
2. We generate a unique ID for each occurence of a given name and always use that as a suffix. This means that even if a name happens to overlap with a keyword (if you somehow have a variable named `do`), we will still add a suffix that makes it not a problem (we'd output `do_0` which is fine).
The logic for generating these names is mostly straightforward. For simple variables, we use their given name directly, while for other declarations we try to form a name that includes their parent declaration (e.g. `SomeType.someMethod`).
Various IR passes need to propagate or preserve this information. The most interesting is type legalization, when we take a variable with an aggregate type and split some of the fields out into their own variables. In that case we generate "dotted" names like `someVar.someTexture` and rely on the emit logic to turn that into `someVar_someTexture`.
During SSA generation, if we are promoting a variable to SSA temporaries, we will try to propagate the name of the variable over to the temporaries (unless they already have a name from some other place). The same applies to block parameters ("phi nodes").
Many of the test changes need their expected output to be updated for this change. Luckily in most cases the output has gotten easier to understand.
Diffstat (limited to 'tests/hlsl')
11 files changed, 26 insertions, 26 deletions
diff --git a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl index 7b7b285b7..0a3209343 100644 --- a/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl +++ b/tests/hlsl/dxsdk/AdaptiveTessellationCS40/Render.hlsl @@ -1,8 +1,8 @@ //TEST(smoke):COMPARE_HLSL:-no-mangle -profile vs_4_0 -entry RenderBaseVS -profile ps_4_0 -entry RenderPS -target dxbc-assembly #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 #endif diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl index 97b8b6c7e..c446b3493 100644 --- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl +++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_PS.hlsl @@ -1,11 +1,11 @@ //TEST:COMPARE_HLSL:-no-mangle -target dxbc-assembly -profile ps_4_0 -entry PSMain #ifndef __SLANG__ -#define cbPerFrame _SV031SLANG_parameterGroup_cbPerFrame -#define g_vLightDir _SV031SLANG_ParameterGroup_cbPerFrame11g_vLightDir -#define g_fAmbient _SV031SLANG_ParameterGroup_cbPerFrame10g_fAmbient -#define g_samLinear _SV011g_samLinear -#define g_txDiffuse _SV011g_txDiffuse +#define cbPerFrame cbPerFrame_0 +#define g_vLightDir g_vLightDir_0 +#define g_fAmbient g_fAmbient_0 +#define g_samLinear g_samLinear_0 +#define g_txDiffuse g_txDiffuse_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl index fa5a7e0b4..8ff5e64d7 100644 --- a/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl +++ b/tests/hlsl/dxsdk/BasicHLSL11/BasicHLSL11_VS.hlsl @@ -1,9 +1,9 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection -#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 +#define g_mWorld g_mWorld_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl index e9175834a..5e2cfacf8 100644 --- a/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl +++ b/tests/hlsl/dxsdk/CascadedShadowMaps11/RenderCascadeShadow.hlsl @@ -1,8 +1,8 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain -entry VSMainPancake #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl index 7421c8aa7..ecbcb85f9 100644 --- a/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl +++ b/tests/hlsl/dxsdk/DynamicShaderLinkage11/DynamicShaderLinkage11_VS.hlsl @@ -1,9 +1,9 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection -#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 +#define g_mWorld g_mWorld_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl index 464bb4c8a..3f1d90bfd 100644 --- a/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl +++ b/tests/hlsl/dxsdk/MultithreadedRendering11/MultithreadedRendering11_VS.hlsl @@ -1,10 +1,10 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorld _SV032SLANG_ParameterGroup_cbPerObject8g_mWorld -#define cbPerScene _SV031SLANG_parameterGroup_cbPerScene -#define g_mViewProj _SV031SLANG_ParameterGroup_cbPerScene11g_mViewProj +#define cbPerObject cbPerObject_0 +#define g_mWorld g_mWorld_0 +#define cbPerScene cbPerScene_0 +#define g_mViewProj g_mViewProj_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl index a6b971a57..6f96938ed 100644 --- a/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl +++ b/tests/hlsl/dxsdk/OIT11/SceneVS.hlsl @@ -1,8 +1,8 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry SceneVS #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 #endif //----------------------------------------------------------------------------- diff --git a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl index e80360754..744e16d0e 100644 --- a/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl +++ b/tests/hlsl/dxsdk/VarianceShadows11/RenderVarianceShadow.hlsl @@ -1,8 +1,8 @@ //TEST:COMPARE_HLSL: -target dxbc-assembly -profile vs_4_0 -entry VSMain -profile ps_4_0 -entry PSMain #ifndef __SLANG__ -#define cbPerObject _SV032SLANG_parameterGroup_cbPerObject -#define g_mWorldViewProjection _SV032SLANG_ParameterGroup_cbPerObject22g_mWorldViewProjection +#define cbPerObject cbPerObject_0 +#define g_mWorldViewProjection g_mWorldViewProjection_0 #endif //-------------------------------------------------------------------------------------- diff --git a/tests/hlsl/simple/allow-uav-conditional.hlsl b/tests/hlsl/simple/allow-uav-conditional.hlsl index 3f12c9be8..8195a9f1d 100644 --- a/tests/hlsl/simple/allow-uav-conditional.hlsl +++ b/tests/hlsl/simple/allow-uav-conditional.hlsl @@ -3,7 +3,7 @@ // Check output for `[allow_uav_conditional]` #ifndef __SLANG__ -#define gBuffer _SV07gBuffer +#define gBuffer gBuffer_0 #endif RWStructuredBuffer<uint> gBuffer : register(u0); diff --git a/tests/hlsl/simple/compute-numthreads.hlsl b/tests/hlsl/simple/compute-numthreads.hlsl index 4f3291671..805c960c4 100644 --- a/tests/hlsl/simple/compute-numthreads.hlsl +++ b/tests/hlsl/simple/compute-numthreads.hlsl @@ -3,7 +3,7 @@ // Confirm that we properly pass along the `numthreads` attribute on an entry point. #ifndef __SLANG__ -#define b _SV01b +#define b b_0 #endif RWStructuredBuffer<float> b; diff --git a/tests/hlsl/simple/literal-typing.hlsl b/tests/hlsl/simple/literal-typing.hlsl index 48ea5b2cb..0ecf60506 100644 --- a/tests/hlsl/simple/literal-typing.hlsl +++ b/tests/hlsl/simple/literal-typing.hlsl @@ -18,7 +18,7 @@ Bad foo(int x) { Bad b; b.bad = x; return b; } // or ignore it and call the wrong one. #ifndef __SLANG__ -#define b _SV01b +#define b b_0 #endif RWStructuredBuffer<uint> b; |
