Skip to content

Commit 0cfdd95

Browse files
committed
Upgrade the sample for version 2 of VK_AMDX_shader_enqueue
Changes: - Added mesh node samples - Removed SPIR-V intrinsics-based shaders - Updated HLSL shaders to use the node syntax (HLSL needs offline compilation to SPIR-V)
1 parent ad4e45d commit 0cfdd95

117 files changed

Lines changed: 3790 additions & 2482 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2020-2023, Arm Limited and Contributors
2+
# Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
#
34
# SPDX-License-Identifier: Apache-2.0
45
#
@@ -46,6 +47,10 @@ add_compile_definitions($<$<CONFIG:DEBUG>:VKB_DEBUG>)
4647

4748
project(vulkan_samples)
4849

50+
if(MSVC)
51+
add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING)
52+
endif()
53+
4954
# create output folder
5055
file(MAKE_DIRECTORY output)
5156

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ AMD sample code license:
22

33
MIT License
44

5-
Copyright (c) 2023 Advanced Micro Devices, Inc.
5+
Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All rights reserved.
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy
88
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,19 @@ access to GPU Work Graphs feature on Radeon&trade; RX 7000 series graphics cards
2424

2525
To build the sample, follow the standard build instructions.
2626

27-
To run the sample, execute with the arguments `sample gpu_dispatch`.
27+
To run the compute sample, execute with the arguments `sample gpu_dispatch`.
2828
See more details and command line options in the [readme](./samples/extensions/gpu_dispatch/README.md).
2929

30+
To run the mesh draw sample, execute with the arguments `sample gpu_draw_dispatch`.
31+
See more details and command line options in the [readme](./samples/extensions/gpu_draw_dispatch/README.md).
32+
3033
Navigate to the following paths to learn more:
31-
- [source code](./samples/extensions/gpu_dispatch)
32-
- [shaders](./shaders/gpu_dispatch)
34+
- Source code
35+
- [samples/extensions/gpu_dispatch](./samples/extensions/gpu_dispatch)
36+
- [samples/extensions/gpu_draw_dispatch](./samples/extensions/gpu_draw_dispatch)
37+
- Shaders
38+
- [shaders/gpu_dispatch](./shaders/gpu_dispatch)
39+
- [shaders/gpu_draw_dispatch](./shaders/gpu_draw_dispatch)
3340

3441
# Vulkan Samples <!-- omit in toc -->
3542

app/plugins/benchmark_mode/benchmark_mode.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2020-2021, Arm Limited and Contributors
2+
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
@@ -39,12 +40,16 @@ void BenchmarkMode::init(const vkb::CommandParser &parser)
3940
// Whilst in benchmark mode fix the fps so that separate runs are consistently simulated
4041
// This will effect the graph outputs of framerate
4142
platform->force_simulation_fps(60.0f);
43+
enabled = true;
4244
}
4345

4446
void BenchmarkMode::on_update(float delta_time)
4547
{
46-
elapsed_time += delta_time;
47-
total_frames++;
48+
if (enabled)
49+
{
50+
elapsed_time += delta_time;
51+
total_frames++;
52+
}
4853
}
4954

5055
void BenchmarkMode::on_app_start(const std::string &app_id)
@@ -58,4 +63,10 @@ void BenchmarkMode::on_app_close(const std::string &app_id)
5863
{
5964
LOGI("Benchmark for {} completed in {} seconds (ran {} frames, averaged {} fps)", app_id, elapsed_time, total_frames, total_frames / elapsed_time);
6065
}
61-
} // namespace plugins
66+
67+
void BenchmarkMode::set_enabled(bool is_enabled)
68+
{
69+
enabled = is_enabled;
70+
}
71+
72+
} // namespace plugins

app/plugins/benchmark_mode/benchmark_mode.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2020-2021, Arm Limited and Contributors
2+
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
@@ -27,11 +28,11 @@ using BenchmarkModeTags = vkb::PluginBase<BenchmarkMode, vkb::tags::Passive>;
2728

2829
/**
2930
* @brief Benchmark Mode
30-
*
31+
*
3132
* When enabled frame time statistics of a samples run will be printed to the console when an application closes. The simulation frame time (delta time) is also locked to 60FPS so that statistics can be compared more accurately across different devices.
32-
*
33+
*
3334
* Usage: vulkan_samples sample afbc --benchmark
34-
*
35+
*
3536
*/
3637
class BenchmarkMode : public BenchmarkModeTags
3738
{
@@ -50,9 +51,13 @@ class BenchmarkMode : public BenchmarkModeTags
5051

5152
virtual void on_app_close(const std::string &app_info) override;
5253

54+
void set_enabled(bool is_enabled);
55+
5356
vkb::FlagCommand benchmark_flag = {vkb::FlagType::FlagOnly, "benchmark", "", "Enable benchmark mode"};
5457

5558
private:
59+
bool enabled{false};
60+
5661
uint32_t total_frames{0};
5762

5863
float elapsed_time{0.0f};

app/plugins/generic_options/generic_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
1+
// Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All Rights Reserved.
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to deal

app/plugins/generic_options/generic_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
1+
// Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All Rights Reserved.
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to deal

app/plugins/stop_after/stop_after.cpp

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2020-2021, Arm Limited and Contributors
2+
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
@@ -22,27 +23,45 @@ namespace plugins
2223
StopAfter::StopAfter() :
2324
StopAfterTags("Stop After X",
2425
"A collection of flags to stop the running application after a set period.",
25-
{vkb::Hook::OnUpdate}, {&stop_after_frame_flag})
26+
{vkb::Hook::OnUpdate},
27+
{&stop_after_frame_flag, &stop_after_seconds_flag})
2628
{
2729
}
2830

