Skip to content

Commit

Permalink
Meshlet examples compile now with older Vulkan SDKs, also fixed some …
Browse files Browse the repository at this point in the history
…compiler warnings
  • Loading branch information
johannesugb committed Sep 16, 2023
1 parent e684524 commit 78717ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 6 additions & 2 deletions examples/skinned_meshlets/source/skinned_meshlets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,10 @@ class skinned_meshlets_app : public avk::invokee
// Draw all the meshlets with just one single draw call:
command::conditional(
[this]() { return mUseNvPipeline.value_or(false); },
[this]() { return command::draw_mesh_tasks_nv(div_ceil(mNumMeshlets, mTaskInvocationsNv), 0); },
[this]() { return command::draw_mesh_tasks_ext(div_ceil(mNumMeshlets, mTaskInvocationsExt), 1, 1); }
[this]() { return command::draw_mesh_tasks_nv(div_ceil(mNumMeshlets, mTaskInvocationsNv), 0); }
#if VK_HEADER_VERSION >= 239
, [this]() { return command::draw_mesh_tasks_ext(div_ceil(mNumMeshlets, mTaskInvocationsExt), 1, 1); }
#endif
)
}),

Expand Down Expand Up @@ -743,12 +745,14 @@ int main() // <== Starting point ==
// Gotta enable the mesh shader extension, ...
avk::required_device_extensions(VK_EXT_MESH_SHADER_EXTENSION_NAME),
avk::optional_device_extensions(VK_NV_MESH_SHADER_EXTENSION_NAME),
#if VK_HEADER_VERSION >= 239
// ... and enable the mesh shader features that we need:
[](vk::PhysicalDeviceMeshShaderFeaturesEXT& meshShaderFeatures) {
meshShaderFeatures.setMeshShader(VK_TRUE);
meshShaderFeatures.setTaskShader(VK_TRUE);
meshShaderFeatures.setMeshShaderQueries(VK_TRUE);
},
#endif
[](vk::PhysicalDeviceFeatures& features) {
features.setPipelineStatisticsQuery(VK_TRUE);
},
Expand Down
18 changes: 11 additions & 7 deletions examples/static_meshlets/source/static_meshlets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ class static_meshlets_app : public avk::invokee

mPipelineStatsPool = avk::context().create_query_pool_for_pipeline_statistics_queries(
vk::QueryPipelineStatisticFlagBits::eFragmentShaderInvocations | vk::QueryPipelineStatisticFlagBits::eMeshShaderInvocationsEXT | vk::QueryPipelineStatisticFlagBits::eTaskShaderInvocationsEXT,
avk::context().main_window()->number_of_frames_in_flight()
static_cast<uint32_t>(avk::context().main_window()->number_of_frames_in_flight())
);
}

Expand Down Expand Up @@ -451,12 +451,12 @@ class static_meshlets_app : public avk::invokee
mLastFrameDuration = timers[1] - mLastTimestamp;
mLastTimestamp = timers[1];

mPipelineStats = mPipelineStatsPool->get_results<uint64_t, 3>(inFlightIndex, 1, vk::QueryResultFlagBits::e64);
mPipelineStats = mPipelineStatsPool->get_results<uint64_t, 3>(static_cast<uint32_t>(inFlightIndex), 1, vk::QueryResultFlagBits::e64);
}
auto& pipeline = mUseNvPipeline.value_or(false) ? mPipelineNv : mPipelineExt;
context().record({
mPipelineStatsPool->reset(inFlightIndex, 1),
mPipelineStatsPool->begin_query(inFlightIndex),
mPipelineStatsPool->reset(static_cast<uint32_t>(inFlightIndex), 1),
mPipelineStatsPool->begin_query(static_cast<uint32_t>(inFlightIndex)),
mTimestampPool->reset(firstQueryIndex, 2), // reset the two values relevant for the current frame in flight
mTimestampPool->write_timestamp(firstQueryIndex + 0, stage::all_commands), // measure before drawMeshTasks*

Expand Down Expand Up @@ -486,13 +486,15 @@ mViewProjBuffers[inFlightIndex]->fill(glm::value_ptr(viewProjMat), 0),
// Draw all the meshlets with just one single draw call:
command::conditional(
[this]() { return mUseNvPipeline.value_or(false); },
[this]() { return command::draw_mesh_tasks_nv (div_ceil(mNumMeshlets, mTaskInvocationsNv ), 0); },
[this]() { return command::draw_mesh_tasks_ext(div_ceil(mNumMeshlets, mTaskInvocationsExt), 1, 1); }
[this]() { return command::draw_mesh_tasks_nv (div_ceil(mNumMeshlets, mTaskInvocationsNv ), 0); }
#if VK_HEADER_VERSION >= 239
, [this]() { return command::draw_mesh_tasks_ext(div_ceil(mNumMeshlets, mTaskInvocationsExt), 1, 1); }
#endif
)
}),

mTimestampPool->write_timestamp(firstQueryIndex + 1, stage::mesh_shader),
mPipelineStatsPool->end_query(inFlightIndex)
mPipelineStatsPool->end_query(static_cast<uint32_t>(inFlightIndex))
})
.into_command_buffer(cmdBfr)
.then_submit_to(*mQueue)
Expand Down Expand Up @@ -574,12 +576,14 @@ int main() // <== Starting point ==
// Gotta enable the mesh shader extension, ...
avk::required_device_extensions(VK_EXT_MESH_SHADER_EXTENSION_NAME),
avk::optional_device_extensions(VK_NV_MESH_SHADER_EXTENSION_NAME),
#if VK_HEADER_VERSION >= 239
// ... and enable the mesh shader features that we need:
[](vk::PhysicalDeviceMeshShaderFeaturesEXT& meshShaderFeatures) {
meshShaderFeatures.setMeshShader(VK_TRUE);
meshShaderFeatures.setTaskShader(VK_TRUE);
meshShaderFeatures.setMeshShaderQueries(VK_TRUE);
},
#endif
[](vk::PhysicalDeviceFeatures& features) {
features.setPipelineStatisticsQuery(VK_TRUE);
},
Expand Down

0 comments on commit 78717ca

Please sign in to comment.