Skip to content
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

Closed
krogovin opened this issue Aug 8, 2019 · 30 comments · Fixed by #4588
Closed

HW Clip Planes support #390

krogovin opened this issue Aug 8, 2019 · 30 comments · Fixed by #4588
Labels
api WebGPU API feature request A request for a new GPU feature exposed in the API investigation wgsl resolved Resolved - waiting for a change to the WGSL specification
Milestone

Comments

@krogovin
Copy link

krogovin commented Aug 8, 2019

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):

  1. Vulkan: VkPhysicalDeviceFeatures has fields for both clipping and culling (shaderClipDistance and shaderCullDistance) along with how many from the fields maxClipDistances and maxCulldistances from VkPhysicalDeviceLimits

  2. Direct3D12: see the enumeration D3D12_CLIP_OR_CULL_DISTANCE_COUNT at https://docs.microsoft.com/en-us/windows/win32/direct3d12/constants

  3. 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.

@kvark kvark added feature request A request for a new GPU feature exposed in the API investigation labels Aug 8, 2019
@kvark
Copy link
Contributor

kvark commented Aug 8, 2019

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.

@prideout
Copy link

prideout commented Aug 8, 2019

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.

@magcius
Copy link

magcius commented Aug 8, 2019

Bizarre that Intel does not have clip planes, since it's required for D3D10+ through the SV_ClipDistance semantic.

@krogovin
Copy link
Author

krogovin commented Aug 8, 2019

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.

@krogovin
Copy link
Author

krogovin commented Aug 8, 2019

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.

@kdashg
Copy link
Contributor

kdashg commented Aug 16, 2019

Reporting zero clip-planes seems fine to me.

@frustum
Copy link

frustum commented Jul 15, 2021

Clip-distance is a great feature to have. Clip-distances can emulate multiple viewports as well (which is missing now).

@Kangz Kangz added this to the post-V1 milestone Sep 2, 2021
@sseanwang
Copy link

Clip-distance is an very important and useful feature in many industrial 3d app, I hope it can be implemented soon

@magcius
Copy link

magcius commented Apr 11, 2022

For a single clip plane, consider using an oblique projection matrix: http://terathon.com/code/oblique.html

@unvestigate
Copy link

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.

@kainino0x kainino0x modified the milestones: Polish post-V1, Milestone 2? Aug 15, 2023
@olofwalker
Copy link

I'm in the sam boat as @unvestigate, I need clip planes as well.

@kohakukun
Copy link

I'm also interested in this feature 👀

@kdashg
Copy link
Contributor

kdashg commented Jan 23, 2024

(Please use Reactions for +1s rather than commenting, to keep the issue clean so we can more easily make progress on spec work here! ;) )

@kdashg
Copy link
Contributor

kdashg commented Jan 23, 2024

Reporting zero clip-planes seems fine to me.

I disagree with this these days. :)

@kdashg
Copy link
Contributor

kdashg commented Jan 23, 2024

There's useful background info on this feature here:
https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#15.4%20Clipping
(especially in 15.4.1 and 15.4.2)

@teoxoy
Copy link
Member

teoxoy commented Jan 23, 2024

Some more info on the availability and limits of this feature:

Requiring Vulkan's shaderClipDistance loses all Mali devices (compared to all the requirements to implement WebGPU).

