From eedfcc6b74fe9c50025eaceaa8ed70f44b14824a Mon Sep 17 00:00:00 2001 From: Sascha Willems Date: Fri, 19 Apr 2024 10:34:12 +0200 Subject: [PATCH] Fixed closesthit shader --- .../raytracingpositionfetch/closesthit.rchit | 17 ++++++++--------- .../closesthit.rchit.spv | Bin 0 -> 2612 bytes .../raytracingpositionfetch/miss.rmiss.spv | Bin 0 -> 380 bytes .../raytracingpositionfetch/raygen.rgen.spv | Bin 0 -> 2388 bytes 4 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 shaders/hlsl/raytracingpositionfetch/closesthit.rchit.spv create mode 100644 shaders/hlsl/raytracingpositionfetch/miss.rmiss.spv create mode 100644 shaders/hlsl/raytracingpositionfetch/raygen.rgen.spv diff --git a/shaders/hlsl/raytracingpositionfetch/closesthit.rchit b/shaders/hlsl/raytracingpositionfetch/closesthit.rchit index 59e91df13..2223640cd 100644 --- a/shaders/hlsl/raytracingpositionfetch/closesthit.rchit +++ b/shaders/hlsl/raytracingpositionfetch/closesthit.rchit @@ -20,12 +20,16 @@ struct UBO float4x4 projInverse; float4 lightPos; }; -cbuffer ubo : register(b2) -{ - UBO ubo; -}; +ConstantBuffer ubo : register(b2); + +// We need to use special syntax for SPIR-V inlines +#define HitTriangleVertexPositionsKHR 5335 +#define RayTracingPositionFetchKHR 5336 [[vk::ext_extension("SPV_KHR_ray_tracing_position_fetch")]] +[[vk::ext_capability(RayTracingPositionFetchKHR)]] +[[vk::ext_builtin_input(HitTriangleVertexPositionsKHR)]] +const static float3 gl_HitTriangleVertexPositions[3]; [shader("closesthit")] void main(inout Payload p, in Attributes attribs) @@ -35,11 +39,6 @@ void main(inout Payload p, in Attributes attribs) // With VK_KHR_ray_tracing_position_fetch we can access the vertices for the hit triangle in the shader - // We need to use special syntax for SPIR-V inlines - #define HitTriangleVertexPositionsKHR 5391 - [[vk::ext_builtin_output(HitTriangleVertexPositionsKHR)]] - static float3 gl_HitTriangleVertexPositions[3]; - float3 vertexPos0 = gl_HitTriangleVertexPositions[0]; float3 vertexPos1 = gl_HitTriangleVertexPositions[1]; float3 vertexPos2 = gl_HitTriangleVertexPositions[2]; diff --git a/shaders/hlsl/raytracingpositionfetch/closesthit.rchit.spv b/shaders/hlsl/raytracingpositionfetch/closesthit.rchit.spv new file mode 100644 index 0000000000000000000000000000000000000000..cce003a5d2e04ccb936581f3e53086b7c4baf0de GIT binary patch literal 2612 zcmZvd*>77#6o)5^U1&o}TDkxw*e!dDS-MatX_FL4N&|5l8g|^9#7T^T9oaWQc>=^c z5)ywBkL?o=AR+O0@Pfqm-ONo3@ZH3| z{^PL_4u*1AsxLQg&fjiyv%N;%%~o6O4fuoq$2Yb+y;k1pv>WTqe3hh!h_}Mr!qP&m zm#@_>Tzu6!<6%TqtQ{uTuhbd_f0MP^@~(~|C8UfTKt}iz@8Vbr5Ahd5zPH`1UGKDe zdDhNnch=XN-P)bmMPkauIxbX`R%>H3uXlRJmSWAF zl@9i3co?pp?QM0kwIY|;XS0ZDZ_tyRb{_E`*sp@3vNU@+Mi!c*yyzWZgZr zx!q${`1K0hKaV-qoyj5OcV;DaKH}dZb~dLGAJ@fI#60sL=jC%|U;T%(_M^x=ammm8 zDb9HrH$A`&#_87|XKmxYN9Ndpx#f;y+j|8$ON90qg6Fkk;7713i1}O>k0U+_AI9!q zw|{e|d|cz=N%#op{=IusC&+gc+nV-zl3zwxaN@~0E4jp1@HqxHzk9I9$`Wc`*hFxUm{ZlZ7!cG z@;B%uw7&Ls7BODzUd|2Rmj`fd0KYPT{jl}tdu;%}K7h~nVP|(C;wk#^94;d6_ZE9` zW|ty|3Rjto{mSX@IlX~cUw>zQIdZ7N-~GzXux`CK5jo#0b9ioVA@V=sBff(8UdpGq zx3P`${Y!CE*zzgvDz>rm$>$ojxf7noHm1%l-QNsioPN`VJrXe;yK zk#{DZkvRFkgROt+RsVMpdHp>@aq@o;TYtYL_No6IBCo$^EKakS$F|4Rk2AZ0$p1vo z#=no)lYEN1iEUi!%eVzZKE-{2ZEx~F#9SX@o6ohBYZ2RAsb_Q55&4ws7PfuMr(CzO z&F7kX^S;V?hW5RLSl`|g_Yt;v5NB$PK4bArm$6+lkABwiJ&^aF+Uv&= zqaJXdM9$dc_i5yOr|Z=AyYU%fy#B6xS3Nhsb)O@C4}OmO`66=0r2f9dPW`!_`jdCQ zextrZN=TZobsLdi15QWG4o2ZFMg6YIyskHh+cJUQ_4x51AxiN*i z40C4ZJF|PQ@6}@qa%T3-{##}9>`*q#TV!ATVbbdklC|3>o3$IIiz%F+fpV2#j<06Y z-!5IK;SoMNB=0Cf3o=LF?dMB3#u42nn9b77(9O3K`9eF2ZaMmI)_(My}$r}}}AM3oZFB%y}YrAmtPL3-Li*0Z~~T{{R30 literal 0 HcmV?d00001 diff --git a/shaders/hlsl/raytracingpositionfetch/raygen.rgen.spv b/shaders/hlsl/raytracingpositionfetch/raygen.rgen.spv new file mode 100644 index 0000000000000000000000000000000000000000..5535f2ed86ea22bf27dbdbb4477e3addd88fa49d GIT binary patch literal 2388 zcmZ9MZEsXn5XTQ~cM+_`@{D5H0zOh#ML-0hMUWP#bfH>bndWADgKOIEdb_PQF;T-C zUm3mCF7+;mpjrXNQN*>Z05x_al7$;k+nPPkHX8uTXA-NalX0HUuj;r_@Q;j!my(B z9U$uI;lN2DtYw{balIpO4X(p`;g{fH{=~Kju7T`B&)V&LH7~M$r@Ow`FE-o#%_6_Q zgntlQY#3Xo#}NA4y}WsTrP*1_9_83IPO<)TyGA!LuAQx+;vXq7b)g#FjH2Jn);P6Q zbbEQx@8q0fY`yfUZ*}q?@2qd-#YVn^yNh1Y{XXIL=xl?!BjFYFR<^y`%~r}BZRxvC ze<@qtwB@pAchQS+&QRUmEVlb|jz8I}w!75+E86Byz>`pdf| z-x;cYZT^J3khIuo)u-$par95Yq(s{FNM9hAUqK_dP z@HsNn55Um$F>HGgGj@vJwfXeR7~@jTL3C&)*@sH=*XfkQs)Lw(gt|wN4cI=-(LTD% zK87u&n#Tubu&)#7_T`LIY+U;_*qFqgm2zK4?;d=7CD|vj!_3Ls_VNa5LmSesoxX=; zp8`w0rub)I{~R7F-(7>eNo>h?c!K}FF?%%6{UuTtGv{;!jXjR-9XX40P4M4uKun&9 z_alDll>98wHN5Xxz5AJ$dYIFi12&=7}oz={QfUQ%y*FT zFQQvhma6%eu=W2Q^FKkihWH;5yNoXGJ9-?kPtnC0H{4)z?)wVt&U_ob7w2*RS7Ch* z$n}mtgUy!`b`4$3-dgd^Tt_!nUwWTUsNpv_4ePgdI)4T|oo^56{2S={Qts#IzDMx| zZq2*835&~;eGI|Le+%6+Whwbbnce&^BBnGp&2>Ba5Ifjx#H^9x<|5{qY5qIt<{Piy z-;OlHU3C4`8SY_=%TnsG#Xb0T=3&3d>wIl~tJ>~pAM#7s_weobXsMqu{Ui)b(3W`j0JLhW`gcJ(z?5 literal 0 HcmV?d00001