WebGPURenderPassDescriptor.cpp [plain text]
#include "config.h"
#include "WebGPURenderPassDescriptor.h"
#if ENABLE(WEBGPU)
#include "GPURenderPassDescriptor.h"
#include "Logging.h"
namespace WebCore {
GPURenderPassColorAttachmentDescriptor::GPURenderPassColorAttachmentDescriptor(Ref<GPUTexture>&& texture, const GPURenderPassColorAttachmentDescriptorBase& base)
: GPURenderPassColorAttachmentDescriptorBase(base)
, attachment(WTFMove(texture))
{
}
GPURenderPassDepthStencilAttachmentDescriptor::GPURenderPassDepthStencilAttachmentDescriptor(Ref<GPUTexture>&& texture, const GPURenderPassDepthStencilAttachmentDescriptorBase& base)
: GPURenderPassDepthStencilAttachmentDescriptorBase(base)
, attachment(WTFMove(texture))
{
}
Optional<GPURenderPassDescriptor> WebGPURenderPassDescriptor::tryCreateGPURenderPassDescriptor() const
{
if (colorAttachments.isEmpty()) {
LOG(WebGPU, "GPURenderPassDescriptor: No color attachments specified for GPURenderPassDescriptor!");
return WTF::nullopt;
}
Vector<GPURenderPassColorAttachmentDescriptor> gpuColorAttachments;
for (const auto& colorAttachment : colorAttachments) {
if (!colorAttachment.attachment
|| !colorAttachment.attachment->texture()
|| !colorAttachment.attachment->texture()->isOutputAttachment()) {
LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassColorAttachmentDescriptor!");
return WTF::nullopt;
}
gpuColorAttachments.append(GPURenderPassColorAttachmentDescriptor { makeRef(*colorAttachment.attachment->texture()), colorAttachment });
}
Optional<GPURenderPassDepthStencilAttachmentDescriptor> gpuDepthAttachment;
if (depthStencilAttachment) {
if (!depthStencilAttachment->attachment
|| !depthStencilAttachment->attachment->texture()
|| !depthStencilAttachment->attachment->texture()->isOutputAttachment()) {
LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassDepthStencilAttachmentDescriptor!");
return WTF::nullopt;
}
gpuDepthAttachment = GPURenderPassDepthStencilAttachmentDescriptor { makeRef(*depthStencilAttachment->attachment->texture()), *depthStencilAttachment };
}
return GPURenderPassDescriptor { WTFMove(gpuColorAttachments), WTFMove(gpuDepthAttachment) };
}
}
#endif // ENABLE(WEBGPU)