-
Notifications
You must be signed in to change notification settings - Fork 787
[SM6.9] Enable Native Vector Overloads for Derivatives #7598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
HLSL intrinsics that lower to DXIL derivative ops get their parameters marked as convergent by passing their parameters to a temporary convergent function. This function scalarized vectors, leading to the results remaining scalarized. This change adds native vector support overloads to the convergent function and generates them in the convergent pass. This preserves the native vectors throughout final DXIL. Fixes microsoft#7343
This has IR breaking implications, which I think should be made clear from the title. What about: This most important high-level change is not currently made clear in either the title or description. It reminds me that we need to make sure we don't expose new vector overloads for existing DXIL ops when on an earlier shader model than 6.9, even when crafted directly with IR. For instance, in libraries, we allow vector in export function signature, so we could craft a validator test that takes a vector from function input and passes it directly to an existing intrinsic with a new vector overload, and make sure the validator will fail any vector passed to, or returned from, any DXIL intrinsic, if SM < 6.9. |
I've changed the title. The first sentence of the description mentions derivatives. I didn't really consider adding another valid opcode value to the already native vector overloaded dx.op.unary was fully an IR change really. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small readability nit, apply or not at you discretion.
if (VectorType *VTy = dyn_cast<VectorType>(Ty)) | ||
if (!SupportsVectors || VTy->getNumElements() == 1) { | ||
Ty = Ty->getScalarType(); | ||
NeedVectorExpansion = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor style nit to reduce levels of indentation.
if (VectorType *VTy = dyn_cast<VectorType>(Ty)) | |
if (!SupportsVectors || VTy->getNumElements() == 1) { | |
Ty = Ty->getScalarType(); | |
NeedVectorExpansion = true; | |
} | |
VectorType *VTy = dyn_cast<VectorType>(Ty); | |
if (VTy && !SupportsVectors || VTy->getNumElements() == 1) { | |
Ty = Ty->getScalarType(); | |
NeedVectorExpansion = true; | |
} |
This enables derivative operations using native vectors by allowing native vectors in temporary convergent functions. HLSL intrinsics that lower to DXIL derivative ops get their parameters marked as convergent by passing their parameters to a temporary convergent function. This function scalarized vectors, leading to the results remaining scalarized.
This change adds native vector support overloads to the convergent function and generates them in the convergent pass. This preserves the native vectors throughout final DXIL.
Moves tests for the until now scalarized intrinsics to native vector test locations. fwidth requires some more involved expansion while the derivative operations can be tested trivially.
Fixes #7343