Skip to content

Commit

Permalink
igl | vulkan | Add a test for descriptor indexing
Browse files Browse the repository at this point in the history
Summary: Add a test for descriptor indexing.

Reviewed By: syeh1

Differential Revision: D48532138

fbshipit-source-id: f41f94f60e85ac9512517a01e3abc49cd615027a
  • Loading branch information
corporateshark authored and facebook-github-bot committed Aug 22, 2023
1 parent 015c466 commit 77de2d1
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion src/igl/tests/vulkan/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ GTEST_TEST(VulkanContext, BufferDeviceAddress) {
config.terminateOnValidationError = true;
#else
config.enableValidation = true;
config.terminateOnValidationError = true;
config.terminateOnValidationError = false;
#endif
config.enableExtraLogs = true;
config.enableBufferDeviceAddress = true;
Expand Down Expand Up @@ -111,6 +111,68 @@ GTEST_TEST(VulkanContext, BufferDeviceAddress) {

ASSERT_NE(buffer->gpuAddress(), 0u);
}

GTEST_TEST(VulkanContext, DescriptorIndexing) {
std::shared_ptr<igl::IDevice> iglDev = nullptr;

igl::vulkan::VulkanContextConfig config;
#if IGL_PLATFORM_MACOS
config.terminateOnValidationError = false;
#elif IGL_DEBUG
config.enableValidation = true;
config.terminateOnValidationError = true;
#else
config.enableValidation = true;
config.terminateOnValidationError = false;
#endif
config.enableExtraLogs = true;
config.enableDescriptorIndexing = true;

auto ctx = igl::vulkan::HWDevice::createContext(config, nullptr);

Result ret;

std::vector<HWDeviceDesc> devices = igl::vulkan::HWDevice::queryDevices(
*ctx.get(), HWDeviceQueryDesc(HWDeviceType::Unknown), &ret);

ASSERT_TRUE(!devices.empty());

if (ret.isOk()) {
std::vector<const char*> extraDeviceExtensions;
iglDev = igl::vulkan::HWDevice::create(std::move(ctx),
devices[0],
0, // width
0, // height,
0,
nullptr,
&ret);

if (!ret.isOk()) {
iglDev = nullptr;
}
}

ASSERT_TRUE(ret.isOk());
ASSERT_NE(iglDev, nullptr);

if (!iglDev)
return;

const TextureDesc texDesc = TextureDesc::new2D(TextureFormat::RGBA_UNorm8,
1,
1,
TextureDesc::TextureUsageBits::Sampled |
TextureDesc::TextureUsageBits::Attachment);

auto texture = iglDev->createTexture(texDesc, &ret);
ASSERT_EQ(ret.code, Result::Code::Ok);
ASSERT_NE(texture, nullptr);

if (!texture)
return;

ASSERT_NE(texture->getTextureId(), 0u);
}
#endif

} // namespace tests
Expand Down

0 comments on commit 77de2d1

Please sign in to comment.