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

Add mirror clamped to edge filter #2100

Closed
msiglreith opened this issue Jun 2, 2018 · 5 comments · Fixed by #3172
Closed

Add mirror clamped to edge filter #2100

msiglreith opened this issue Jun 2, 2018 · 5 comments · Fixed by #3172

Comments

@msiglreith
Copy link
Contributor

Support the one time mirroring filter extension (VK_KHR_sampler_mirror_clamp_to_edge).
Named D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE in D3D12

@msiglreith
Copy link
Contributor Author

Need to figure out first how to expose extensions in gfx

@caitp
Copy link
Contributor

caitp commented Sep 15, 2018

Need to figure out first how to expose extensions in gfx

How about something like this? (Granted, I haven't really looked at the gfx codebase at all until a few hours ago).

This way, an application can request an abstract naming of extensions which vulkan/metal/dx12 can translate, ignore, or fail during device creation if they can't be supported.

  1. encode abstract extensions via enum or bitfield
mod hal {
    enum Extension {
        SamplerMirrorOnce, // VK_KHR_sampler_mirror_clamp_to_edge,
        ..
    }
}
  1. pass into PhysicalDevice::open() (either as a bitfield, or a vec/slice/iterator of enums)
fn open(
        &self,
        families: &[(&QueueFamily, &[hal::QueuePriority])],
        extensions: &[Extension],
    ) -> Result<hal::Gpu<Backend>, DeviceCreationError>
  1. add some conv:: machinery to translate requested extensions into a pointer to a 'static str
pub enum ExtensionError {
    ImplicitlySupported, // Or return Option<&'static str>, whatever

    NotSupported, // PhysicalDevice can't do what's requested, HAL can try to find another that can?
}

pub fn map_ext(ext: Extension) -> Result<&'static str, ExtensionError> {
  map ext {
    Extension::SamplerMirrorOnce => Ok(extensions::VK_KHR_Sampler_mirror_clamp_to_edge),

    _ => Err(ExtensionError::NotSupported),
  }
}

A fancier version of this would integrate the builder pattern for PhysicalDevice opening, with methods that accept HAL abstractions for extensions, as well as backend-specific versions which could be used for testing, or adding backend support before HAL integration is ready, which would be better for developers of gfx-rs (by allowing the advancement of individual backend features without being blocked on support in other backends or the HAL) e.g.

backend_vulkan::PhysicalDevice::open()
    // testing some extension that doesn't exist in HAL --- doesn't require handling in other backends
    .with_vulkan_extensions(&["VK_KHR_sampler_mirror_clamp_to_edge"])

    // using extensions which are exposed in HAL, and are known about by all backends.
    .with_extensions(&[Extension::QuerySurfaceCapabilities]);

@caitp
Copy link
Contributor

caitp commented Sep 15, 2018

of course, making the abstract extension enums/bitfields isn’t very future-proof (would mean removing them or adding new ones is always a API breaking change) so there are downsides

@kvark
Copy link
Member

kvark commented Mar 22, 2020

@msiglreith I suggest just extending Features, just like #3170 does it.
Essentially, extensions are just features that weren't know by the time the spec was out.

@kvark kvark self-assigned this Mar 22, 2020
@kvark
Copy link
Member

kvark commented Mar 22, 2020

I'm trying to cover our bases for releaing 0.5, will add a flag for this.

bors bot added a commit that referenced this issue Mar 22, 2020
3172: MirrorClamp feature r=msiglreith a=kvark

Fixes #2100
PR checklist:
- [x] `make` succeeds (on *nix)
- [ ] `make reftests` succeeds
- [ ] tested examples with the following backends:
- [ ] `rustfmt` run on changed code


Co-authored-by: Dzmitry Malyshau <[email protected]>
@bors bors bot closed this as completed in 8a4a7c4 Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment