aurora/lib/gfx/texture_convert.hpp

30 lines
747 B
C++
Raw Permalink Normal View History

2022-07-27 15:25:25 +00:00
#pragma once
#include "common.hpp"
#include "texture.hpp"
#include "../webgpu/gpu.hpp"
namespace aurora::gfx {
static wgpu::TextureFormat to_wgpu(u32 format) {
2022-07-27 15:25:25 +00:00
switch (format) {
case GX_TF_I4:
case GX_TF_I8:
case GX_TF_R8_PC:
return wgpu::TextureFormat::R8Unorm;
2022-07-27 15:25:25 +00:00
case GX_TF_C4:
case GX_TF_C8:
case GX_TF_C14X2:
return wgpu::TextureFormat::R16Sint;
2022-07-27 15:25:25 +00:00
case GX_TF_CMPR:
if (webgpu::g_device.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
return wgpu::TextureFormat::BC1RGBAUnorm;
2022-07-27 15:25:25 +00:00
}
[[fallthrough]];
default:
return wgpu::TextureFormat::RGBA8Unorm;
2022-07-27 15:25:25 +00:00
}
}
ByteBuffer convert_texture(u32 format, uint32_t width, uint32_t height, uint32_t mips, ArrayRef<uint8_t> data);
} // namespace aurora::gfx