Repository navigation
Add initial support for extension intrinsics and defines - #5
Conversation
-Add support for recognizing hlsl extensions as new intrinsic functions. -Add support for requesting lowering of extensions. -Add support for preserving semantic defines. -Add support for validating semantic defines. This commit adds support for hlsl extensions in the form of additional intrisic functions and semantic defines. We now allow a dxcompiler instance to register that it can handle additional intrinsic functions beyond the standard hlsl intrinsics. These new intrinsics are called extensions. For each extension, the compiler supplies a lowering strategy that is used by the dxcompiler to translate from the source level intrinsic to a high-level dxil intrinsic. We initially support the two lowering strategies: replicate and pack. The replicate strategy will scalarize the vector elements in the call and replicate the function call once for each element in the vector. The pack strategy changes the vector arguments into literal struct arguments. We also now include support for "semantic defines". A semantic define is a source level define whose value is preserved in the final dxil as metatdata. The source level define can come as either a #define in the hlsl source or a /D define from the command line. We provide a hook to validate that a semantic define has a legal value (for example to ensure that the value is an integer). Validation failures can produce warnings and errors that will be emitted through the standard clang diagnostic mechanism. This code was originally written by marcelolr and modified by dmpots to support packed lowering of intriniscs and validation of semantic defines.
|
Hi David Peixotto (@dmpots), I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
TTYL, MSBOT; |
| // Set the validator used to validate semantic defines. | ||
| // Only one validator stored and used to run validation. | ||
| HRESULT STDMETHODCALLTYPE SetSemanticDefineValidator(_In_ IDxcSemanticDefineValidator* pValidator) { | ||
| try { |
There was a problem hiding this comment.
This block doesn't really need a try block, as all we do is an assignment. It can just error if pValidator is nullptr, otherwise assign.
| } | ||
|
|
||
| HRESULT STDMETHODCALLTYPE SetSemanticDefineMetaDataName(LPCSTR name) { | ||
| m_semanticDefineMetaDataName = name; |
There was a problem hiding this comment.
This one on the other hand does need a try block, because the std::string will throw with bad_alloc.
| HRESULT result = m_semanticDefineValidator->GetSemanticDefineWarningsAndErrors(name.c_str(), value.c_str(), &pWarning, &pError); | ||
|
|
||
| if (FAILED(result)) { | ||
| // Hmmm... what to do? |
There was a problem hiding this comment.
Probably failing with a generic error message? Maybe format the HRESULT?
| dxcsupport | ||
| hlsl | ||
| option | ||
| Analysis |
There was a problem hiding this comment.
I don't think these additions are needed.
| return S_OK; | ||
| } | ||
| }; | ||
| void CheckOperationFailed(IDxcOperationResult *pResult) { |
There was a problem hiding this comment.
static? or maybe share them out via a header in helpers. But I'd start with static. Same with the next function.
| #include "dxc/dxcapi.internal.h" | ||
| #include "dxc/HLSL/HLOperationLowerExtension.h" | ||
|
|
||
| // LLVM include for custom lowering |
There was a problem hiding this comment.
No custom lowering from outside dxcompiler.
* add/remove try blocks
* format message on failure to run validator
* clean up link/include options for tests
* make internal test functions static
Marcelo Lopez Ruiz (marcelolr)
left a comment
There was a problem hiding this comment.
Other than the lib references in the test cmake file, I think this is good to go.
| hlsl | ||
| option | ||
| Analysis | ||
| Core |
There was a problem hiding this comment.
The other newly introduced dependencies aren't necessary either.
There was a problem hiding this comment.
Yep, I will fix that. Sorry I missed it earlier!
Forgot to remove them in an earlier patch.
Strip function parameter for entry and patch constant function * Update error message for ValidationTest::MultiDimArray * Merge remote-tracking branch 'origin/master' # Conflicts: # lib/HLSL/DxilValidation.cpp # tools/clang/unittests/HLSL/ValidationTest.cpp * Update error message for ValidationTest::MultiDimArray Update error message for ValidationTest::MultiDimArray * Fix merge error. (#3) * Delete local file (#4) * Fix merge error. * Delete local file * Strip function parameter for entry and patch constant function. (#5)
…icrosoft#5) * Fix ValidateDxilBitcode PSV generation for Root Signature validation. - also fix validation for empty patch constant signature. * Test container and root signature validation. * Fix DXASSERT when PC in/out patch sig mismatch HS.
…for `vk::SampledTexture2D` type. (#8098) Part of #7979 Implement remaining sample methods methods for `vk::SampledTexture2D`: ```hlsl float Object.SampleCmp(float Location, float CompareValue, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCmpLevelZero(float Location, float CompareValue, [, int Offset], [, out uint Status]); float Object.SampleCmpLevel(float Location, float CompareValue, float LOD, [, int Offset], [, out uint Status]); float Object.SampleGrad(float Location, float DDX, float DDY, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCompGrad(float Location, float CompareValue, float DDX, float DDY, [, int Offset], [, float Clamp] [, out uint Status]); float Object.SampleCompBias(float Location, float CompareValue, float Bias, [, int Offset], [, float Clamp] [, out uint Status]); PARAM_TYPE Object.SampleBias(float Location, float Bias, [, int Offset], [, float Clamp], [, out uint Status]); PARAM_TYPE Object.SampleLevel(float Location, float LOD, [, int Offset], [, out uint Status]); ``` --------- Co-authored-by: Damyan Pepper <damyanp@microsoft.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Ashley Coleman <ascoleman@microsoft.com> Co-authored-by: kpyzhov <konstantin.pyzhov@gmail.com> Co-authored-by: Konstantin <konstantin.pyzhov@amd.com> Co-authored-by: Steven Perron <stevenperron@google.com> Co-authored-by: Alex Sepkowski <alexsepkowski@gmail.com>
-Add support for recognizing hlsl extensions as new intrinsic functions.
-Add support for requesting lowering of extensions.
-Add support for preserving semantic defines.
-Add support for validating semantic defines.
This commit adds support for hlsl extensions in the form of additional
intrisic functions and semantic defines.
We now allow a dxcompiler instance to register that it can handle
additional intrinsic functions beyond the standard hlsl intrinsics. These
new intrinsics are called extensions. For each extension, the compiler
supplies a lowering strategy that is used by the dxcompiler to translate
from the source level intrinsic to a high-level dxil intrinsic.
We initially support the two lowering strategies: replicate and pack.
The replicate strategy will scalarize the vector elements in the call
and replicate the function call once for each element in the vector.
The pack strategy changes the vector arguments into literal struct
arguments.
We also now include support for "semantic defines". A semantic define is
a source level define whose value is preserved in the final dxil as
metatdata. The source level define can come as either a #define in
the hlsl source or a /D define from the command line.
We provide a hook to validate that a semantic define has a legal value
(for example to ensure that the value is an integer). Validation failures
can produce warnings and errors that will be emitted through the standard
clang diagnostic mechanism.
This code was originally written by marcelolr and modified by dmpots to
support packed lowering of intriniscs and validation of semantic defines.