Skip to content

Commit

Permalink
igl | tests | Improve DeviceVulkanTest::StagingDeviceLargeBufferTest
Browse files Browse the repository at this point in the history
Summary: Improved `DeviceVulkanTest::StagingDeviceLargeBufferTest` by checking the actual buffer sizes.

Reviewed By: mmaurer

Differential Revision: D50139941

fbshipit-source-id: e9ffa6f9bf11ad243a70355e4c13f546116823cb
  • Loading branch information
corporateshark authored and facebook-github-bot committed Oct 12, 2023
1 parent 652a366 commit 6b21e50
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/igl/tests/vulkan/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../util/TestDevice.h"

#if IGL_PLATFORM_WIN || IGL_PLATFORM_ANDROID || IGL_PLATFORM_MACOS || IGL_PLATFORM_LINUX
#include <igl/vulkan/Device.h>
#include <igl/vulkan/HWDevice.h>
#include <igl/vulkan/VulkanContext.h>
#endif
Expand Down Expand Up @@ -53,6 +54,7 @@ TEST_F(DeviceVulkanTest, CreateCommandQueue) {
ASSERT_NE(cmdQueue, nullptr);
}

#if IGL_PLATFORM_WIN || IGL_PLATFORM_ANDROID || IGL_PLATFORM_MACOS || IGL_PLATFORM_LINUX
TEST_F(DeviceVulkanTest, StagingDeviceLargeBufferTest) {
Result ret;

Expand All @@ -62,11 +64,17 @@ TEST_F(DeviceVulkanTest, StagingDeviceLargeBufferTest) {
bufferDesc.type = BufferDesc::BufferTypeBits::Storage;
bufferDesc.storage = ResourceStorage::Private;

constexpr size_t kDesiredBufferLength = 256u * 1024u * 1024u + 2u;
igl::vulkan::VulkanContext& ctx =
static_cast<igl::vulkan::Device*>(iglDev_.get())->getVulkanContext();

const VkDeviceSize kMaxStagingBufferSize = ctx.stagingDevice_->getMaxStagingBufferSize();

const VkDeviceSize kDesiredBufferSize = kMaxStagingBufferSize + 2u;

size_t maxBufferLength = 0;
iglDev_->getFeatureLimits(DeviceFeatureLimits::MaxStorageBufferBytes, maxBufferLength);

bufferDesc.length = std::min(kDesiredBufferLength, maxBufferLength);
bufferDesc.length = std::min(static_cast<size_t>(kDesiredBufferSize), maxBufferLength);

ASSERT_TRUE(bufferDesc.length % 2 == 0);

Expand Down Expand Up @@ -104,9 +112,14 @@ TEST_F(DeviceVulkanTest, StagingDeviceLargeBufferTest) {
}

ASSERT_EQ(ret.code, Result::Code::Ok);

if (ctx.useStaging_) {
// do not check if we are not using a staging buffer
const VkDeviceSize stagingBufferSize = ctx.stagingDevice_->getCurrentStagingBufferSize();
ASSERT_EQ(stagingBufferSize, kMaxStagingBufferSize);
}
}

#if IGL_PLATFORM_WIN || IGL_PLATFORM_ANDROID || IGL_PLATFORM_MACOS || IGL_PLATFORM_LINUX
GTEST_TEST(VulkanContext, BufferDeviceAddress) {
std::shared_ptr<igl::IDevice> iglDev = nullptr;

Expand Down

0 comments on commit 6b21e50

Please sign in to comment.