Bug 237882 - [WebGPU] Implement sampler creation according to the spec
Summary: [WebGPU] Implement sampler creation according to the spec
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on: 237879
Blocks:
  Show dependency treegraph
 
Reported: 2022-03-15 01:38 PDT by Myles C. Maxfield
Modified: 2022-03-16 20:57 PDT (History)
4 users (show)

See Also:


Attachments
Patch (10.63 KB, patch)
2022-03-15 01:40 PDT, Myles C. Maxfield
kkinnunen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2022-03-15 01:38:37 PDT
.
Comment 1 Myles C. Maxfield 2022-03-15 01:40:43 PDT
Created attachment 454680 [details]
Patch
Comment 2 Kimmo Kinnunen 2022-03-16 08:52:12 PDT
Comment on attachment 454680 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=454680&action=review

> Source/WebGPU/WebGPU/Sampler.mm:40
> +    if (descriptor.lodMinClamp < 0)

an edge case of edge cases:
Do we have a mechanism to prevent NaNs in the floats or do we need to validate those?
(those cause tricky failures to debug even if it's a content issue, so if validation rejects those, maybe it'd be good use of time?)
Comment 3 Kimmo Kinnunen 2022-03-16 09:01:19 PDT
Comment on attachment 454680 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=454680&action=review

> Source/WebGPU/WebGPU/Sampler.mm:190
> +    samplerDescriptor.maxAnisotropy = descriptor.maxAnisotropy;

this should be clamped?
Comment 4 Myles C. Maxfield 2022-03-16 20:51:08 PDT
Comment on attachment 454680 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=454680&action=review

>> Source/WebGPU/WebGPU/Sampler.mm:40
>> +    if (descriptor.lodMinClamp < 0)
> 
> an edge case of edge cases:
> Do we have a mechanism to prevent NaNs in the floats or do we need to validate those?
> (those cause tricky failures to debug even if it's a content issue, so if validation rejects those, maybe it'd be good use of time?)

Yes, good catch. The spec says "Return true if and only if all of the following conditions are satisfied: descriptor.lodMinClamp is greater than or equal to 0. \ descriptor.lodMaxClamp is greater than or equal to descriptor.lodMinClamp." so I think a careful reading of the spec already catches NaN (those comparisons will be false in that case). My code, however, gets this wrong, since I've inverted the conditionals. I'll check for NaN explicitly.

>> Source/WebGPU/WebGPU/Sampler.mm:190
>> +    samplerDescriptor.maxAnisotropy = descriptor.maxAnisotropy;
> 
> this should be clamped?

Yes, the Metal spec https://developer.apple.com/documentation/metal/mtlsamplerdescriptor/1516164-maxanisotropy?language=objc says "Values must be between 1 and 16, inclusive."
Comment 5 Myles C. Maxfield 2022-03-16 20:56:10 PDT
Committed r291387 (248518@trunk): <https://commits.webkit.org/248518@trunk>
Comment 6 Radar WebKit Bug Importer 2022-03-16 20:57:15 PDT
<rdar://problem/90408334>