Hash :
3cf7a604
Author :
Date :
2025-05-17T19:39:08
WebGPU: Add extensions for importing external textures Add EGL_ANGLE_device_webgpu which exposes the adapter and device used by ANGLE internally. Add EGL_ANGLE_webgpu_texture_client_buffer which allows importing external WGPUTexture handles if they share the same device as ANGLE (queried from EGL_ANGLE_device_webgpu). Bug: angleproject:418022112 Change-Id: I0683d36b84a0f8e0e9b68a5ec0d3aa8b7a95152c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6553063 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "libANGLE/renderer/wgpu/wgpu_format_utils.h"
#include "libANGLE/renderer/load_functions_table.h"
namespace rx
{
namespace
{
void FillTextureCaps(const angle::Format &angleFormat,
angle::FormatID formatID,
gl::TextureCaps *outTextureCaps)
{
if (formatID != angle::FormatID::NONE)
{
outTextureCaps->texturable = true;
}
outTextureCaps->filterable = true;
outTextureCaps->renderbuffer = true;
outTextureCaps->blendable = true;
}
} // namespace
namespace webgpu
{
Format::Format()
: mIntendedFormatID(angle::FormatID::NONE),
mIntendedGLFormat(GL_NONE),
mActualImageFormatID(angle::FormatID::NONE),
mActualBufferFormatID(angle::FormatID::NONE),
mImageInitializerFunction(nullptr),
mIsRenderable(false)
{}
void Format::initImageFallback(const ImageFormatInitInfo *info, int numInfo)
{
UNIMPLEMENTED();
}
void Format::initBufferFallback(const BufferFormatInitInfo *fallbackInfo, int numInfo)
{
UNIMPLEMENTED();
}
FormatTable::FormatTable() {}
FormatTable::~FormatTable() {}
void FormatTable::initialize()
{
for (size_t formatIndex = 0; formatIndex < angle::kNumANGLEFormats; ++formatIndex)
{
Format &format = mFormatData[formatIndex];
const auto intendedFormatID = static_cast<angle::FormatID>(formatIndex);
const angle::Format &intendedAngleFormat = angle::Format::Get(intendedFormatID);
format.initialize(intendedAngleFormat);
format.mIntendedFormatID = intendedFormatID;
gl::TextureCaps textureCaps;
FillTextureCaps(format.getActualImageFormat(), format.mActualImageFormatID, &textureCaps);
if (textureCaps.texturable)
{
format.mTextureLoadFunctions =
GetLoadFunctionsMap(format.mIntendedGLFormat, format.mActualImageFormatID);
}
}
}
const Format *FormatTable::findClosestTextureFormat(WGPUTextureFormat wgpuFormat) const
{
for (const Format &format : mFormatData)
{
// Accept formats with WGPUTextureFormats that match the request and are 1:1 with their
// intended format (not a fallback for something else)
if (format.getActualWgpuTextureFormat() == wgpuFormat &&
format.getIntendedFormatID() == format.getActualImageFormatID())
{
return &format;
}
}
return nullptr;
}
} // namespace webgpu
} // namespace rx