Skip to content
Merged
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
Move preferred format to the adapter
  • Loading branch information
toji committed Nov 30, 2020
commit 1a7ec8a8fdbe7a986a47f663d06e208745723b7b
27 changes: 9 additions & 18 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,11 @@ interface GPUAdapter {
: <dfn>\[[adapter]]</dfn>, of type [=adapter=], readonly
::
The [=adapter=] to which this {{GPUAdapter}} refers.

: <dfn>\[[preferred_format]]</dfn>, of type {{GPUTextureFormat}}, readonly
Comment thread
toji marked this conversation as resolved.
Outdated
::
An optimal {{GPUTextureFormat}} to use when creating a {{GPUSwapChain}} for a this [=adapter=].
Must be one of the [=supported swap chain formats=].
</dl>

{{GPUAdapter}} has the following methods:
Expand Down Expand Up @@ -6853,21 +6858,20 @@ interface GPUCanvasContext {
1. If any of the following conditions are unsatisfied, generate a validation error and stop.
<div class=validusage>
- |descriptor|.{{GPUSwapChainDescriptor/device}} is a [=valid=] {{GPUDevice}}.
- Let |supportedFormats| be the [=supported swap chain formats=].
- |supportedFormats| [=set/contains=] |descriptor|.{{GPUSwapChainDescriptor/format}}.
- [=Supported swap chain formats=] [=set/contains=] |descriptor|.{{GPUSwapChainDescriptor/format}}.
</div>

Issue: Describe remaining {{GPUCanvasContext/configureSwapChain()}} algorithm steps.
</div>
</div>

: <dfn>getSwapChainPreferredFormat(device)</dfn>
: <dfn>getSwapChainPreferredFormat(adapter)</dfn>
::
Returns an optimal {{GPUTextureFormat}} to use for swap chains with this context and the
given device.

<div algorithm="GPUCanvasContext.getSwapChainPreferredFormat">
**Called on:** {{GPUCanvasContext}} |this|.
**Called on:** {{GPUCanvasContext}} this.

**Arguments:**
<pre class=argumentdef for="GPUCanvasContext/getSwapChainPreferredFormat(adapter)">
Expand All @@ -6877,8 +6881,7 @@ interface GPUCanvasContext {
**Returns:** {{GPUTextureFormat}}

<div class=content-timeline>
1. Let |preferredFormat| be the [$preferred swap chain format$] for |this| and |adapter|.
1. Return |preferredFormat|.
1. Return |adapter|.{{GPUAdapter/[[preferred_format]]}}
</div>
</div>
</dl>
Expand All @@ -6889,18 +6892,6 @@ of the given {{GPUSwapChainDescriptor}}.{{GPUSwapChainDescriptor/device}}, initi
&laquo;{{GPUTextureFormat/"bgra8unorm"}}, {{GPUTextureFormat/"bgra8unorm-srgb"}},
{{GPUTextureFormat/"rgba8unorm"}}, {{GPUTextureFormat/"rgba8unorm-srgb"}}&raquo;.
Comment thread
kainino0x marked this conversation as resolved.

<div algorithm>
To get the <dfn abstract-op>preferred swap chain format</dfn> for a given {{GPUCanvasContext}}
|context| and a given {{GPUAdapter}} |adapter| run the following steps::

1. Let |preferredFormat| be |context|.{{GPUCanvasContext/[[preferred_format]]}}
1. If |preferredFormat|[|adapter|] does not exist:
1. Set |preferredFormat|[|adapter|] to be one of the [=supported swap chain formats=] known
to be optimal for use with |context| and |adapter|. The user agent may use any criteria
to select the format.
1. Return |preferredFormat|[|adapter|].
</div>

<script type=idl>
dictionary GPUSwapChainDescriptor : GPUObjectDescriptorBase {
required GPUDevice device;
Expand Down