-
Notifications
You must be signed in to change notification settings - Fork 237
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
Implement Quad Control intrinsics #5981
base: master
Are you sure you want to change the base?
Conversation
I added a new functional test which requires the quad control extensions to be enabled when creating the vulkan device. This change is reflected here shader-slang/slang-rhi#124. |
source/slang/hlsl.meta.slang
Outdated
// | ||
|
||
//@public: | ||
/// Returns true if <expr> is true in any lane of the current quad. |
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.
-> expr
for better documentation rendering results.
source/slang/slang-emit-glsl.cpp
Outdated
{ | ||
m_writer->emit("layout(quad_derivatives) in;\n"); | ||
} | ||
if (irFunc->findDecoration<IRRequireFullQuadsDecoration>()) |
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.
This should be moved to fragment shader specific handling logic in the switch statement above since it is only valid on fragment shaders.
source/slang/slang-emit-glsl.cpp
Outdated
@@ -1470,6 +1470,19 @@ void GLSLSourceEmitter::emitEntryPointAttributesImpl( | |||
default: | |||
break; | |||
} | |||
|
|||
if (irFunc->findDecoration<IRQuadDerivativesDecoration>()) |
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.
This is starting to get too many if (findDecoration) blocks, note that each one of them is a linear search, we may just use one single for loop to interate and test the op code of all decorations.
IRBuilder builder(module); | ||
builder.setInsertInto(entryPointFunc); | ||
|
||
for (auto globalInst : module->getGlobalInsts()) |
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.
This should be traversing the call graph of each EntryPoint, otherwise we will be marking all entrypoints with the decorations if any one function in the module has the opcode.
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.
See buildEntryPointReferenceGraph, it would be best if we can perform this logic in a place where the reference graph is already available.
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.
Looks good, thank you!
@csyonghe Can you merge shader-slang/slang-rhi#124 so I can update the slang-rhi submodule required to run the new functional test? Thanks! |
Merged. |
Adds quad control intrinsics introduced in SM 6.7. Parallel implementations exist in Metal and Vulkan. This change also adds adds attribute syntax to specify quad control SPIRV execution modes that is not exposed by HLSL.
SPIRV specs: quad control, maximal reconvergence
GLSL specs: quad control, maximal reconvergence
Vulkan specs: quad control, maximal reconvergence