mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
DX12/VK allow texture_format_capabilities to be called on any texture format
This commit is contained in:
parent
ff233fbf31
commit
bb273a908f
@ -1,10 +1,10 @@
|
||||
use winapi::shared::dxgiformat;
|
||||
|
||||
pub fn map_texture_format(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
|
||||
pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgiformat::DXGI_FORMAT> {
|
||||
use wgt::TextureFormat as Tf;
|
||||
use winapi::shared::dxgiformat::*;
|
||||
|
||||
match format {
|
||||
Some(match format {
|
||||
Tf::R8Unorm => DXGI_FORMAT_R8_UNORM,
|
||||
Tf::R8Snorm => DXGI_FORMAT_R8_SNORM,
|
||||
Tf::R8Uint => DXGI_FORMAT_R8_UINT,
|
||||
@ -78,7 +78,14 @@ pub fn map_texture_format(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT
|
||||
| Tf::Astc {
|
||||
block: _,
|
||||
channel: _,
|
||||
} => unreachable!(),
|
||||
} => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn map_texture_format(format: wgt::TextureFormat) -> dxgiformat::DXGI_FORMAT {
|
||||
match map_texture_format_failable(format) {
|
||||
Some(f) => f,
|
||||
None => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,10 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
) -> crate::TextureFormatCapabilities {
|
||||
use crate::TextureFormatCapabilities as Tfc;
|
||||
|
||||
let raw_format = auxil::dxgi::conv::map_texture_format(format);
|
||||
let raw_format = match auxil::dxgi::conv::map_texture_format_failable(format) {
|
||||
Some(f) => f,
|
||||
None => return Tfc::empty(),
|
||||
};
|
||||
let mut data = d3d12::D3D12_FEATURE_DATA_FORMAT_SUPPORT {
|
||||
Format: raw_format,
|
||||
Support1: mem::zeroed(),
|
||||
|
@ -1459,8 +1459,11 @@ impl crate::Adapter<super::Api> for super::Adapter {
|
||||
let properties = self
|
||||
.phd_capabilities
|
||||
.formats
|
||||
.get(vk_format.as_raw() as usize)
|
||||
.unwrap();
|
||||
.get(vk_format.as_raw() as usize);
|
||||
let properties = match properties {
|
||||
Some(p) => p,
|
||||
None => return Tfc::empty(),
|
||||
};
|
||||
let features = properties.optimal_tiling_features;
|
||||
|
||||
let mut flags = Tfc::empty();
|
||||
|
Loading…
Reference in New Issue
Block a user