Skip to content

Commit

Permalink
WIP R64Uint/Sint support
Browse files Browse the repository at this point in the history
  • Loading branch information
JMS55 committed Jan 27, 2024
1 parent 707d22d commit 0126182
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
4 changes: 2 additions & 2 deletions naga/src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ bitflags::bitflags! {
}

struct BlockInfo {
stages: super::ShaderStages,
stages: ShaderStages,
finished: bool,
}

Expand Down Expand Up @@ -262,7 +262,7 @@ impl super::Validator {
arguments: &[Handle<crate::Expression>],
result: Option<Handle<crate::Expression>>,
context: &BlockContext,
) -> Result<super::ShaderStages, WithSpan<CallError>> {
) -> Result<ShaderStages, WithSpan<CallError>> {
let fun = &context.functions[function];
if fun.arguments.len() != arguments.len() {
return Err(CallError::ArgumentCount {
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/auxil/dxgi/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub fn map_texture_format_failable(format: wgt::TextureFormat) -> Option<dxgifor
Tf::Rgba16Unorm => DXGI_FORMAT_R16G16B16A16_UNORM,
Tf::Rgba16Snorm => DXGI_FORMAT_R16G16B16A16_SNORM,
Tf::Rgba16Float => DXGI_FORMAT_R16G16B16A16_FLOAT,
Tf::R64Uint => DXGI_FORMAT_R32G32_UINT,
Tf::R64Sint => DXGI_FORMAT_R32G32_SINT,
Tf::Rgba32Uint => DXGI_FORMAT_R32G32B32A32_UINT,
Tf::Rgba32Sint => DXGI_FORMAT_R32G32B32A32_SINT,
Tf::Rgba32Float => DXGI_FORMAT_R32G32B32A32_FLOAT,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,8 @@ impl crate::Adapter<super::Api> for super::Adapter {
Tf::Rgba16Unorm => empty,
Tf::Rgba16Snorm => empty,
Tf::Rgba16Float => filterable | storage | half_float_renderable,
Tf::R64Uint => empty,
Tf::R64Sint => empty,
Tf::Rgba32Uint => renderable | storage,
Tf::Rgba32Sint => renderable | storage,
Tf::Rgba32Float => unfilterable | storage | float_renderable | texture_float_linear,
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/gles/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ impl super::AdapterShared {
Tf::Rgba16Unorm => (glow::RGBA16, glow::RGBA, glow::UNSIGNED_SHORT),
Tf::Rgba16Snorm => (glow::RGBA16_SNORM, glow::RGBA, glow::SHORT),
Tf::Rgba16Float => (glow::RGBA16F, glow::RGBA, glow::HALF_FLOAT),
Tf::R64Uint => unreachable!(),
Tf::R64Sint => unreachable!(),
Tf::Rgba32Uint => (glow::RGBA32UI, glow::RGBA_INTEGER, glow::UNSIGNED_INT),
Tf::Rgba32Sint => (glow::RGBA32I, glow::RGBA_INTEGER, glow::INT),
Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT),
Expand Down
2 changes: 2 additions & 0 deletions wgpu-hal/src/vulkan/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ impl super::PrivateCapabilities {
Tf::Rgba16Unorm => F::R16G16B16A16_UNORM,
Tf::Rgba16Snorm => F::R16G16B16A16_SNORM,
Tf::Rgba16Float => F::R16G16B16A16_SFLOAT,
Tf::R64Uint => F::R64_UINT,
Tf::R64Sint => F::R64_SINT,
Tf::Rgba32Uint => F::R32G32B32A32_UINT,
Tf::Rgba32Sint => F::R32G32B32A32_SINT,
Tf::Rgba32Float => F::R32G32B32A32_SFLOAT,
Expand Down
41 changes: 35 additions & 6 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ bitflags::bitflags! {
/// - DX12
const DUAL_SOURCE_BLENDING = 1 << 63;

/// Allows shaders to use i64 and u64.
/// Allows shaders to use i64 and u64 types.
///
/// Supported platforms:
/// - Vulkan
Expand All @@ -863,16 +863,24 @@ bitflags::bitflags! {
/// This is a native only feature.
const SHADER_I64 = 1 << 64;

/// Enables R64Sint and R64Uint texture formats.
///
/// Supported platforms:
/// - Vulkan
///
/// This is a native only feature.
const TEXTURE_FORMAT_R64INT = 1 << 65;

/// Allows compute shaders to use atomic operations on R64Sint and R64Uint read_write storage textures.
///
/// Requires SHADER_I64 and [`Dx12Compiler::Dxc`].
/// Requires `SHADER_I64`, `TEXTURE_FORMAT_R64INT`, `TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`, and [`Dx12Compiler::Dxc`].
///
/// Supported platforms:
/// - Vulkan (with VK_EXT_shader_image_atomic_int64)
/// - DX12 (with Shader Model 6.6 and AtomicInt64OnTypedResourceSupported)
///
/// This is a native only feature.
const SHADER_I64_TEXTURE_ATOMIC = 1 << 65;
const SHADER_I64_TEXTURE_ATOMIC = 1 << 66;
}
}

Expand Down Expand Up @@ -2405,6 +2413,14 @@ pub enum TextureFormat {
Rgba16Snorm,
/// Red, green, blue, and alpha channels. 16 bit float per channel. Float in shader.
Rgba16Float,
/// Red channel only. 64 bit integer per channel. Unsigned in shader.
///
/// [`Features::TEXTURE_FORMAT_R64INT`] must be enabled to use this texture format.
R64Uint,
/// Red channel only. 64 bit integer per channel. Signed in shader.
///
/// [`Features::TEXTURE_FORMAT_R64INT`] must be enabled to use this texture format.
R64Sint,

// Normal 128 bit formats
/// Red, green, blue, and alpha channels. 32 bit integer per channel. Unsigned in shader.
Expand Down Expand Up @@ -2793,6 +2809,8 @@ impl Serialize for TextureFormat {
TextureFormat::Rgba16Unorm => "rgba16unorm",
TextureFormat::Rgba16Snorm => "rgba16snorm",
TextureFormat::Rgba16Float => "rgba16float",
TextureFormat::R64Uint => "r64uint",
TextureFormat::R64Sint => "r64sint",
TextureFormat::Rgba32Uint => "rgba32uint",
TextureFormat::Rgba32Sint => "rgba32sint",
TextureFormat::Rgba32Float => "rgba32float",
Expand Down Expand Up @@ -3023,6 +3041,8 @@ impl TextureFormat {
| Self::Rgba16Unorm
| Self::Rgba16Snorm
| Self::Rgba16Float
| Self::R64Uint
| Self::R64Sint
| Self::Rgba32Uint
| Self::Rgba32Sint
| Self::Rgba32Float
Expand Down Expand Up @@ -3141,6 +3161,8 @@ impl TextureFormat {
| Self::Rgba16Unorm
| Self::Rgba16Snorm => Features::TEXTURE_FORMAT_16BIT_NORM,

Self::R64Uint | Self::R64Sint => Features::TEXTURE_FORMAT_R64INT,

Self::Bc1RgbaUnorm
| Self::Bc1RgbaUnormSrgb
| Self::Bc2RgbaUnorm
Expand Down Expand Up @@ -3239,6 +3261,8 @@ impl TextureFormat {
Self::Rgba16Uint => ( msaa, all_flags),
Self::Rgba16Sint => ( msaa, all_flags),
Self::Rgba16Float => (msaa_resolve, all_flags),
Self::R64Uint => (noaa, all_flags), // TODO: Probably wrong
Self::R64Sint => (noaa, all_flags), // TODO: Probably wrong
Self::Rgba32Uint => ( noaa, all_flags),
Self::Rgba32Sint => ( noaa, all_flags),
Self::Rgba32Float => ( noaa, all_flags),
Expand Down Expand Up @@ -3355,7 +3379,8 @@ impl TextureFormat {
| Self::R32Uint
| Self::Rg32Uint
| Self::Rgba32Uint
| Self::Rgb10a2Uint => Some(uint),
| Self::Rgb10a2Uint
| Self::R64Uint => Some(uint),

Self::R8Sint
| Self::Rg8Sint
Expand All @@ -3365,7 +3390,8 @@ impl TextureFormat {
| Self::Rgba16Sint
| Self::R32Sint
| Self::Rg32Sint
| Self::Rgba32Sint => Some(sint),
| Self::Rgba32Sint
| Self::R64Sint => Some(sint),

Self::Stencil8 => Some(uint),
Self::Depth16Unorm | Self::Depth24Plus | Self::Depth32Float => Some(depth),
Expand Down Expand Up @@ -3482,6 +3508,7 @@ impl TextureFormat {
| Self::Rgba16Sint
| Self::Rgba16Float => Some(8),
Self::Rg32Uint | Self::Rg32Sint | Self::Rg32Float => Some(8),
Self::R64Uint | Self::R64Sint => Some(8),

Self::Rgba32Uint | Self::Rgba32Sint | Self::Rgba32Float => Some(16),

Expand Down Expand Up @@ -3556,7 +3583,9 @@ impl TextureFormat {
| Self::R16Float
| Self::R32Uint
| Self::R32Sint
| Self::R32Float => 1,
| Self::R32Float
| Self::R64Uint
| Self::R64Sint => 1,

Self::Rg8Unorm
| Self::Rg8Snorm
Expand Down

0 comments on commit 0126182

Please sign in to comment.