2931
bool StopAfter::is_active(const vkb::CommandParser &parser)
3032
{
31-
return parser.contains(&stop_after_frame_flag);
33+
return parser.contains(&stop_after_frame_flag) || parser.contains(&stop_after_seconds_flag);
3234
}
3335

3436
void StopAfter::init(const vkb::CommandParser &parser)
3537
{
38+
enabled = true;
39+
3640
remaining_frames = parser.as<uint32_t>(&stop_after_frame_flag);
41+
use_frames = (remaining_frames > 0);
42+
43+
remaining_time = parser.as<float>(&stop_after_seconds_flag);
44+
use_time = (remaining_time > 0.0f);
3745
}
3846

3947
void StopAfter::on_update(float delta_time)
4048
{
41-
remaining_frames--;
42-
43-
if (remaining_frames <= 0)
49+
if (enabled)
4450
{
45-
platform->close();
51+
remaining_frames--;
52+
remaining_time -= delta_time;
53+
54+
if ((use_frames && (remaining_frames <= 0)) ||
55+
(use_time && (remaining_time <= 0.0f)))
56+
{
57+
platform->close();
58+
}
4659
}
4760
}
48-
} // namespace plugins
61+
62+
void StopAfter::set_enabled(bool is_enabled)
63+
{
64+
enabled = is_enabled;
65+
}
66+
67+
} // namespace plugins

app/plugins/stop_after/stop_after.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2020-2021, Arm Limited and Contributors
2+
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
@@ -21,17 +22,17 @@
2122

2223
namespace plugins
2324
{
24-
using StopAfterTags = vkb::PluginBase<vkb::tags::Stopping>;
25+
class StopAfter;
26+
27+
using StopAfterTags = vkb::PluginBase<StopAfter, vkb::tags::Stopping>;
2528

2629
/**
2730
* @brief Stop After
28-
*
31+
*
2932
* Stop the execution of the app after a specific frame.
30-
*
33+
*
3134
* Usage: vulkan_sample sample afbc --stop-after-frame 100
32-
*
33-
* TODO: Add stop after duration
34-
*
35+
*
3536
*/
3637
class StopAfter : public StopAfterTags
3738
{
@@ -46,9 +47,18 @@ class StopAfter : public StopAfterTags
4647

4748
virtual void on_update(float delta_time) override;
4849

50+
void set_enabled(bool is_enabled);
51+
4952
vkb::FlagCommand stop_after_frame_flag = {vkb::FlagType::OneValue, "stop-after-frame", "", "Stop the application after a certain number of frames"};
53+
vkb::FlagCommand stop_after_seconds_flag = {vkb::FlagType::OneValue, "stop-after-seconds", "", "Stop the application after elapsed time in seconds"};
5054

5155
private:
56+
bool enabled{false};
57+
58+
bool use_frames{false};
5259
uint32_t remaining_frames{0};
60+
61+
bool use_time{false};
62+
float remaining_time{0.0f};
5363
};
5464
} // namespace plugins

framework/api_vulkan_sample.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* Copyright (c) 2019-2023, Sascha Willems
2+
* Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
23
*
34
* SPDX-License-Identifier: Apache-2.0
45
*
@@ -1270,11 +1271,11 @@ Texture ApiVulkanSample::load_texture_cubemap(const std::string &file, vkb::sg::
12701271
return texture;
12711272
}
12721273

1273-
std::unique_ptr<vkb::sg::SubMesh> ApiVulkanSample::load_model(const std::string &file, uint32_t index)
1274+
std::unique_ptr<vkb::sg::SubMesh> ApiVulkanSample::load_model(const std::string &file, uint32_t index, bool mesh_shader_buffer)
12741275
{
1275-
vkb::GLTFLoader loader{*device};
1276+
vkb::GLTFLoader loader{get_device()};
12761277

1277-
std::unique_ptr<vkb::sg::SubMesh> model = loader.read_model_from_file(file, index);
1278+
std::unique_ptr<vkb::sg::SubMesh> model = loader.read_model_from_file(file, index, mesh_shader_buffer);
12781279

12791280
if (!model)
12801281
{

0 commit comments

Comments
 (0)