Requirement "shaderClipDistance" loses 21 (and partially loses 0) further deviceNames:
  In ALL reports (21 deviceNames):
    x Mali-G51: 25 (5377 6292 7669 10777 10788 11259 11286 11335 11337 11360 11379 11778 12255 12619 13310 13384 14281 15038 16156 16200 16482 17934 18059 18472 19024)
    x Mali-G52: 36 (9942 10194 11056 11982 12046 12062 12284 12622 12630 12643 12798 14045 14925 15260 15378 15490 15727 15736 15996 16385 16469 16506 16992 17167 17176 17292 17649 17729 18106 18134 18226 18280 18582 18589 18744 19671)
    x Mali-G52 MC2: 49 (7412 8797 10324 10667 10849 10855 10960 10986 11043 11291 11614 11870 11901 12515 12628 12673 12810 12948 13342 13433 13594 13669 14065 14190 14320 15256 15400 15548 15556 15567 15667 15740 15918 15976 16161 16324 16354 16530 17282 17338 17387 17637 17919 17930 18219 18724 19380 19429 19436)
    x Mali-G57: 9 (9826 11011 14237 14904 15036 15480 15610 16430 18614)
    x Mali-G57 MC2: 28 (10733 11674 12300 12863 13164 13709 14459 14942 15483 15491 15587 15643 15745 16222 16317 16389 16594 16615 17705 17787 17788 18266 18517 18587 18588 18994 19213 19558)
    x Mali-G57 MC3: 11 (10564 10930 11617 13017 13543 13858 14192 15375 15457 15843 16535)
    x Mali-G610: 5 (15222 16433 17303 18068 18716)
    x Mali-G610 MC6: 7 (15244 15916 15970 16086 16425 16785 17770)
    x Mali-G68: 6 (15534 15897 16727 17484 17627 18121)
    x Mali-G68 MC4: 6 (15101 15273 15934 16321 17646 18377)
    x Mali-G710: 3 (16769 16823 19220)
    x Mali-G710 MC10: 9 (14684 14922 15223 15630 16294 18327 19394 19512 19524)
    x Mali-G715-Immortalis MC11: 2 (17913 17955)
    x Mali-G72: 68 (4756 4871 5209 5540 6070 6158 6561 6593 6839 7335 9031 10297 10316 10409 10493 10500 10561 10593 10737 10797 10916 10922 10933 10961 11060 11071 11078 11188 11226 11267 11313 11330 11537 11559 11660 11782 12179 12241 12319 12371 12372 12427 12742 13059 13129 13255 13521 13785 14167 14271 14272 14687 15084 15242 15379 15451 15730 16083 16521 16583 16930 17469 17754 18721 18860 19143 19222 19381)
    x Mali-G72 MP3: 22 (5644 6051 8572 10811 10812 11183 11189 11572 11939 12222 12658 13147 13286 13293 13443 14420 14890 15513 16380 16803 16997 17814)
    x Mali-G76: 66 (5370 5374 5529 5558 5917 6036 6039 6110 6227 6737 7395 7441 9760 10364 10433 10520 10553 10851 11020 11165 11221 11344 11418 11473 11555 11601 11649 11650 11713 11848 11853 11967 11968 12326 12373 12580 12592 12654 12748 12894 13326 13360 13822 14108 14229 14263 14563 14701 14803 14891 15110 15390 16227 16590 16889 17262 17885 17948 17976 18331 18343 18411 18690 18794 19472 19745)
    x Mali-G76 MC4: 15 (7301 8775 11889 12030 13477 13602 13693 13938 14688 14986 15404 16447 17517 18083 18616)
    x Mali-G77: 25 (8046 9058 9711 10290 10312 10346 10643 11844 11929 12347 12879 12884 13607 13648 13668 13818 14087 14609 15844 17341 17401 17556 17655 17731 17750)
    x Mali-G77 MC7: 1 (10785)
    x Mali-G77 MC9: 11 (12808 15485 15560 16366 16711 16764 17819 18147 18843 19401 19468)
    x Mali-G78: 30 (10390 10395 10625 10699 11648 12368 12788 12851 13091 13271 13582 14501 14514 15142 15143 15551 15603 16031 16143 16265 16311 16441 17127 17427 17487 17843 18249 18399 19077 19270)
'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 D3D12_CLIP_OR_CULL_DISTANCE_COUNT is 8 (Vulkan also has a minimum limit of 8 maxCombinedClipAndCullDistances if both features are available).

Metal seems to have had the clip_distance attribute as far back as v1.2 but I couldn't find what the limit is (is it also 8?). For completeness, Metal also doesn't have a cull_distance attribute.

It seems that this would need to be a feature due to Mali GPUs not supporting it.
If we can confirm that Metal also supports 8 clip distances, we can have this be a static limit.

@unvestigate
Copy link

unvestigate commented Jan 23, 2024

