Skip to content

Commit

Permalink
igl | vulkan | Add custom debug name to Device
Browse files Browse the repository at this point in the history
Reviewed By: EricGriffith, syeh1, Denis-Prof, maliarov

Differential Revision: D66465056

fbshipit-source-id: 591deb23c54b3a5ef169c648ff7bb30bca2cedbf
  • Loading branch information
mmaurer authored and facebook-github-bot committed Dec 4, 2024
1 parent 7fc5142 commit 13f02ac
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions shell/android/jni/TinyRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ void TinyRenderer::init(AAssetManager* mgr,
0,
nullptr,
&vulkanFeatures,
"TinyRenderer",
&result);
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/igl/tests/util/device/vulkan/TestDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ std::shared_ptr<::igl::IDevice> createTestDevice(const igl::vulkan::VulkanContex
extraDeviceExtensions.size(),
extraDeviceExtensions.data(),
&features,
"Test Device",
&ret);

if (!ret.isOk()) {
Expand Down
2 changes: 2 additions & 0 deletions src/igl/tests/vulkan/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ GTEST_TEST(VulkanContext, BufferDeviceAddress) {
0,
nullptr,
&features,
"DeviceVulkanTest",
&ret);

if (!ret.isOk()) {
Expand Down Expand Up @@ -368,6 +369,7 @@ GTEST_TEST(VulkanContext, DescriptorIndexing) {
0,
nullptr,
&features,
"VulkanContext Test",
&ret);

if (!ret.isOk()) {
Expand Down
4 changes: 3 additions & 1 deletion src/igl/vulkan/HWDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ std::unique_ptr<IDevice> HWDevice::create(std::unique_ptr<VulkanContext> ctx,
const char* IGL_NULLABLE* IGL_NULLABLE
extraDeviceExtensions,
const igl::vulkan::VulkanFeatures* IGL_NULLABLE features,
const char* IGL_NULLABLE debugName,
Result* IGL_NULLABLE outResult) {
IGL_DEBUG_ASSERT(ctx);

auto result = ctx->initContext(desc, numExtraDeviceExtensions, extraDeviceExtensions, features);
auto result =
ctx->initContext(desc, numExtraDeviceExtensions, extraDeviceExtensions, features, debugName);

Result::setResult(outResult, result);

Expand Down
1 change: 1 addition & 0 deletions src/igl/vulkan/HWDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class HWDevice final {
size_t numExtraDeviceExtensions = 0,
const char* IGL_NULLABLE* IGL_NULLABLE extraDeviceExtensions = nullptr,
const igl::vulkan::VulkanFeatures* IGL_NULLABLE features = nullptr,
const char* IGL_NULLABLE debugName = nullptr,
Result* IGL_NULLABLE outResult = nullptr);
};

Expand Down
8 changes: 5 additions & 3 deletions src/igl/vulkan/VulkanContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ igl::Result VulkanContext::queryDevices(const HWDeviceQueryDesc& desc,
igl::Result VulkanContext::initContext(const HWDeviceDesc& desc,
size_t numExtraDeviceExtensions,
const char* IGL_NULLABLE* IGL_NULLABLE extraDeviceExtensions,
const VulkanFeatures* IGL_NULLABLE requestedFeatures) {
const VulkanFeatures* IGL_NULLABLE requestedFeatures,
const char* IGL_NULLABLE debugName) {
if (desc.guid == 0UL) {
IGL_LOG_ERROR("Invalid hardwareGuid(%lu)", desc.guid);
return Result(Result::Code::Unsupported, "Vulkan is not supported");
Expand Down Expand Up @@ -708,6 +709,7 @@ igl::Result VulkanContext::initContext(const HWDeviceDesc& desc,
const uint32_t apiVersion = vkPhysicalDeviceProperties2_.properties.apiVersion;

if (config_.enableExtraLogs) {
IGL_LOG_INFO("Device: %s\n", debugName ? debugName : "igl/vulkan/VulkanContext.cpp");
IGL_LOG_INFO("Vulkan physical device: %s\n",
vkPhysicalDeviceProperties2_.properties.deviceName);
IGL_LOG_INFO(" API version: %i.%i.%i.%i\n",
Expand Down Expand Up @@ -825,8 +827,8 @@ igl::Result VulkanContext::initContext(const HWDeviceDesc& desc,
vf_.vkGetDeviceQueue(
device, deviceQueues_.computeQueueFamilyIndex, 0, &deviceQueues_.computeQueue);

device_ =
std::make_unique<igl::vulkan::VulkanDevice>(vf_, device, "Device: VulkanContext::device_");
device_ = std::make_unique<igl::vulkan::VulkanDevice>(
vf_, device, IGL_FORMAT("Device: VulkanContext::device_ {}", debugName).c_str());
immediate_ =
std::make_unique<igl::vulkan::VulkanImmediateCommands>(vf_,
device,
Expand Down
3 changes: 2 additions & 1 deletion src/igl/vulkan/VulkanContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ class VulkanContext final {
igl::Result initContext(const HWDeviceDesc& desc,
size_t numExtraDeviceExtensions = 0,
const char* IGL_NULLABLE* IGL_NULLABLE extraDeviceExtensions = nullptr,
const VulkanFeatures* IGL_NULLABLE requestedFeatures = nullptr);
const VulkanFeatures* IGL_NULLABLE requestedFeatures = nullptr,
const char* IGL_NULLABLE debugName = nullptr);

igl::Result initSwapchain(uint32_t width, uint32_t height);
VkExtent2D getSwapchainExtent() const;
Expand Down

0 comments on commit 13f02ac

Please sign in to comment.