Hash :
4f498eaa
Author :
Date :
2024-07-24T14:31:23
WebGPU: Add more format support This CL adds a new FormatTable class that initializes webgpu texture and vertex formats. It also adds this class to the display so it can be used in the ImageHelper. This CL changes the previously hardcoded RGBA8 texture format that was initially used when creating textures to use the format passed into the methods. Bug: angleproject:344814096 Change-Id: I768b85335329116496dbf721aac54d1137aaae9f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5660397 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Liza Burakova <liza@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
//
// 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);
}
}
}
} // namespace webgpu
} // namespace rx