Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add GPUReductionMode
  • Loading branch information
kvark committed Dec 8, 2020
commit 8fdb231239b82963b9e4e13452ab1c3243bb8d3f
53 changes: 37 additions & 16 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,7 @@ dictionary GPUSamplerDescriptor : GPUObjectDescriptorBase {
GPUFilterMode magFilter = "nearest";
GPUFilterMode minFilter = "nearest";
GPUFilterMode mipmapFilter = "nearest";
GPUReductionMode reduction = "weighted-average";
float lodMinClamp = 0;
float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE.
GPUCompareFunction compare;
Expand Down Expand Up @@ -2351,8 +2352,6 @@ match one texel.
enum GPUFilterMode {
"nearest",
"linear",
Copy link
Copy Markdown
Contributor

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

"minimum",
"maximum",
};
</script>

Expand All @@ -2363,16 +2362,32 @@ enum GPUFilterMode {

: <dfn>"linear"</dfn>
::
Select two texels in each dimension and return a linear interpolation between their values.
Select two texels in each dimension for the reduction operation.
</dl>

{{GPUReductionMode}} describes the operation a sampler does on multiple texels before it produces the result.

<script type=idl>
enum GPUReductionMode {
"weighted-average",
"minimum",
"maximum",
};
</script>

<dl dfn-type="enum-value" dfn-for=GPUFilterMode>
: <dfn>"weighted-average"</dfn>
::
Compute the weighted average of the texel values based on the position of a sample.

: <dfn>"minimum"</dfn>
::
Select two texels in each dimension and return the minimum values between them, component-wise.
Compute the minimum between the texel values, component-wise.
Requires {{GPUFeatureName/"minmax-sampling"}} feature to be enabled.

: <dfn>"maximum"</dfn>
::
Select two texels in each dimension and return the maximum values between them, component-wise.
Compute the maximum between the texel values, component-wise.
Requires {{GPUFeatureName/"minmax-sampling"}} feature to be enabled.
</dl>

Expand Down Expand Up @@ -2444,8 +2459,8 @@ enum GPUCompareFunction {
|descriptor|.{{GPUSamplerDescriptor/lodMinClamp}}.
- |descriptor|.{{GPUSamplerDescriptor/magFilter}} and |descriptor.{{GPUSamplerDescriptor/mipmapFilter}}
are either {{GPUFilterMode/"nearest"}} or {{GPUFilterMode/"linear"}}, independently.
- if |descriptor|.{{GPUSamplerDescriptor/minFilter}} is {{GPUFilterMode/"minimum"}} or
{{GPUFilterMode/"maximum"}}, then all of the following conditions are satisfied:
- if |descriptor|.{{GPUSamplerDescriptor/reduction}} is not {{GPUReductionMode/"weighted-average"}},
then all of the following conditions are satisfied:
- |device|.{{device/[[features]]}} [=list/contains=] {{GPUFeatureName/"minmax-sampling"}}.
- |descriptor|.{{GPUSamplerDescriptor/compare}} is `null`.
</div>
Expand Down Expand Up @@ -2591,8 +2606,8 @@ type and each [=binding type=] has an associated [=internal usage=], given by th
<td>[=internal usage/storage-read=]

<tr>
<td rowspan=3>{{GPUBindGroupLayoutEntry/sampler}}
<td rowspan=3>{{GPUSampler}}
<td rowspan=4>{{GPUBindGroupLayoutEntry/sampler}}
<td rowspan=4>{{GPUSampler}}
<td>{{GPUSamplerBindingType/"filtering"}}
<td>[=internal usage/constant=]
<tr>
Expand All @@ -2601,6 +2616,9 @@ type and each [=binding type=] has an associated [=internal usage=], given by th
<tr>
<td>{{GPUSamplerBindingType/"comparison"}}
<td>[=internal usage/constant=]
<tr>
<td>{{GPUSamplerBindingType/"minmax"}}
<td>[=internal usage/constant=]

<tr>
<td rowspan=5>{{GPUBindGroupLayoutEntry/texture}}
Expand Down Expand Up @@ -2678,6 +2696,7 @@ enum GPUSamplerBindingType {
"filtering",
"non-filtering",
"comparison",
"minmax",
};

dictionary GPUSamplerBindingLayout {
Expand Down Expand Up @@ -3535,6 +3554,8 @@ A {{GPUProgrammableStageDescriptor}} describes the entry point in the user-provi
:: the |binding| is a non-comparison sampler
: {{GPUSamplerBindingType/"comparison"}}
:: the |binding| is a comparison sampler
: {{GPUSamplerBindingType/"minmax"}}
:: the |binding| is a min/max sampler
Comment thread
kvark marked this conversation as resolved.
Outdated
</dl>

: {{GPUBindGroupLayoutEntry/texture}}
Expand Down Expand Up @@ -7282,10 +7303,10 @@ The following enums are supported if and only if the {{GPUFeatureName/"minmax-sa
[=feature=] is enabled:

<dl>
: {{GPUFilterMode}}
: {{GPUReductionMode}}
::
* {{GPUFilterMode/"minimum"}}
* {{GPUFilterMode/"maximum"}}
* {{GPUReductionMode/"minimum"}}
* {{GPUReductionMode/"maximum"}}
</dl>

# Appendices # {#appendices}
Expand All @@ -7304,7 +7325,7 @@ The {{GPUTextureUsage/STORAGE|GPUTextureUsage.STORAGE}} column specifies the sup
usage in the core API, including both {{GPUStorageTextureAccess/"readonly"}} and {{GPUStorageTextureAccess/"writeonly"}}.

The "Min/Max sampling" column specifies the support for sampling a {{GPUTextureView}} of the format with a {{GPUSampler}}
that uses {{GPUFilterMode/"minimum"}} or {{GPUFilterMode/"maximum"}}.
bound as {{GPUSamplerBindingType/"minmax"}.

<table class='data'>
<thead class=stickyheader>
Expand Down Expand Up @@ -7479,7 +7500,7 @@ that uses {{GPUFilterMode/"minimum"}} or {{GPUFilterMode/"maximum"}}.
<td>{{GPUTextureSampleType/"unfilterable-float"}}<!-- Metal -->
<td>&checkmark;
<td>&checkmark;
<td>&checkmark;
<td>&checkmark; <!-- this is tricky in Vulkan -->
<tr>
<td>{{GPUTextureFormat/rg32uint}}
<td>{{GPUTextureSampleType/"uint"}}
Expand Down Expand Up @@ -7538,8 +7559,8 @@ All depth formats support {{GPUTextureUsage/COPY_SRC}}, {{GPUTextureUsage/COPY_D

None of the depth formats can be filtered.

The {{GPUTextureAspect/"depth-only"} aspect of all of the depth formats can be sampled
with {{GPUFilterMode/"minimum"}} or {{GPUFilterMode/"maximum"}} modes.
The {{GPUTextureAspect/"depth-only"}} aspect of all of the depth formats can be sampled
with samplers bound as {{GPUSamplerBindingType/"minmax"}}.

<table class='data'>
<thead>
Expand Down