Skip to content

Commit

Permalink
IGL: Add DeviceFeature for external memory objects
Browse files Browse the repository at this point in the history
Summary: This diff adds a new device feature indicating whether external memory objects are supported.

Reviewed By: corporateshark

Differential Revision: D48497571

fbshipit-source-id: 9e1dc12854117a234e5e3d666cc0811fb4c6c823
  • Loading branch information
Eric Griffith authored and facebook-github-bot committed Aug 22, 2023
1 parent b230a61 commit 4837419
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/igl/DeviceFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace igl {
* DrawIndexedIndirect Supports IRenderCommandEncoder::drawIndexedIndirect
* ExplicitBinding, Supports uniforms block explicit binding in shaders
* ExplicitBindingExt, Supports uniforms block explicit binding in shaders via an extension
* ExternalMemoryObjects, Supports accessing external memory objects, including by POSIX file descriptor
* MapBufferRange Supports mapping buffer data into client address space
* MinMaxBlend Supports Min and Max blend operations
* MultipleRenderTargets Supports MRT - Multiple Render Targets
Expand Down Expand Up @@ -72,6 +73,7 @@ enum class DeviceFeatures {
DrawIndexedIndirect,
ExplicitBinding,
ExplicitBindingExt,
ExternalMemoryObjects,
MapBufferRange,
MinMaxBlend,
MultipleRenderTargets,
Expand Down
2 changes: 2 additions & 0 deletions src/igl/metal/DeviceFeatureSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
return true;
case DeviceFeatures::ValidationLayersEnabled:
return false;
case DeviceFeatures::ExternalMemoryObjects:
return false;
}
return false;
}
Expand Down
4 changes: 4 additions & 0 deletions src/igl/opengl/DeviceFeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ bool DeviceFeatureSet::isFeatureSupported(DeviceFeatures feature) const {
case DeviceFeatures::ExplicitBindingExt:
return hasDesktopExtension(*this, "GL_ARB_shading_language_420pack");

case DeviceFeatures::ExternalMemoryObjects:
return hasDesktopOrESExtension(*this, "GL_EXT_memory_object") &&
hasDesktopOrESExtension(*this, "GL_EXT_memory_object_fd");

case DeviceFeatures::PushConstants:
return false;

Expand Down
6 changes: 6 additions & 0 deletions src/igl/tests/DeviceFeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ TEST_F(DeviceFeatureSetTest, hasFeatureForMacOSOrWinOrAndroidTest) {
deviceFeatures.isSupported("GL_ARB_texture_rg")));
EXPECT_EQ(iglDev_->hasFeature(DeviceFeatures::TextureFormatRG), textureFormatRG);
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ValidationLayersEnabled));
const bool externalMemoryObjects = deviceFeatures.isSupported("GL_EXT_memory_object") &&
deviceFeatures.isSupported("GL_EXT_memory_object_fd");
EXPECT_EQ(iglDev_->hasFeature(DeviceFeatures::ExternalMemoryObjects), externalMemoryObjects);
#endif // IGL_BACKEND_OPENGL
} else {
// non OpenGL backends
Expand Down Expand Up @@ -200,6 +203,7 @@ TEST_F(DeviceFeatureSetTest, hasFeatureForMacOSOrWinOrAndroidTest) {
#else
EXPECT_TRUE(iglDev_->hasFeature(DeviceFeatures::ValidationLayersEnabled));
#endif // IGL_PLATFORM_ANDROID
EXPECT_TRUE(iglDev_->hasFeature(DeviceFeatures::ExternalMemoryObjects));
} else if (iglDev_->getBackendType() == igl::BackendType::Metal) {
EXPECT_TRUE(iglDev_->hasFeature(DeviceFeatures::Texture2DArray));
EXPECT_TRUE(iglDev_->hasFeature(DeviceFeatures::Texture3D));
Expand All @@ -223,6 +227,7 @@ TEST_F(DeviceFeatureSetTest, hasFeatureForMacOSOrWinOrAndroidTest) {
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ExplicitBindingExt));
EXPECT_TRUE(iglDev_->hasFeature(DeviceFeatures::TextureFormatRG));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ValidationLayersEnabled));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ExternalMemoryObjects));
} else {
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::Texture2DArray));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::Texture3D));
Expand All @@ -246,6 +251,7 @@ TEST_F(DeviceFeatureSetTest, hasFeatureForMacOSOrWinOrAndroidTest) {
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ExplicitBindingExt));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::TextureFormatRG));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ValidationLayersEnabled));
EXPECT_FALSE(iglDev_->hasFeature(DeviceFeatures::ExternalMemoryObjects));
}
}

Expand Down
1 change: 1 addition & 0 deletions src/igl/tests/metal/DeviceFeatureSet.mm
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void TearDown() override {}
ASSERT_EQ(mtlDeviceFeatureSet.hasFeature(DeviceFeatures::TextureArrayExt), false);
ASSERT_EQ(mtlDeviceFeatureSet.hasFeature(DeviceFeatures::ExplicitBindingExt), false);
ASSERT_EQ(mtlDeviceFeatureSet.hasFeature(DeviceFeatures::ValidationLayersEnabled), false);
ASSERT_EQ(mtlDeviceFeatureSet.hasFeature(DeviceFeatures::ExternalMemoryObjects), false);
}

TEST_F(DeviceFeatureSetMTLTest, HasRequirementTest) {
Expand Down
2 changes: 2 additions & 0 deletions src/igl/vulkan/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,8 @@ bool Device::hasFeature(DeviceFeatures feature) const {
return true;
case DeviceFeatures::ExplicitBindingExt:
return false;
case DeviceFeatures::ExternalMemoryObjects:
return true;
case DeviceFeatures::TextureBindless:
return ctx_->vkPhysicalDeviceDescriptorIndexingProperties_
.shaderSampledImageArrayNonUniformIndexingNative == VK_TRUE;
Expand Down

0 comments on commit 4837419

Please sign in to comment.