If we can confirm that Metal also supports 8 clip distances, we can have this be a static limit.

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

@mwyrzykowski
Copy link

[clip_distance] supports 8 values, e.g., float clipDistance [[clip_distance]] [8];

@kdashg
Copy link
Contributor

kdashg commented Feb 13, 2024

WGSL 2024-01-23 Minutes
  • JS: Investigating the limit of number of clip planes allowed. It seems Metal has an undocumented limit of 8.
  • KG: How to bridge the gap between the desire and what can be done.
  • JS: We’re still investigating support level.
  • DN: Primer on this feature?
  • KG: See the D3D11 functional spec; describes it well.
  • DN: ok.
  • KG: There’s a similar investigation for an extension for WebGL.

@Jiawei-Shao
Copy link
Contributor

Jiawei-Shao commented Feb 21, 2024

User Defined Clipping

Introduction

User-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 f32) as the output of the vertex shaders, and each of them is assumed to be a float32 signed distance to a plane. Primitive setup only invokes rasterization on pixels for which the interpolated plane distance(s) are >= 0 (Reference, chapter 15.4.1)

Uses

User-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 refraction

The 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).

CAD

User-defined Clipping Plane is useful in CAD to view the internal structure of the current object (example1, example2)

GUI

In 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 WebGPU

Clip Distance in native graphics APIs

