Skip to content

Commit

Permalink
- Update vulkan headers and spirv-cross
Browse files Browse the repository at this point in the history
- Add mesh shader support in graphics api
  • Loading branch information
godlikepanos committed Oct 8, 2023
1 parent fe26924 commit 79377a4
Show file tree
Hide file tree
Showing 81 changed files with 120,414 additions and 50,196 deletions.
2 changes: 2 additions & 0 deletions AnKi/Gr/CommandBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ class CommandBuffer : public GrObject
void drawIndirectCount(PrimitiveTopology topology, Buffer* argBuffer, PtrSize argBufferOffset, U32 argBufferStride, Buffer* countBuffer,
PtrSize countBufferOffset, U32 maxDrawCount);

void drawMeshTasks(U32 groupCountX, U32 groupCountY, U32 groupCountZ);

void dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ);

void dispatchComputeIndirect(Buffer* argBuffer, PtrSize argBufferOffset);
Expand Down
27 changes: 18 additions & 9 deletions AnKi/Gr/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ class GpuDeviceCapabilities

/// DLSS.
Bool m_dlss = false;

/// Mesh shaders.
Bool m_meshShaders = false;
};
ANKI_END_PACKED_STRUCT

Expand Down Expand Up @@ -533,6 +536,8 @@ enum class ShaderType : U16
kTessellationControl,
kTessellationEvaluation,
kGeometry,
kTask,
kMesh,
kFragment,
kCompute,
kRayGen,
Expand All @@ -558,17 +563,21 @@ enum class ShaderTypeBit : U16
kTessellationControl = 1 << 1,
kTessellationEvaluation = 1 << 2,
kGeometry = 1 << 3,
kFragment = 1 << 4,
kCompute = 1 << 5,
kRayGen = 1 << 6,
kAnyHit = 1 << 7,
kClosestHit = 1 << 8,
kMiss = 1 << 9,
kIntersection = 1 << 10,
kCallable = 1 << 11,
kTask = 1 << 4,
kMesh = 1 << 5,
kFragment = 1 << 6,
kCompute = 1 << 7,
kRayGen = 1 << 8,
kAnyHit = 1 << 9,
kClosestHit = 1 << 10,
kMiss = 1 << 11,
kIntersection = 1 << 12,
kCallable = 1 << 13,

kNone = 0,
kAllGraphics = kVertex | kTessellationControl | kTessellationEvaluation | kGeometry | kFragment,
kAllGraphics = kVertex | kTessellationControl | kTessellationEvaluation | kGeometry | kTask | kMesh | kFragment,
kAllLegacyGeometry = kVertex | kTessellationControl | kTessellationEvaluation | kGeometry,
kAllModernGeometry = kTask | kMesh,
kAllRayTracing = kRayGen | kAnyHit | kClosestHit | kMiss | kIntersection | kCallable,
kAll = kAllGraphics | kCompute | kAllRayTracing,
};
Expand Down
1 change: 1 addition & 0 deletions AnKi/Gr/GrManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class NativeWindow;
extern BoolCVar g_vsyncCVar;
extern BoolCVar g_validationCVar;
extern BoolCVar g_debugMarkersCVar;
extern BoolCVar g_meshShadersCVar;

/// @addtogroup graphics
/// @{
Expand Down
20 changes: 18 additions & 2 deletions AnKi/Gr/ShaderProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,25 @@ Bool ShaderProgramInitInfo::isValid() const
}
}

if(!!graphicsMask && (graphicsMask & (ShaderTypeBit::kVertex | ShaderTypeBit::kFragment)) != (ShaderTypeBit::kVertex | ShaderTypeBit::kFragment))
if(!!graphicsMask)
{
return false;
if(!(graphicsMask & ShaderTypeBit::kFragment))
{
return false;
}

const Bool hasMesh = !!(graphicsMask & ShaderTypeBit::kAllModernGeometry);
const Bool hasVert = !!(graphicsMask & ShaderTypeBit::kAllLegacyGeometry);

if(hasMesh && !!(graphicsMask & ShaderTypeBit::kAllLegacyGeometry))
{
return false;
}

if(hasVert && !!(graphicsMask & ShaderTypeBit::kAllModernGeometry))
{
return false;
}
}

Bool compute = false;
Expand Down
6 changes: 6 additions & 0 deletions AnKi/Gr/Vulkan/CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ void CommandBuffer::drawIndexedIndirect(PrimitiveTopology topology, U32 drawCoun
self.drawIndexedIndirectInternal(topology, drawCount, offset, buff);
}

void CommandBuffer::drawMeshTasks(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
{
ANKI_VK_SELF(CommandBufferImpl);
self.drawMeshTasksInternal(groupCountX, groupCountY, groupCountZ);
}

void CommandBuffer::dispatchCompute(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
{
ANKI_VK_SELF(CommandBufferImpl);
Expand Down
7 changes: 7 additions & 0 deletions AnKi/Gr/Vulkan/CommandBufferImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,13 @@ class CommandBufferImpl final : public CommandBuffer
vkCmdDrawIndexedIndirect(m_handle, impl.getHandle(), offset, drawCount, sizeof(DrawIndexedIndirectArgs));
}

ANKI_FORCE_INLINE void drawMeshTasksInternal(U32 groupCountX, U32 groupCountY, U32 groupCountZ)
{
ANKI_ASSERT(!!(getGrManagerImpl().getExtensions() & VulkanExtensions::kEXT_mesh_shader));
drawcallCommon();
vkCmdDrawMeshTasksEXT(m_handle, groupCountX, groupCountY, groupCountZ);
}

ANKI_FORCE_INLINE void drawIndexedIndirectCountInternal(PrimitiveTopology topology, Buffer* argBuffer, PtrSize argBufferOffset,
U32 argBufferStride, Buffer* countBuffer, PtrSize countBufferOffset, U32 maxDrawCount)
{
Expand Down
10 changes: 10 additions & 0 deletions AnKi/Gr/Vulkan/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,16 @@ VkShaderStageFlags convertShaderTypeBit(ShaderTypeBit bit)
out |= VK_SHADER_STAGE_GEOMETRY_BIT;
}

if(!!(bit & ShaderTypeBit::kTask))
{
out |= VK_SHADER_STAGE_TASK_BIT_EXT;
}

if(!!(bit & ShaderTypeBit::kMesh))
{
out |= VK_SHADER_STAGE_MESH_BIT_EXT;
}

if(!!(bit & ShaderTypeBit::kFragment))
{
out |= VK_SHADER_STAGE_FRAGMENT_BIT;
Expand Down
5 changes: 3 additions & 2 deletions AnKi/Gr/Vulkan/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum class DescriptorType : U8
kCount
};

enum class VulkanExtensions : U32
enum class VulkanExtensions : U64
{
kNone = 0,
kKHR_xcb_surface = 1 << 1,
Expand Down Expand Up @@ -94,7 +94,8 @@ enum class VulkanExtensions : U32
kNVX_image_view_handle = 1 << 27,
kKHR_push_descriptor = 1 << 28,
kKHR_maintenance_4 = 1 << 29,
kKHR_draw_indirect_count = 1 << 30
kKHR_draw_indirect_count = 1 << 30,
kEXT_mesh_shader = 1 << 31
};
ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(VulkanExtensions)

Expand Down
Loading

0 comments on commit 79377a4

Please sign in to comment.