use super::*;
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum TextureFormat {
Rgba,
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum AttachmentImageColorFormat {
R8UNorm,
R8G8UNorm,
R8G8B8A8UNorm,
R32SFloat,
R32G32SFloat,
R32G32B32A32SFloat,
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum AttachmentImageUsage {
ColorAttachment,
DepthAttachment,
}
pub struct CubemapTextureUpload<'a> {
pub posx: &'a [u8],
pub negx: &'a [u8],
pub posy: &'a [u8],
pub negy: &'a [u8],
pub posz: &'a [u8],
pub negz: &'a [u8],
}
#[derive(Default, Debug)]
pub struct NewTextureExt {
pub enable_mipmaps: Option<()>,
pub mip_levels: Option<u32>,
pub enable_cubemap: Option<()>,
}
#[derive(Default, Debug, Clone)]
pub struct UploadTextureExt {
pub generate_mipmaps: Option<()>,
}
#[derive(Default, Debug, Clone)]
pub struct UploadCubemapTextureExt {
pub generate_mipmaps: Option<()>,
}
#[derive(Default, Debug, Clone)]
pub struct NewAttachmentImageExt {
pub msaa_samples: Option<MsaaSampleCount>,
pub color_format: Option<AttachmentImageColorFormat>,
}
impl Context {
pub fn new_texture(
&mut self,
width: usize,
height: usize,
format: TextureFormat,
ext: Option<NewTextureExt>,
) -> GResult<TextureId> {
match self {
Self::Vulkan(vk) => vk.new_texture(width, height, format, ext),
Self::WebGpu(wgpu) => wgpu.new_texture(width, height, format, ext),
}
}
pub fn upload_texture(
&mut self,
texture: TextureId,
data: &[u8],
ext: Option<UploadTextureExt>,
) -> GResult<()> {
match self {
Self::Vulkan(vk) => vk.upload_texture(texture, data, ext),
Self::WebGpu(wgpu) => wgpu.upload_texture(texture, data, ext),
}
}
pub fn upload_cubemap_texture(
&mut self,
texture: TextureId,
upload: CubemapTextureUpload,
ext: Option<UploadTextureExt>,
) -> GResult<()> {
match self {
Self::Vulkan(vk) => vk.upload_cubemap_texture(texture, upload, ext),
Self::WebGpu(wgpu) => wgpu.upload_cubemap_texture(texture, upload, ext),
}
}
pub fn get_texture_max_lod(&self, texture: TextureId) -> GResult<f32> {
match self {
Self::Vulkan(vk) => vk.get_texture_max_lod(texture),
Self::WebGpu(wgpu) => wgpu.get_texture_max_lod(texture),
}
}
pub fn new_attachment_image(
&mut self,
initial_width: usize,
initial_height: usize,
attachment_usage: AttachmentImageUsage,
ext: Option<NewAttachmentImageExt>,
) -> GResult<AttachmentImageId> {
match self {
Self::Vulkan(vk) => {
vk.new_attachment_image(initial_width, initial_height, attachment_usage, ext)
}
Self::WebGpu(wgpu) => {
wgpu.new_attachment_image(initial_width, initial_height, attachment_usage, ext)
}
}
}
}