DirectXShaderCompiler icon indicating copy to clipboard operation
DirectXShaderCompiler copied to clipboard

Require valid outputcontrolpoints on Hull shader

Open sudonatalie opened this issue 1 year ago • 6 comments

According to the documentation: "A hull shader is implemented with an HLSL function, and has the following properties: [...] The shader output is between 1 and 32 control points".

https://learn.microsoft.com/en-us/windows/win32/direct3d11/direct3d-11-advanced-stages-tessellation#hull-shader-stage

This change adds a check to verify that the outputcontrolpoints attribute is set on Hull shaders and has an argument in the valid range.

Fixes #3733 (by making the error consistent between backends)

sudonatalie avatar Jan 24 '24 14:01 sudonatalie

@llvm-beanz The cases where outputcontrolpoints was 0 or unset currently pass with the DXIL backend, but it seems like this shouldn't be the case. What do you think of this change?

sudonatalie avatar Jan 24 '24 14:01 sudonatalie

@tex3d Any thoughts on this? If it's too breaking of a change to error, do you have any insight into the expected behavior of outputcontrolpoints being unset or zero that could help us implement it correctly on the SPIR-V side?

sudonatalie avatar Feb 12 '24 18:02 sudonatalie

In terms of the DXIL that would be generated if 0 were allowed, it's just placed on the list of attributes for the hull entry point functions.

I expect that drivers may consume this fine, but it could only mean that the domain shader wouldn't be run at all. I can't imagine why this would be a useful thing to do even in the most contrived case.

pow2clk avatar Feb 26 '24 18:02 pow2clk

Looking into the validator changes...

sudonatalie avatar Feb 27 '24 18:02 sudonatalie

:warning: Python code formatter, darker found issues in your code. :warning:

You can test this locally with the following command:
darker --check --diff -r 696a13a2a8d007e625c11d46f650b3a91ed72a3a..c679d6fdbdbaf936d8c0e977647f96484dcbc579 utils/hct/hctdb.py
View the diff from darker here.
--- hctdb.py	2024-02-27 18:36:29.000000 +0000
+++ hctdb.py	2024-03-25 17:22:57.471712 +0000
@@ -7587,11 +7587,11 @@
             "Instr.AtomicIntrinNonUAV", "Non-UAV destination to atomic intrinsic."
         )
         self.add_valrule_msg(
             "Instr.SVConflictingLaunchMode",
             "Input system values are compatible with node shader launch mode.",
-            "Call to DXIL intrinsic %0 (%1) is not allowed in node shader launch type %2"
+            "Call to DXIL intrinsic %0 (%1) is not allowed in node shader launch type %2",
         )
         self.add_valrule("Instr.AtomicConst", "Constant destination to atomic.")
 
         # Work-Graphs
         self.add_valrule(

  • [x] Check this box to apply formatting changes to this branch.

github-actions[bot] avatar Feb 27 '24 18:02 github-actions[bot]

This change is ready for re-review!

sudonatalie avatar Mar 04 '24 15:03 sudonatalie

Ping @tex3d, this change is just waiting on your review.

sudonatalie avatar Mar 15 '24 14:03 sudonatalie

I don't know why the formatter auto-apply is failing, but I'm going to bypass it since it's modifying a line that isn't touched in this PR anyways.

sudonatalie avatar Mar 25 '24 17:03 sudonatalie

I see this failing the GitHub Pages workflow, taking a look...

sudonatalie avatar Mar 25 '24 18:03 sudonatalie