Title: [291593] trunk/Source/WebGPU
Revision
291593
Author
mmaxfi...@apple.com
Date
2022-03-21 18:19:00 -0700 (Mon, 21 Mar 2022)

Log Message

[WebGPU] maxAnisotropy > 16 is clamped, rather than illegal
https://bugs.webkit.org/show_bug.cgi?id=238063

Reviewed by Kimmo Kinnunen.

See https://github.com/gpuweb/gpuweb/issues/696#issuecomment-644343897

> Let's add a maxAnisotropy value to samplers, and a maxAnisotropy limit(? query?) (likely only
> ever 16 or 1), but not to validate that the former is less than the latter.

Test: api/operation/sampling/anisotropy.spec.ts

* WebGPU/Sampler.mm:
(WebGPU::validateCreateSampler):
(WebGPU::Device::createSampler):

Modified Paths

Diff

Modified: trunk/Source/WebGPU/ChangeLog (291592 => 291593)


--- trunk/Source/WebGPU/ChangeLog	2022-03-22 00:43:52 UTC (rev 291592)
+++ trunk/Source/WebGPU/ChangeLog	2022-03-22 01:19:00 UTC (rev 291593)
@@ -1,5 +1,23 @@
 2022-03-21  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        [WebGPU] maxAnisotropy > 16 is clamped, rather than illegal
+        https://bugs.webkit.org/show_bug.cgi?id=238063
+
+        Reviewed by Kimmo Kinnunen.
+
+        See https://github.com/gpuweb/gpuweb/issues/696#issuecomment-644343897
+
+        > Let's add a maxAnisotropy value to samplers, and a maxAnisotropy limit(? query?) (likely only
+        > ever 16 or 1), but not to validate that the former is less than the latter.
+
+        Test: api/operation/sampling/anisotropy.spec.ts
+
+        * WebGPU/Sampler.mm:
+        (WebGPU::validateCreateSampler):
+        (WebGPU::Device::createSampler):
+
+2022-03-21  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         [WebGPU] Implement error reporting facilities
         https://bugs.webkit.org/show_bug.cgi?id=238131
 

Modified: trunk/Source/WebGPU/WebGPU/Sampler.mm (291592 => 291593)


--- trunk/Source/WebGPU/WebGPU/Sampler.mm	2022-03-22 00:43:52 UTC (rev 291592)
+++ trunk/Source/WebGPU/WebGPU/Sampler.mm	2022-03-22 01:19:00 UTC (rev 291593)
@@ -50,10 +50,6 @@
     if (descriptor.maxAnisotropy < 1)
         return false;
 
-    // "descriptor.maxAnisotropy is less than or equal to 16."
-    if (descriptor.maxAnisotropy > 16)
-        return false;
-
     // "When descriptor.maxAnisotropy is greater than 1"
     if (descriptor.maxAnisotropy > 1) {
         // "descriptor.magFilter, descriptor.minFilter, and descriptor.mipmapFilter must be equal to "linear"."
@@ -194,7 +190,10 @@
         return nullptr;
     }
 
-    samplerDescriptor.maxAnisotropy = descriptor.maxAnisotropy;
+    // "The used value of maxAnisotropy will be clamped to the maximum value that the platform supports."
+    // https://developer.apple.com/documentation/metal/mtlsamplerdescriptor/1516164-maxanisotropy?language=objc
+    // "Values must be between 1 and 16, inclusive."
+    samplerDescriptor.maxAnisotropy = std::min<uint16_t>(descriptor.maxAnisotropy, 16);
 
     samplerDescriptor.label = descriptor.label ? [NSString stringWithCString:descriptor.label encoding:NSUTF8StringEncoding] : nil;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to