فهرست منبع

Add special PerPrimitiveEXT decoration as a SPIRV intrinsic

Panagiotis Christopoulos Charitos 1 سال پیش
والد
کامیت
4a7bc97f32
2فایلهای تغییر یافته به همراه14 افزوده شده و 5 حذف شده
  1. 9 0
      AnKi/Shaders/Common.hlsl
  2. 5 5
      AnKi/Shaders/GBufferGeneric.ankiprog

+ 9 - 0
AnKi/Shaders/Common.hlsl

@@ -131,3 +131,12 @@ U32 checkStructuredBuffer(T buff, U32 idx)
 
 // Safely access a structured buffer. Throw an assertion if it's out of bounds
 #define SBUFF(buff, idx) buff[(idx) + checkStructuredBuffer(buff, idx)]
+
+// Need extra decoration for per-primitive stuff in Vulkan. Remove when https://github.com/microsoft/DirectXShaderCompiler/issues/6862 is fixed
+#if ANKI_GR_BACKEND_VULKAN
+#	define ANKI_PER_PRIMITIVE_VAR [[vk::ext_extension("SPV_EXT_mesh_shader")]] [[vk::ext_capability(5283 /*MeshShadingEXT*/)]]
+#	define ANKI_PER_PRIMITIVE_MEMBER [[vk::ext_decorate(5271 /*PerPrimitiveEXT*/)]]
+#else
+#	define ANKI_PER_PRIMITIVE_VAR
+#	define ANKI_PER_PRIMITIVE_MEMBER
+#endif

+ 5 - 5
AnKi/Shaders/GBufferGeneric.ankiprog

@@ -144,13 +144,13 @@ struct MeshPerVertOut
 
 struct MeshPerPrimitiveOut
 {
-	U32 m_constantsOffset : UNIS_OFFSET;
+	ANKI_PER_PRIMITIVE_MEMBER U32 m_constantsOffset : UNIS_OFFSET;
 
 #if VISUALIZE_MESHLETS
-	U32 m_meshletIndex : MESHLET_INDEX;
+	ANKI_PER_PRIMITIVE_MEMBER U32 m_meshletIndex : MESHLET_INDEX;
 #endif
 
-	Bool m_cullPrimitive : SV_CULLPRIMITIVE;
+	ANKI_PER_PRIMITIVE_MEMBER Bool m_cullPrimitive : SV_CULLPRIMITIVE;
 };
 
 struct FragOut
@@ -461,7 +461,7 @@ void main()
 
 void main(
 #		if ANKI_TECHNIQUE_ShadowsMeshShaders
-	MeshPerVertOut vertInput, MeshPerPrimitiveOut primInput
+	MeshPerVertOut vertInput, ANKI_PER_PRIMITIVE_VAR MeshPerPrimitiveOut primInput
 #		else
 	VertOut vertInput
 #		endif
@@ -485,7 +485,7 @@ void main(
 
 FragOut main(
 #		if ANKI_TECHNIQUE_GBufferMeshShaders
-	MeshPerVertOut vertInput, MeshPerPrimitiveOut primInput
+	MeshPerVertOut vertInput, ANKI_PER_PRIMITIVE_VAR MeshPerPrimitiveOut primInput
 #		else
 	VertOut vertInput
 #		endif