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

Support texture-compression-bc-sliced-3d in wgpu #5751

Merged
merged 25 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3580be7
Enable compressed formats in wgpu for 3D textures
mehmetoguzderin May 28, 2024
87a36d1
Use `align_to` for rounding
mehmetoguzderin May 29, 2024
3456c25
Case rounded sizes according if uncompressed
mehmetoguzderin May 29, 2024
8413a04
Please see https://github.com/gpuweb/gpuweb/pull/4685
mehmetoguzderin May 30, 2024
8fc7489
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin May 30, 2024
42b202d
Please see https://github.com/gpuweb/gpuweb/pull/4685
mehmetoguzderin May 30, 2024
d9e4d73
Please see https://github.com/gpuweb/gpuweb/pull/4685
mehmetoguzderin May 30, 2024
99f1b9a
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin May 30, 2024
a7ebdf2
Update lib.rs
mehmetoguzderin May 31, 2024
533629c
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jun 1, 2024
b0a5c05
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jun 3, 2024
bd21ec6
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jun 3, 2024
e5ac970
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jun 4, 2024
c72af0c
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jul 26, 2024
65be71e
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Jul 30, 2024
237c1b7
Move into extension
mehmetoguzderin Jul 30, 2024
c76dc29
Format deno directory
mehmetoguzderin Jul 30, 2024
a747de8
WASM Clippy Fix
mehmetoguzderin Jul 30, 2024
1fd2ddf
Make comments single line
mehmetoguzderin Jul 30, 2024
c035e83
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Aug 4, 2024
9e8b74c
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Aug 5, 2024
1bd768f
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Aug 5, 2024
1f01ac0
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Aug 6, 2024
5bb449e
Merge branch 'trunk' into oguz-20240530-compress3d
mehmetoguzderin Aug 8, 2024
e690729
Update command and flag in order
mehmetoguzderin Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/tests/clear_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async fn clear_texture_tests(ctx: TestingContext, formats: &'static [wgpu::Textu
let is_compressed_or_depth_stencil_format =
format.is_compressed() || format.is_depth_stencil_format();
let supports_1d = !is_compressed_or_depth_stencil_format;
let supports_3d = !is_compressed_or_depth_stencil_format;
let supports_3d = format.is_bcn() || !is_compressed_or_depth_stencil_format;

// 1D texture
if supports_1d {
Expand Down Expand Up @@ -386,6 +386,10 @@ static CLEAR_TEXTURE_COMPRESSED_BCN: GpuTestConfiguration = GpuTestConfiguration
.parameters(
TestParameters::default()
.features(wgpu::Features::CLEAR_TEXTURE | wgpu::Features::TEXTURE_COMPRESSION_BC)
.limits(wgpu::Limits {
max_texture_dimension_3d: 1024,
..wgpu::Limits::downlevel_defaults()
})
// https://bugs.chromium.org/p/angleproject/issues/detail?id=7056
.expect_fail(FailureCase::backend_adapter(wgpu::Backends::GL, "ANGLE"))
// compressed texture copy to buffer not yet implemented
Expand Down
14 changes: 13 additions & 1 deletion wgpu-core/src/device/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,8 +755,12 @@ impl<A: HalApi> Device<A> {
desc.dimension,
));
}
}

// Compressed textures can only be 2D
if desc.dimension != wgt::TextureDimension::D2
&& desc.dimension != wgt::TextureDimension::D3
{
// Compressed textures can only be 2D or 3D
if desc.format.is_compressed() {
return Err(CreateTextureError::InvalidCompressedDimension(
desc.dimension,
Expand Down Expand Up @@ -787,6 +791,14 @@ impl<A: HalApi> Device<A> {
},
));
}

// Only BCn formats are supported for 3D textures
if desc.dimension == wgt::TextureDimension::D3 && !desc.format.is_bcn() {
return Err(CreateTextureError::InvalidCompressedDimension(
desc.dimension,
desc.format,
));
}
}

{
Expand Down
21 changes: 21 additions & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3153,6 +3153,27 @@ impl TextureFormat {
self.block_dimensions() != (1, 1)
}

/// Returns `true` for BCn compressed formats.
pub fn is_bcn(&self) -> bool {
match *self {
Self::Bc1RgbaUnorm
| Self::Bc1RgbaUnormSrgb
| Self::Bc2RgbaUnorm
| Self::Bc2RgbaUnormSrgb
| Self::Bc3RgbaUnorm
| Self::Bc3RgbaUnormSrgb
| Self::Bc4RUnorm
| Self::Bc4RSnorm
| Self::Bc5RgUnorm
| Self::Bc5RgSnorm
| Self::Bc6hRgbUfloat
| Self::Bc6hRgbFloat
| Self::Bc7RgbaUnorm
| Self::Bc7RgbaUnormSrgb => true,
_ => false,
}
mehmetoguzderin marked this conversation as resolved.
Show resolved Hide resolved
}

/// Returns the required features (if any) in order to use the texture.
pub fn required_features(&self) -> Features {
match *self {
Expand Down
Loading