Remove stride in ExternalImageDescriptorDmaBuf

Use planeLayouts instead.

Bug: chromium:1258986
Change-Id: I16c041a8e0b739fa347ea4695988ad1eed82cccc
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92202
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
jchen10 2022-06-02 00:34:30 +00:00 committed by Dawn LUCI CQ
parent ccc1b2db0b
commit ad8caa2540
3 changed files with 15 additions and 18 deletions

View File

@ -102,8 +102,6 @@ struct DAWN_NATIVE_EXPORT PlaneLayout {
// Descriptor for dma-buf file descriptor image import // Descriptor for dma-buf file descriptor image import
struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD { struct DAWN_NATIVE_EXPORT ExternalImageDescriptorDmaBuf : ExternalImageDescriptorFD {
ExternalImageDescriptorDmaBuf(); ExternalImageDescriptorDmaBuf();
// To be removed after chromium's switch to planeLayouts.
uint32_t stride = 0u; // Stride of the buffer in bytes
static constexpr uint32_t kMaxPlanes = 3; static constexpr uint32_t kMaxPlanes = 3;
std::array<PlaneLayout, kMaxPlanes> planeLayouts; std::array<PlaneLayout, kMaxPlanes> planeLayouts;

View File

@ -320,16 +320,6 @@ ResultOrError<VkImage> Service::CreateImage(const ExternalImageDescriptor* descr
planeLayouts[plane].depthPitch = 0; // Not a depth texture planeLayouts[plane].depthPitch = 0; // Not a depth texture
} }
// For single plane formats.
// To be Removed after chromium's switch to planeLayouts.
if (dmaBufDescriptor->stride != 0) {
planeLayouts[0].offset = 0;
planeLayouts[0].size = 0; // VK_EXT_image_drm_format_modifier mandates size = 0.
planeLayouts[0].rowPitch = dmaBufDescriptor->stride;
planeLayouts[0].arrayPitch = 0; // Not an array texture
planeLayouts[0].depthPitch = 0; // Not a depth texture
}
VkImageDrmFormatModifierExplicitCreateInfoEXT explicitCreateInfo = {}; VkImageDrmFormatModifierExplicitCreateInfoEXT explicitCreateInfo = {};
explicitCreateInfo.drmFormatModifier = dmaBufDescriptor->drmModifier; explicitCreateInfo.drmFormatModifier = dmaBufDescriptor->drmModifier;
explicitCreateInfo.drmFormatModifierPlaneCount = planeCount; explicitCreateInfo.drmFormatModifierPlaneCount = planeCount;

View File

@ -51,8 +51,12 @@ class ExternalSemaphoreDmaBuf : public VulkanImageWrappingTestBackend::ExternalS
class ExternalTextureDmaBuf : public VulkanImageWrappingTestBackend::ExternalTexture { class ExternalTextureDmaBuf : public VulkanImageWrappingTestBackend::ExternalTexture {
public: public:
ExternalTextureDmaBuf(gbm_bo* bo, int fd, uint32_t stride, uint64_t drmModifier) ExternalTextureDmaBuf(
: mGbmBo(bo), mFd(fd), stride(stride), drmModifier(drmModifier) {} gbm_bo* bo,
int fd,
std::array<PlaneLayout, ExternalImageDescriptorDmaBuf::kMaxPlanes> planeLayouts,
uint64_t drmModifier)
: mGbmBo(bo), mFd(fd), planeLayouts(planeLayouts), drmModifier(drmModifier) {}
~ExternalTextureDmaBuf() override { ~ExternalTextureDmaBuf() override {
if (mFd != -1) { if (mFd != -1) {
@ -70,7 +74,7 @@ class ExternalTextureDmaBuf : public VulkanImageWrappingTestBackend::ExternalTex
int mFd = -1; int mFd = -1;
public: public:
const uint32_t stride; const std::array<PlaneLayout, ExternalImageDescriptorDmaBuf::kMaxPlanes> planeLayouts;
const uint64_t drmModifier; const uint64_t drmModifier;
}; };
@ -93,8 +97,13 @@ class VulkanImageWrappingTestBackendDmaBuf : public VulkanImageWrappingTestBacke
gbm_bo* bo = CreateGbmBo(width, height, true); gbm_bo* bo = CreateGbmBo(width, height, true);
return std::make_unique<ExternalTextureDmaBuf>( std::array<PlaneLayout, ExternalImageDescriptorDmaBuf::kMaxPlanes> planeLayouts;
bo, gbm_bo_get_fd(bo), gbm_bo_get_stride_for_plane(bo, 0), gbm_bo_get_modifier(bo)); for (int plane = 0; plane < gbm_bo_get_plane_count(bo); ++plane) {
planeLayouts[plane].stride = gbm_bo_get_stride_for_plane(bo, plane);
planeLayouts[plane].offset = gbm_bo_get_offset(bo, plane);
}
return std::make_unique<ExternalTextureDmaBuf>(bo, gbm_bo_get_fd(bo), planeLayouts,
gbm_bo_get_modifier(bo));
} }
wgpu::Texture WrapImage(const wgpu::Device& device, wgpu::Texture WrapImage(const wgpu::Device& device,
@ -115,7 +124,7 @@ class VulkanImageWrappingTestBackendDmaBuf : public VulkanImageWrappingTestBacke
descriptorDmaBuf.memoryFD = textureDmaBuf->Dup(); descriptorDmaBuf.memoryFD = textureDmaBuf->Dup();
descriptorDmaBuf.waitFDs = std::move(waitFDs); descriptorDmaBuf.waitFDs = std::move(waitFDs);
descriptorDmaBuf.stride = textureDmaBuf->stride; descriptorDmaBuf.planeLayouts = textureDmaBuf->planeLayouts;
descriptorDmaBuf.drmModifier = textureDmaBuf->drmModifier; descriptorDmaBuf.drmModifier = textureDmaBuf->drmModifier;
return wgpu::Texture::Acquire( return wgpu::Texture::Acquire(