-
Notifications
You must be signed in to change notification settings - Fork 328
Add minmax-sampling feature #1283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -1375,6 +1375,7 @@ enum GPUFeatureName { | |||
"pipeline-statistics-query", | |||
"texture-compression-bc", | |||
"timestamp-query", | |||
"minmax-sampling", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is minmax sampling allowed for uint, int textures, but also for comparison samplers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The minmax feature in vulkan doesn't require support for any integer formats, so I assume we wouldn't support any. It also can't be used with comparison samplers apparently (kinda weird).
If the format is a depth/stencil format, this bit only specifies that the depth aspect (not the stencil aspect) of an image of this format supports min/max filtering, and that min/max filtering of the depth aspect is supported when depth compare is disabled in the sampler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be, but getting the stats for this is hard :(
For now the spec only allows it on a few selected formats (see last commit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that's not a lot of formats.
@@ -7239,6 +7257,22 @@ The following enums are supported if and only if the {{GPUFeatureName/"timestamp | |||
* {{GPUQueryType/"timestamp"}} | |||
</dl> | |||
|
|||
## <dfn dfn-type=enum-value dfn-for=GPUFeatureName>minmax-sampling</dfn> ## {#minmax-sampling} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## <dfn dfn-type=enum-value dfn-for=GPUFeatureName>minmax-sampling</dfn> ## {#minmax-sampling} | |
## <dfn enum-value for=GPUFeatureName>minmax-sampling</dfn> ## {#minmax-sampling} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should change this across all features, consistently (as a follow-up)
@@ -1375,6 +1375,7 @@ enum GPUFeatureName { | |||
"pipeline-statistics-query", | |||
"texture-compression-bc", | |||
"timestamp-query", | |||
"minmax-sampling", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that's not a lot of formats.
Thank you for the quick and detailed reviews! We have now gone through a few iterations, and the spec is not quite the same as it was in the first draft.
So it sounds like a format still has to be filterable, even if the min/max reduction mode is used. This mostly affects "r32float", which I tentatively marked as enabled for min/maxing, even though one technically can do it today, since filtering is not supported (i.e. they get a WebGPU validation error because of filtering requirements). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK; as I said on the issue I wasn't sure whether it was tied to filterability or not.
I should have noticed that this should have defined a reduction mode instead of a filter mode, whoops.
|s|.{{GPUSampler/[[descriptor]]}}.{{GPUSamplerDescriptor/compare}} is `null` or undefined. | ||
Otherwise, set it to `true`. | ||
1. Set |s|.{{GPUSampler/[[isMinMax]]}} to `false` if | ||
|s|.{{GPUSampler/[[descriptor]]}}.{{GPUSamplerDescriptor/reduction}} is {{GPUReductionMode/"weighted-average"}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems kind of backward, I think it's easier to read if it says set it to true if it's "minimum" or "maximum"
1. Set |s|.{{GPUSampler/[[isFiltering]]}} to `false` if none of {{GPUSamplerDescriptor/minFilter}}, | ||
{{GPUSamplerDescriptor/magFilter}}, or {{GPUSamplerDescriptor/mipmapFilter}} has the value of | ||
{{GPUFilterMode/"linear"}}. Otherwise, set it to `true`. | ||
1. Set |s|.{{GPUSampler/[[isComparison]]}} to `false` if | ||
|s|.{{GPUSampler/[[descriptor]]}}.{{GPUSamplerDescriptor/compare}} is `null` or undefined. | ||
Otherwise, set it to `true`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just say undefined; JS null and undefined both get converted to IDL undefined
https://heycam.github.io/webidl/#es-dictionary
I would probably flip this to say "true if compare is defined" or "is specified" or "is not undefined".
Wish we could come up with a better phrasing than "otherwise set it to true". Like "set isComparison to (s.descriptor.compare ≠ undefined)" maybe?
@@ -3555,7 +3573,7 @@ A {{GPUProgrammableStageDescriptor}} describes the entry point in the user-provi | |||
: {{GPUSamplerBindingType/"comparison"}} | |||
:: the |binding| is a comparison sampler | |||
: {{GPUSamplerBindingType/"minmax"}} | |||
:: the |binding| is a min/max sampler | |||
:: the |binding| is a non-comparison sampler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe have "filtering or non-filtering or minmax" as one case, or just "otherwise".
@@ -2349,7 +2355,7 @@ match one texel. | |||
<script type=idl> | |||
enum GPUFilterMode { | |||
"nearest", | |||
"linear" | |||
"linear", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Briefly considering if we try to come up with a word other than linear, since this also describes minmax filters which aren't exactly "linear"? I'm not sure what it would be; "nearest"/"linear"(/"cubic") is well understood terminology. I think they're clearest.
Vulkan has an extension to use min/max with "cubic", too, fwiw: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#textures-texel-cubic-filtering
nit: are we sure we want to have this in the spec given it seems a very niche or advanced feature? I'm worried you both have spend significant time on this when it is nowhere close to the critical path to getting WebGPU out :) |
I just needed a warm-up before starting #1293 :) |
…1417) This PR adds unimplmented stubs for the read-write-modify atomic operations. * `atomicAdd` * `atomicAnd` * `atomicCompareExchangeWeak` * `atomicExchange` * `atomicMax` * `atomicMin` * `atomicOr` * `atomicSub` * `atomicXor` Issue gpuweb#1275, gpuweb#1276, gpuweb#1277, gpuweb#1278, gpuweb#1279, gpuweb#1280, gpuweb#1281, gpuweb#1282, gpuweb#1283
Closes #1267
This is useful for building hierarchical depth bounds, as one example.
Hardware support:
VK_EXT_sampler_filter_minmax
is present on around 50% desktops and 25% Android devices. There is a set of formats supporting min/max sampling, enabled by filterMinmaxSingleComponentFormats property. It's hard to grasp the support surface for the others.Note: min/max sampling shouldn't be considered "filtering" for the purpose of validation.
TODO:
Preview | Diff