D3D11 and D3D12 Metal Vulkan OpenGL OpenGL ES
Support Always Always VkPhysicalDeviceFeatures.shaderClipDistance
(Coverage: 82.38%:
Android (67.52%), Windows (99.4%), Linux (98.86%), macOS (100%), iOS (100%)
GLSL 1.3 EXT_clip_cull_distance
Minimum Clip Distances if supported 8
(D3D12_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT)
8 8
(maxClipDistances)
8
(MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT)
8
(MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT)
Built-ins when use 8 clip distances SV_ClipDistance0 (float4)
SV_ClipDistance1 (float4)
float [[clip_distance]][8] ClipDistance (an array of float32) highp float gl_ClipDistance[8] highp float gl_ClipDistance[8]
User defined culling Supported Not Supported Supported Supported Supported
As Fragment Input Supported Not Supported Supported Supported Supported
Additional API side commands - - - glEnable(GL_CLIP_DISTANCE0)
glDisable(GL_CLIP_DISTANCE0)
glEnable(GL_CLIP_DISTANCE0)
glDisable(GL_CLIP_DISTANCE0)

In addition, user-defined clipping and culling has been supported in WebGL as an extension WEBGL_clip_cull_distance

Proposal in WebGPU

We'd like to propose user-defined clipping as an optional WebGPU feature.

  • User-defined clipping cannot be a core feature because it is still not supported on some old Android devices.
  • User-defined culling is not included because Metal doesn't support it.
  • Two built-ins are introduced as vertex stage outputs: @builtin(clip_distance0) and
    @builtin(clip_distance1), which can both be f32 or vec2f or vec3f or vec4f to align with SV_ClipDistance0 and SV_ClipDistance1 in HLSL. In the WGSL shader the developer can either declare @builtin(clip_distance0) or both @builtin(clip_distance0) and @builtin(clip_distance1), which depends on how many user-defined clip distances are used.
  • Each user-defined clip distance vertex outputs will consume 1 inter-stage shader variable and the certain number of inter-stage shader components that depends on its declaration.
  • Clip distances as fragment stage inputs are not included because Metal doesn't support it.

@JannikGM
Copy link

User-defined clipping cannot be a core feature because it is still not supported on some old Android devices

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?

@Kangz
Copy link
Contributor

Kangz commented Feb 21, 2024

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 @clip_distance could work. (also @clip_distance(N) otherwise?). It's a bit inconvenient for the developers to have to pack things in vec3s. What about allowing not just two clip distances but N < 8 and having them use inter stage variable slots as usual?

@Jiawei-Shao
Copy link
Contributor

Why do the clip distances need to be numbered unless we want to access them in the FS? It seems that @clip_distance could work. (also @clip_distance(N) otherwise?). It's a bit inconvenient for the developers to have to pack things in vec3s. What about allowing not just two clip distances but N < 8 and having them use inter stage variable slots as usual?

I think making @clip_distance an array or vector is helpful for the developer to iterate all the planes in a for-loop:

  for (var i = 0; i < clipPlanes; i++){
    clipDistance[i] = dot(planes[i], currentLocation);
  }

@Kangz
Copy link
Contributor

Kangz commented Feb 22, 2024

Good point, then maybe require that @clip_distance be an array<f32/f16, N> and make it consume N/4 variable slots.

@Jiawei-Shao
Copy link
Contributor

Jiawei-Shao commented Feb 27, 2024

Good point, then maybe require that @clip_distance be an array<f32/f16, N> and make it consume N/4 variable slots.

In fact I suggest we use HLSL tradition (two vec4f) instead of MSL and Vulkan (GLSL) ones (an f32 array) because translating clipDistance0 : vec4f and clipDistance1 : vec4f into float clipDistances[N] is straightforward:

clipDistance0[i] -> clipDistances[i]
clipDistance1[i] -> clipDistances[i + 4]

While translating float clipDistances[N] into HLSL will introduce a check on the index, which seems unnecessary and may cause performance penalty:

clipDistance[i]

->

if (i < 4) {
    clipDistance0[i]
} else {
    clipDistance1[i - 4]
}

@Kangz
Copy link
Contributor

Kangz commented Feb 27, 2024

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?

@kdashg
Copy link
Contributor

kdashg commented Mar 12, 2024

Without an if: select(clipDistance0, clipDistance1, i >= 4)[i % 4]

@kdashg
Copy link
Contributor

kdashg commented Mar 12, 2024

What happens if you don't write to these output?

@kdashg kdashg added the wgsl resolved Resolved - waiting for a change to the WGSL specification label Mar 13, 2024
@kdashg
Copy link
Contributor

kdashg commented Mar 13, 2024

WGSL 2024-03-12 Minutes
  • From the API meeting: “Finish discussing the shape of the WGSL builtins in the WGSL meeting.” (Added by KN who probably won’t be here and doesn’t know needs to be discussed exactly. Feel free to punt if needed, but I think Jiawei wanted to keep working on this.)
  • KG: HLSL exposes it as up to 2 vec4f, and others use arrays.
  • KG: My taste is to make it arrays of floats.
  • (JiaweS: Agreed with meeting emoji)
  • (JB: Agreed with thumbs up)
  • KG: Think the translation is relatively small, and affects (MSL?)
  • KG: I propose an array of 8 floats.
  • DN: Agree.
  • BC: Agree. Prefer don’t baking in the two vectors.
  • Consensus for array of floats.
  • DN: Need to make sure the output slots counting is clear. E.g. that array-of-4 floats really only counts as one output slot.
  • KG: What happens if you don’t write the outputs?
  • JS: If not written, then they are not clipped.
  • JB: Background question: by using these clipping planes we can chop up a triangle in more ways.
  • DN: You’re adding more clipping half planes.
  • JB: Never generates anything that’s concave? (correct)

@kdashg
Copy link
Contributor

kdashg commented Mar 13, 2024

GPU Web 2024-03-06 Pacific-time
  • JS: last WGSL meeting discussed this: widely supported, useful. Supported in WebGL as an extension. Think we should have it in WebGPU as an extension.
  • JS: small issue - HLSL style or Metal style. Think HLSL style is easier to implement in Vulkan. If Metal style, should at least have an if-statement to do a check.
  • KG: potentially have overhead if we don't optimize it. I don't like the HLSL style, but that's a WGSL style question rather than an API style question. Do we add this now? And is it an optional feature?
  • JS: yes, it'd be optional.
  • KG: think it's time to write a PR for this. Finish discussing the shape of the WGSL builtins in the WGSL meeting.
  • JS: we'll do it.
  • KG: thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api WebGPU API feature request A request for a new GPU feature exposed in the API investigation wgsl resolved Resolved - waiting for a change to the WGSL specification
Projects
None yet
Development

Successfully merging a pull request may close this issue.