Sitelet https://github.com/gpuweb/gpuweb/pull/419
Skip to content

Initial spec for GPUDevice.createBuffer - #419

Merged
kainino0x merged 1 commit into
gpuweb:masterfrom
Kangz:initial-buffer-spec
Sep 5, 2019
Merged

kainino0x merged 1 commit into
gpuweb:masterfrom
Kangz:initial-buffer-spec

Conversation

@Kangz

@Kangz Kangz commented Aug 22, 2019 •

Copy link
Copy Markdown
Contributor

Putting this up to try to get the spec-writing ball rolling. Editors, PTAL @kainino0x @kvark @JusSn. Also @litherum PTAL since I think you have the most Bikeshed experience here. This is the first time I'm doing non-trivial Bikeshed and Web-style specs so I'm sure I'm holding it wrong :)


Preview | Diff

Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
Comment thread spec/index.bs
1. If device is lost return false.
1. If any of the bits of |descriptor|'s {{GPUBufferDescriptor/usage}} aren't present in this device's [[allowed buffer usages]] return false.
1. If both the {{GPUBufferUsage/MAP_READ}} and {{GPUBufferUsage/MAP_WRITE}} bits of |descriptor|'s {{GPUBufferDescriptor/usage}} attribute are set, return false.
1. Return true.

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.

ok, this appears to be written for the implementors
Would it be simpler if we describe it as:

Buffer creation fails if one of the conditions is true:

  1. Device is lost
  2. Any of the bits ...
  3. Usage contains both MAP_READ and MAP_WRITE ...

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.

This is an "algorithm" which means it's the procedure to do when "validating GPUBufferDescriptor". Other specs do this too. However since this has no return value it seems fine to flip it.

I think it's also that web specs are written more for browsers than for users. I'm personally ok with deviating from this because I see the tests as being the source of truth for browser implementers whenever possible.

Comment thread spec/index.bs Outdated
@kvark

kvark commented Aug 22, 2019

Copy link
Copy Markdown
Contributor

Hmm the "Diff" link shows quite a few more changes than there are in the PR :/

Comment thread spec/index.bs
<dl dfn-type="abstract-op">
: <dfn>validating GPUBufferDescriptor</dfn>(device, descriptor)
::
<div algorithm="validation GPUBufferDescriptor(device, descriptor)">

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.

Some other specs seem to use present progressive tense, "validating GPUBufferDescriptor". Also I don't think the args are needed inside the algorithm name.

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.

Thinking about it more, it would make sense to make this be part of the "creating a GPUBuffer" algorithm. May or may not be useful to keep it separate from that.

@kainino0x kainino0x left a comment

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.

Some more thoughts, but we shouldn't block landing. I'd be happy to do the follow-up to make these suggested changes after it's landed.

Comment thread spec/Makefile Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
</dl>

Note:
{{GPUBuffer/[[size]]}} and {{GPUBuffer/[[usage]]}} are immutable once the {{GPUBuffer}} has been created.

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.

IMO would no longer be needed with "readonly" above.

Comment thread spec/index.bs Outdated
@Kangz

Kangz commented Sep 3, 2019

Copy link
Copy Markdown
Contributor Author

@kvark @kainino0x @JusSn any other changes blocking this?

@kvark kvark left a comment

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.

Here comes another review pass

Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs
Comment thread spec/index.bs Outdated
Comment thread spec/index.bs Outdated
@Kangz
Kangz force-pushed the initial-buffer-spec branch from a46e84f to 5d275db Compare September 4, 2019 15:58
@kainino0x

Copy link
Copy Markdown
Contributor

I don't think there is anything outstanding right now and I'd really like to get this in to make it easier to iterate. Merging!

@kainino0x
kainino0x merged commit dd21edb into gpuweb:master Sep 5, 2019
JusSn pushed a commit to JusSn/gpuweb that referenced this pull request Sep 19, 2019
JusSn added a commit that referenced this pull request Sep 19, 2019
* Add a component type for GPUBGLBinding compatiblity (#384)

In shaders there are several texture types for each dimensionality
depending on their component type. It can be either float, uint or
sint, with maybe in the future depth/stencil if WebGPU allows reading
such textures.

The component type of a GPUTextureView's format must match the
component type of its binding in the shader module. This is for
several reasons:

 - Vulkan requires the following: "The Sampled Type of an
OpTypeImage declaration must match the numeric format of the
corresponding resource in type and signedness, as shown in the
SPIR-V Sampled Type column of the Interpretation of Numeric Format
table, or the values obtained by reading or sampling from this image
are undefined."

 - It is also required in OpenGL for the texture units to be complete,
a uint or sint texture unit used with a non-nearest sampler is
incomplete and returns black texels.

Similar constraints must exist in other APIs.

To encode this compatibility constraint, a new member is added to
GPUBindGroupLayoutBinding that is a new enum GPUTextureComponentType
that give the component type of the texture.

* Make GPUBGLBinding.textureDimension default to 2d.

This is the most common case and avoids having an optional dictionary
member with no default value (but that still requires a value for
texture bindings).

* Add a component type for GPUBGLBinding compatiblity (#384)

In shaders there are several texture types for each dimensionality
depending on their component type. It can be either float, uint or
sint, with maybe in the future depth/stencil if WebGPU allows reading
such textures.

The component type of a GPUTextureView's format must match the
component type of its binding in the shader module. This is for
several reasons:

 - Vulkan requires the following: "The Sampled Type of an
OpTypeImage declaration must match the numeric format of the
corresponding resource in type and signedness, as shown in the
SPIR-V Sampled Type column of the Interpretation of Numeric Format
table, or the values obtained by reading or sampling from this image
are undefined."

 - It is also required in OpenGL for the texture units to be complete,
a uint or sint texture unit used with a non-nearest sampler is
incomplete and returns black texels.

Similar constraints must exist in other APIs.

To encode this compatibility constraint, a new member is added to
GPUBindGroupLayoutBinding that is a new enum GPUTextureComponentType
that give the component type of the texture.

* Make GPUBGLBinding.textureDimension default to 2d.

This is the most common case and avoids having an optional dictionary
member with no default value (but that still requires a value for
texture bindings).

* unifinished createBindGroupLayout algorithm

* draft of BindGroupLayout details

* draft of BindGroupLayout details

* polish before PR

* fix typo

* replace u32/i32/u64 with normal int types or specific typedefs (#423)

* Do not require vertexInput in GPURenderPipelineDescriptor (#378)

* Add a default for GPURenderPassColorAttachmentDescriptor.storeOp (#376)

Supersedes #268.

* Initial spec for GPUDevice.createBuffer (#419)

* Start writing spec for device/adapter, introduce internal objects (#422)

* Move validation rules out of algorithm body and better describe GPUBindGroupLayout internal slots

* Include limits for dynamic offset buffers

* Rename 'dynamic' boolean to 'hasDynamicOffsets'

* Fix indentation for ci bot

* More indentation errors

* Fix var typos

* Fix method definition

* Fix enum references

* Missing </dfn> tag

* Missing </dfn> tag

* Remove bad [= =]

* Fix old constant name

* Half-formed new validation rule structure for createBindGroupLayout

* An interface -> the interface

* Remove old 'layout binding' reference

* fix device lost validation reference

* Fix 'dynamic' typo
@Kangz
Kangz deleted the initial-buffer-spec branch April 21, 2020 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants