Skip to content

Commit

Permalink
texture naming + gles: support new formats + fix FLOAT/HALF_FLOAT mixup
Browse files Browse the repository at this point in the history
  • Loading branch information
EriKWDev committed Dec 15, 2024
1 parent d7244e2 commit 0f4dc42
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
25 changes: 23 additions & 2 deletions blade-graphics/src/gles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,9 @@ fn describe_texture_format(format: crate::TextureFormat) -> FormatInfo {
Tf::Bgra8Unorm => (glow::RGBA8, glow::BGRA, glow::UNSIGNED_BYTE),
Tf::Bgra8UnormSrgb => (glow::SRGB8_ALPHA8, glow::BGRA, glow::UNSIGNED_BYTE),
Tf::Rgba8Snorm => (glow::RGBA8, glow::RGBA, glow::BYTE),
Tf::R16Float => (glow::R16F, glow::RED, glow::FLOAT),
Tf::Rgba16Float => (glow::RGBA16F, glow::RGBA, glow::FLOAT),
Tf::R16Float => (glow::R16F, glow::RED, glow::HALF_FLOAT),
Tf::Rg16Float => (glow::RG16F, glow::RG, glow::HALF_FLOAT),
Tf::Rgba16Float => (glow::RGBA16F, glow::RGBA, glow::HALF_FLOAT),
Tf::R32Float => (glow::R32F, glow::RED, glow::FLOAT),
Tf::Rg32Float => (glow::RG32F, glow::RG, glow::FLOAT),
Tf::Rgba32Float => (glow::RGBA32F, glow::RGBA, glow::FLOAT),
Expand All @@ -622,6 +623,26 @@ fn describe_texture_format(format: crate::TextureFormat) -> FormatInfo {
Tf::Bc4Snorm => (glow::COMPRESSED_SIGNED_RED_RGTC1, glow::RED, 0),
Tf::Bc5Unorm => (glow::COMPRESSED_RG_RGTC2, glow::RG, 0),
Tf::Bc5Snorm => (glow::COMPRESSED_SIGNED_RG_RGTC2, glow::RG, 0),
Tf::Bc6hUfloat => (glow::COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, glow::RGB, 0),
Tf::Bc6hSfloat => (glow::COMPRESSED_RGB_BPTC_SIGNED_FLOAT, glow::RGB, 0),
Tf::Bc7Unorm => (glow::COMPRESSED_RGBA_BPTC_UNORM, glow::RGBA, 0),
Tf::Bc7UnormSrgb => (glow::COMPRESSED_SRGB_ALPHA_BPTC_UNORM, glow::RGBA, 0),
Tf::Rgb10a2Unorm => (
glow::RGB10_A2,
glow::RGBA,
glow::UNSIGNED_INT_2_10_10_10_REV,
),
Tf::Bgr10a2Unorm => (
glow::RGB10_A2, // TODO: Unsupported?
glow::BGRA,
glow::UNSIGNED_INT_2_10_10_10_REV,
),
Tf::Rg11b10Float => (
glow::R11F_G11F_B10F,
glow::RGB,
glow::UNSIGNED_INT_10F_11F_11F_REV,
),
Tf::Rgb9e5Ufloat => (glow::RGB9_E5, glow::RGB, glow::UNSIGNED_INT_5_9_9_9_REV),
};
FormatInfo {
internal,
Expand Down
6 changes: 3 additions & 3 deletions blade-graphics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,15 @@ pub enum TextureFormat {
Bc4Snorm,
Bc5Unorm,
Bc5Snorm,
Bc6UFloat,
Bc6SFloat,
Bc6hUfloat,
Bc6hSfloat,
Bc7Unorm,
Bc7UnormSrgb,
// packed 32-bit
Rgb10a2Unorm,
Bgr10a2Unorm,
Rg11b10Float,
Rgb9e5Float,
Rgb9e5Ufloat,
}

#[derive(Clone, Copy, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions blade-graphics/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ impl super::TextureFormat {
Self::Bc4Snorm => cx_bc(8),
Self::Bc5Unorm => cx_bc(16),
Self::Bc5Snorm => cx_bc(16),
Self::Bc6UFloat => cx_bc(16),
Self::Bc6SFloat => cx_bc(16),
Self::Bc6hUfloat => cx_bc(16),
Self::Bc6hSfloat => cx_bc(16),
Self::Bc7Unorm => cx_bc(16),
Self::Bc7UnormSrgb => cx_bc(16),
Self::Rgb10a2Unorm => uncompressed(4),
Self::Bgr10a2Unorm => uncompressed(4),
Self::Rg11b10Float => uncompressed(4),
Self::Rgb9e5Float => uncompressed(4),
Self::Rgb9e5Ufloat => uncompressed(4),
}
}

Expand Down
6 changes: 3 additions & 3 deletions blade-graphics/src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,14 @@ fn map_texture_format(format: crate::TextureFormat) -> vk::Format {
Tf::Bc4Snorm => vk::Format::BC4_SNORM_BLOCK,
Tf::Bc5Unorm => vk::Format::BC5_UNORM_BLOCK,
Tf::Bc5Snorm => vk::Format::BC5_SNORM_BLOCK,
Tf::Bc6UFloat => vk::Format::BC6H_UFLOAT_BLOCK,
Tf::Bc6SFloat => vk::Format::BC6H_SFLOAT_BLOCK,
Tf::Bc6hUfloat => vk::Format::BC6H_UFLOAT_BLOCK,
Tf::Bc6hSfloat => vk::Format::BC6H_SFLOAT_BLOCK,
Tf::Bc7Unorm => vk::Format::BC7_UNORM_BLOCK,
Tf::Bc7UnormSrgb => vk::Format::BC7_SRGB_BLOCK,
Tf::Rgb10a2Unorm => vk::Format::A2R10G10B10_UNORM_PACK32,
Tf::Bgr10a2Unorm => vk::Format::A2B10G10R10_UNORM_PACK32,
Tf::Rg11b10Float => vk::Format::B10G11R11_UFLOAT_PACK32,
Tf::Rgb9e5Float => vk::Format::E5B9G9R9_UFLOAT_PACK32,
Tf::Rgb9e5Ufloat => vk::Format::E5B9G9R9_UFLOAT_PACK32,
}
}

Expand Down

0 comments on commit 0f4dc42

Please sign in to comment.