Skip to content
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

hal: Improve buffer documentation and cleanup error handling #2154

Merged
merged 1 commit into from
Jun 23, 2018

Conversation

msiglreith
Copy link
Contributor

Fixes #issue
PR checklist:

  • make succeeds (on *nix)
  • make reftests succeeds
  • tested examples with the following backends:

/// Index buffer view for `bind_index_buffer`.
///
/// Defines a buffer slice used for acquiring the indicies on draw commands.
/// Indices are used to lookup the vertex indices in the vertex buffers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to lookup vertices" perhaps?

}
/// Error creating a buffer.
#[derive(Fail, Debug, Clone, PartialEq, Eq)]
pub enum BufferCreationError {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the motivation behind having the Buffer* prefix for those errors? If we are exposing buffer as a module, I find it elegant to keep it buffer::CreationError. If we are using the fully qualified names, there is no need to expose the modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which direction we should go for the errors.
Currently having a error module containing DeviceCreationError and a few more. On the other side we could also move these errors into the different modules as done here with possible name shortening.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm (non-strongly) in favor of having short error names in respective modules (as opposed to putting them into a dedicated error module)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think this will be more clear. changed.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Should we squash it?

@msiglreith
Copy link
Contributor Author

bors r=kvark

bors bot added a commit that referenced this pull request Jun 22, 2018
2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Build failed

@kvark
Copy link
Member

kvark commented Jun 22, 2018

bors retry

bors bot added a commit that referenced this pull request Jun 22, 2018
2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Build failed

@msiglreith
Copy link
Contributor Author

bors retry

@msiglreith
Copy link
Contributor Author

bors r=kvark

@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Not awaiting review

bors bot added a commit that referenced this pull request Jun 22, 2018
2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Build failed

@kvark
Copy link
Member

kvark commented Jun 22, 2018

bors retry

1 similar comment
@kvark
Copy link
Member

kvark commented Jun 22, 2018

bors retry

@kvark
Copy link
Member

kvark commented Jun 22, 2018

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Not awaiting review

1 similar comment
@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Not awaiting review

bors bot added a commit that referenced this pull request Jun 22, 2018
2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 22, 2018

Build failed

@kvark
Copy link
Member

kvark commented Jun 22, 2018 via email

@kvark
Copy link
Member

kvark commented Jun 23, 2018 via email

@bors
Copy link
Contributor

bors bot commented Jun 23, 2018

Not awaiting review

bors bot added a commit that referenced this pull request Jun 23, 2018
2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 23, 2018

Build failed

@kvark
Copy link
Member

kvark commented Jun 23, 2018

bors r+

bors bot added a commit that referenced this pull request Jun 23, 2018
2071: Remaping descriptor sets in the gl backend r=kvark a=ZeGentzy

I'll rebase off master when I'm done.

Uniforms in gl only have a bindings field, not a set one. This means that for shaders that use multiple sets to work, we must change where we are binding them.

See page 14 for what I mean: https://www.khronos.org/assets/uploads/developers/library/2016-vulkan-devday-uk/4-Using-spir-v-with-spirv-cross.pdf

PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


2149: [dx11] add memory flush/invalidate & image/buffer copies r=kvark a=fkaa

Main changes are adding more robust implementation of `Memory`, adding flush/invalidate and adding image/buffer copies. Implements `Memory` like the following (for `HOST_VISIBLE` memory):

```
    0.........................size
    +----------------------------+
    |          Memory            |
    +----------------------------+
    A..B  C.....D         E...F

    1 fixed-size `STAGING` buffer which gets used for reading back from
      resources.(and should be used to copy from/to on flush/invalidate):
      (0..size, ComPtr<Buffer>)

    1 `Vec<u8>` which covers the whole memory range (0..size). This is
      pointer we hand out to users. flush/invalidate moves the affected
      regions into our `STAGING` buffer to get read/uploaded.

    *N* Resources:
      (A..B, ComPtr<Resource>),
      (C..D, ComPtr<Resource>),
      (E..F, ComPtr<Resource>),
```

Implements copying between images and buffers. Image<->Image copies are mostly handled by `CopySubresourceRegion` but some formats, while same size, cant be copied with this method:

> Cannot invoke CopySubresourceRegion when the Formats of each Resource are not the same or at least castable to each other, unless one format is compressed (DXGI_FORMAT_R9G9B9E5_SHAREDEXP, or DXGI_FORMAT_BC[1,2,3,4,5]_* ) and the source format is similar to the dest according to: BC[1|4] ~= R16G16B16A16|R32G32, BC[2|3|5] ~= R32G32B32A32, R9G9B9E5_SHAREDEXP ~= R32. [ RESOURCE_MANIPULATION ERROR #281: ]

These has to be done through compute shaders instead. Image->Buffer & Buffer->Image copies also have to be done through compute shaders, as `CopySubresourceRegion` can only copy between resources of same type (Image<->Image, Buffer<->Buffer). The following formats have Buffer->Image and Image->Buffer copies implemented with these changes:

* `R8`
* `Rg8`
* `R16`
* `Rg16`
* `R32`

Gets about 400 tests passed and equal amount failed in `dEQP-VK.api.copy_and_blit.core.image_to_image.all_formats.color` (mostly because `CopySubresourceRegion` failing to copy between some formats as mentioned above)

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


2154: hal: Improve buffer documentation and cleanup error handling r=kvark a=msiglreith

Fixes #issue
PR checklist:
- [ ] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:


Co-authored-by: Hal Gentz <[email protected]>
Co-authored-by: Felix Kaaman <[email protected]>
Co-authored-by: msiglreith <[email protected]>
@bors
Copy link
Contributor

bors bot commented Jun 23, 2018

@bors bors bot merged commit 8c8281c into gfx-rs:master Jun 23, 2018
@msiglreith msiglreith deleted the buffer_doc branch June 23, 2018 10:58
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.

2 participants