-
Notifications
You must be signed in to change notification settings - Fork 303
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
HW Clip Planes support #390
Comments
It would be great to have. VulkanDB reports it not being available on a whole lot of mobile GPUs as well as Intel, which could be a showstopper. |
FWIW, ClipDistance and CullDistance are available in the GLSL-ES 3.2 spec (not in earlier versions) however the API spec for ES 3.2 makes no mention of them in section 12.5 (Primitive Clipping). So, I doubt there is great support for this feature from mobile vendors. |
Bizarre that Intel does not have clip planes, since it's required for D3D10+ through the SV_ClipDistance semantic. |
Intel most certainly has clip-planes. Indeed, the open source Mesa drivers implements clip-planes as far back as Gen4 (which was a Direct3D 9 part). These clip-planes are NOT emulated with discard either, they genuinely clip triangles. I can see from the source code that the open source Vulkan implementation from Intel should support clip-planes (see file genX_pipeline_state.c, method emit_3dstate_clip()). However, I don't know about the Vulkan driver MS-Windows from Intel (these are two totally different code-bases). However, for that platform, chances are the D3D12 API is to be used instead. If the Intel Vulkan open source driver does not support clip-planes, file a bug ASAP. |
I am advocating that it is OK, like in Vulkan, to report zero clip-planes. When that happens an application is going to have to do something: some will go the discard route and others will roll up their sleeves and go the compute route. Both fallbacks are slower, but an app has got to do what an app has got to do. |
Reporting zero clip-planes seems fine to me. |
Clip-distance is a great feature to have. Clip-distances can emulate multiple viewports as well (which is missing now). |
Clip-distance is an very important and useful feature in many industrial 3d app, I hope it can be implemented soon |
For a single clip plane, consider using an oblique projection matrix: http://terathon.com/code/oblique.html |
As suggested in the matrix webgpu room, I'd like to mention that this would be a very nice addition to the spec. Having ported the renderer of our game engine from Vulkan/D3D11 to WebGPU, I currently cannot implement certain effects because clip planes aren't supported. This is ironic since all of the backends we target (Metal,D3D,Vk) support clip planes just fine. |
I'm in the sam boat as @unvestigate, I need clip planes as well. |
I'm also interested in this feature 👀 |
(Please use Reactions for +1s rather than commenting, to keep the issue clean so we can more easily make progress on spec work here! ;) ) |
I disagree with this these days. :) |
There's useful background info on this feature here: |
Some more info on the availability and limits of this feature: Requiring Vulkan's
'shaderCullDistance' data (since I was wondering if those could be bundled together)Requirement "shaderCullDistance" loses 41 (and partially loses 10) further deviceNames: In ALL reports (41 deviceNames): x AMD Radeon HD - FirePro D300: 2 (7598 10450) x AMD Radeon Pro 455: 1 (19237) x AMD Radeon Pro 5500 XT: 1 (19703) x AMD Radeon Pro 5500M: 6 (12173 17321 18370 18402 18876 19496) x AMD Radeon Pro 555: 2 (19182 19721) x AMD Radeon Pro 555X: 5 (12248 12834 13632 18849 18851) x AMD Radeon Pro 560: 3 (16847 17783 18667) x AMD Radeon Pro 560X: 4 (16782 16995 17003 18525) x AMD Radeon Pro 570: 1 (18186) x AMD Radeon Pro Vega 20: 2 (16905 17497) x AMD Radeon Pro Vega 48: 1 (18502) x AMD Radeon Pro Vega 56: 1 (16451) x AMD Radeon Pro W5700X: 1 (18292) x AMD Radeon RX 570: 1 (17293) x AMD Radeon RX 580: 2 (11047 18921) x Apple M1: 45 (11048 11395 11396 11632 11689 11884 12086 13000 13410 13597 14080 14169 14584 14630 14927 15137 15250 15281 15337 15338 15517 15518 15671 15750 15791 15937 16158 16446 16632 16832 16913 17007 17148 17150 18000 18072 18656 18733 18784 18934 19110 19135 19198 19503 19606) x Apple M1 Max: 21 (13018 14522 14673 14752 15018 15815 16220 16557 16663 16843 16914 17767 17845 18302 18340 18407 18624 18895 18971 19317 19632) x Apple M1 Pro: 13 (13606 14001 16934 16989 17277 17872 18152 18537 18565 18691 18749 18975 19041) x Apple M1 Ultra: 4 (17092 17381 17879 18338) x Apple M2: 9 (16915 17860 17895 18216 18787 19113 19223 19464 19510) x Apple M2 Max: 1 (18789) x Apple M2 Pro: 1 (19130) x Intel HD Graphics 4000: 2 (9638 18923) x Intel HD Graphics 5000: 1 (16388) x Intel Iris Graphics: 2 (9665 19397) x Intel Iris Pro Graphics: 12 (7063 9812 9814 9816 11362 11481 12653 13573 14151 17044 17590 17778) x Intel(R) HD Graphics 5300: 1 (19258) x Intel(R) Iris(TM) Graphics 6000: 4 (11332 18448 18725 19301) x Intel(R) Iris(TM) Graphics 6100: 4 (17664 17687 18406 19067) x Intel(R) Iris(TM) Plus Graphics: 7 (11877 13745 17065 17132 17350 18611 19575) x Intel(R) Iris(TM) Plus Graphics 640: 6 (13263 13264 13266 13756 15516 17618) x Intel(R) Iris(TM) Plus Graphics 645: 4 (13596 15806 17555 18861) x Intel(R) Iris(TM) Plus Graphics 650: 1 (16944) x Intel(R) Iris(TM) Plus Graphics 655: 1 (19338) x Intel(R) Iris(TM) Pro Graphics 6200: 2 (18412 19257) x NVIDIA GeForce GT 640M: 1 (19121) x NVIDIA GeForce GT 650M: 1 (9637) x NVIDIA GeForce GT 750M: 9 (7062 9811 9813 9815 17043 17768 18304 18632 19335) x NVIDIA GeForce GTX 680MX: 1 (17144) x NVIDIA GeForce GTX 775M: 1 (18842) x NVIDIA Quadro K4200: 1 (10583) In SOME reports (10 deviceNames): ~ AMD Radeon Pro 5300M: 7 of 9 (10103 12130 13339 17089 18227 18809 19516; ok: 10099 13860) ~ AMD Radeon Pro 5600M: 1 of 3 (10322; ok: 14700 18056) ~ AMD Radeon Pro 580X: 1 of 2 (19109; ok: 10495) ~ AMD Radeon RX 6600: 2 of 11 (18663 19345; ok: 12796 13253 14295 14943 15928 17339 17513 19296 19530) ~ AMD Radeon RX 6800 XT: 1 of 21 (18291; ok: 10010 10710 11111 11563 11990 12279 12889 13194 13613 14095 15060 15613 16040 16352 16880 17741 18043 18512 18661 19171) ~ AMD Radeon RX 6900 XT: 2 of 60 (13265 15154; ok: 10222 10549 11100 11102 11149 11150 11152 11185 11204 11321 11738 11770 11771 11792 11941 11986 12013 12165 12166 12273 12298 12404 12481 12482 12509 13241 13302 13304 13759 13893 14417 14418 15089 15090 15267 15289 15290 15747 15764 15767 15776 15800 15827 16104 16251 16326 16333 16505 16792 17058 17900 17902 18371 19169 19393 19419 19669 19670) ~ AMD Radeon RX Vega 64: 13 of 16 (9626 9646 10079 10245 11293 12289 14191 14837 15034 15539 15540 16135 18263; ok: 9630 11294 13161) ~ Intel(R) HD Graphics 630: 2 of 79 (17784 18668; ok: 2145 2482 2519 2963 3117 3284 3389 3669 3955 4202 4268 4465 4478 4655 5015 5169 5423 5453 5583 5781 5883 6156 6221 6371 6614 6673 6795 6874 6933 7091 7183 7229 7303 7350 7439 7521 7609 7734 7797 8344 8525 8596 8700 8817 8982 9253 9330 9364 9508 9678 9740 9793 10151 10280 10356 10615 10794 11412 11414 11587 12156 12389 13044 14077 14286 14772 14840 15263 15692 16053 16237 16644 17048 17360 18529 18538 19057) ~ Intel(R) UHD Graphics 630: 12 of 127 (9003 12249 12835 16783 16996 17880 18286 18401 18810 18850 18877 19497; ok: 2796 3114 3168 3346 3744 3817 4385 4513 4686 4890 4919 5285 5639 6022 6050 6181 6187 6543 6601 6649 6811 6923 6991 7024 7092 7185 7298 7518 7748 7956 8100 8267 8569 8580 8586 8619 8792 8857 8984 9204 9322 9406 9420 9440 9458 9465 9578 9601 9732 9839 10081 10096 10165 10227 10257 10388 10745 11153 11622 11817 11913 11925 12149 12433 12597 12657 12670 12711 12762 12848 12975 13029 13067 13252 13407 13417 13576 14040 14127 14398 14427 14591 14605 14712 14968 15125 15297 15345 15562 15564 15712 15939 16164 16378 16721 16770 16811 16856 17175 17456 17634 17679 17685 17765 18095 18181 18184 18414 18508 18728 19090 19253 19387 19437 19547) ~ NVIDIA GeForce GTX 650: 1 of 6 (13744; ok: 12672 13735 14895 16018 18001) gathered via https://github.com/kainino0x/gpuinfo-vulkan-query Vulkan requires implementations supporting the feature to support a minimum of 8 clip distances. D3D12's Metal seems to have had the It seems that this would need to be a feature due to Mali GPUs not supporting it. |
I cannot find the max value listed anywhere either, not in the MTL shading language spec, nor anywhere else. The closest thing I could find is an old post on a bug in UE, which sorta suggests using clip planes 0-7 (even though the comment actually talks about 0-8). See the "fix to MetalUtils.cpp". Any Apple folks around who could confirm this? EDIT: Forgot the link: https://forums.unrealengine.com/t/planar-reflection-clipplane-bug-on-metal/361394/4 |
|
WGSL 2024-01-23 Minutes
|
User Defined ClippingIntroductionUser-defined Clipping is a way to do more primitive clipping besides the default clipping rules in WebGPU (clipping against the clip volume). With user-defined clipping, we can define multiple clip distances (in UsesUser-defined clipping can be used to discard the primitives that are not necessary to be processed by the fragment shader. The classic use is to clip all vertices in a scene that are beyond a certain plane. The clip distance in this case is the distance to the plane, with the visible side of the plane providing non-negative distances. Rendering water reflection or refractionThe water plane can be a user-defined clipping plane. Reflection should only be related to the objects that are above the water, and refraction should only be related to the objects that are under the water (example). CADUser-defined Clipping Plane is useful in CAD to view the internal structure of the current object (example1, example2) GUIIn GUI elements, it is often desired to ensure that objects inside a GUI window cannot be drawn outside of that window. User-defined clipping can be per-vertex values, sampled from vertex arrays. The Vertex Shader will be able to use them to set the gl_ClipDistance outputs to do such clipping against each GUI window. (Reference) User Defined Clipping in WebGPUClip Distance in native graphics APIs
In addition, user-defined clipping and culling has been supported in WebGL as an extension WEBGL_clip_cull_distance Proposal in WebGPUWe'd like to propose user-defined clipping as an optional WebGPU feature.
|
Couldn't clipplanes be emulated on those devices (by doing more expensive discard in the fragment shader) in WebGPU, the browser or some other layer? |
I agree that it would be nice to have clip distances even on hardware that doesn't support it by emulating when compiling the render pipeline, but I don't know how much implementations will want to take this on. It is a non-trivial amount of work in the compiler. Why do the clip distances need to be numbered unless we want to access them in the FS? It seems that |
I think making
|
Good point, then maybe require that |
In fact I suggest we use HLSL tradition (two
While translating
|
The check doesn't seem expensive, and look like something that the developer would have to write anyway if they uses more than 4 clip distances no? |
Without an if: |
What happens if you don't write to these output? |
WGSL 2024-03-12 Minutes
|
GPU Web 2024-03-06 Pacific-time
|
This is a feature request to support HW clip planes. It is OK for a platform to return that it support 0 HW-clip planes.
Each of the "new" 3D API's have HW-clip plane support (atleast a cursory look supports this):
Vulkan: VkPhysicalDeviceFeatures has fields for both clipping and culling (shaderClipDistance and shaderCullDistance) along with how many from the fields maxClipDistances and maxCulldistances from VkPhysicalDeviceLimits
Direct3D12: see the enumeration D3D12_CLIP_OR_CULL_DISTANCE_COUNT at https://docs.microsoft.com/en-us/windows/win32/direct3d12/constants
Metal: see 5.2.3.3 Vertex Function Output Attributes of the Metal 2.2 shading spec,
https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf.
I am just advocating for clip-disance and not cull-distance as the latter is more esoteric IMO.
I advocate that this feature to be part of the 1.0 core interface and not as an extension.
The text was updated successfully, but these errors were encountered: