Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…does not load

https://bugs.webkit.org/show_bug.cgi?id=270933
<radar://124555724>

Reviewed by Dan Glastonbury.

We weren't setting the view formats when configuring the GPUCanvasContext.

* Source/WebGPU/WebGPU/PresentationContextIOSurface.mm:
(WebGPU::PresentationContextIOSurface::configure):

Canonical link: https://commits.webkit.org/276230@main
  • Loading branch information
mwyrzykowski committed Mar 16, 2024
1 parent 6e7fffd commit 244f327
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/WebGPU/WebGPU/PresentationContextIOSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@
return format == WGPUTextureFormat_BGRA8Unorm || format == WGPUTextureFormat_RGBA8Unorm || format == WGPUTextureFormat_RGBA16Float;
};

auto allowedViewFormat = ^(WGPUTextureFormat format) {
return allowedFormat(Texture::removeSRGBSuffix(format));
};

auto& limits = device.limits();
auto width = std::min<uint32_t>(limits.maxTextureDimension2D, descriptor.width);
auto height = std::min<uint32_t>(limits.maxTextureDimension2D, descriptor.height);
Expand All @@ -100,8 +104,8 @@
effectiveFormat,
1,
1,
1,
&effectiveFormat,
descriptor.viewFormats.size() ?: 1,
descriptor.viewFormats.size() ? &descriptor.viewFormats[0] : &effectiveFormat,
};
MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:Texture::pixelFormat(effectiveFormat) width:width height:height mipmapped:NO];
textureDescriptor.usage = Texture::usage(descriptor.usage, effectiveFormat);
Expand All @@ -117,7 +121,7 @@
textureDescriptor.usage |= MTLTextureUsageShaderRead;
id<MTLTexture> luminanceClampTexture = [device.device() newTextureWithDescriptor:textureDescriptor];
luminanceClampTexture.label = fromAPI(descriptor.label);
auto viewFormats = Vector<WGPUTextureFormat> { Texture::pixelFormat(effectiveFormat) };
auto viewFormats = descriptor.viewFormats;
parentLuminanceClampTexture = Texture::create(luminanceClampTexture, wgpuTextureDescriptor, WTFMove(viewFormats), device);
parentLuminanceClampTexture->makeCanvasBacking();
textureDescriptor.pixelFormat = MTLPixelFormatBGRA8Unorm;
Expand All @@ -128,7 +132,7 @@

id<MTLTexture> texture = [device.device() newTextureWithDescriptor:textureDescriptor iosurface:bridge_cast(iosurface) plane:0];
texture.label = fromAPI(descriptor.label);
auto viewFormats = Vector<WGPUTextureFormat> { Texture::pixelFormat(effectiveFormat) };
auto viewFormats = descriptor.viewFormats;
auto parentTexture = Texture::create(texture, wgpuTextureDescriptor, WTFMove(viewFormats), device);
parentTexture->makeCanvasBacking();
m_renderBuffers.append({ parentTexture, parentLuminanceClampTexture });
Expand All @@ -146,7 +150,7 @@
}

for (auto viewFormat : descriptor.viewFormats) {
if (!allowedFormat(viewFormat)) {
if (!allowedViewFormat(viewFormat)) {
device.generateAValidationError("Requested texture view format BGRA8UnormStorage is not enabled"_s);
return;
}
Expand Down

0 comments on commit 244f327

Please sign in to comment.