2022-03-04 07:47:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
#include "../gpu.hpp"
|
|
|
|
|
|
|
|
namespace aurora::gfx {
|
2022-05-13 23:40:19 +00:00
|
|
|
static wgpu::TextureFormat to_wgpu(GX::TextureFormat format) {
|
2022-03-04 07:47:21 +00:00
|
|
|
switch (format) {
|
2022-05-14 23:23:47 +00:00
|
|
|
case GX::TF_I4:
|
2022-05-13 23:40:19 +00:00
|
|
|
case GX::TF_I8:
|
2022-03-04 07:47:21 +00:00
|
|
|
return wgpu::TextureFormat::R8Unorm;
|
2022-05-14 23:23:47 +00:00
|
|
|
case GX::TF_C4:
|
|
|
|
case GX::TF_C8:
|
|
|
|
case GX::TF_C14X2:
|
|
|
|
return wgpu::TextureFormat::R16Sint;
|
2022-05-13 23:40:19 +00:00
|
|
|
case GX::TF_CMPR:
|
2022-03-04 07:47:21 +00:00
|
|
|
if (gpu::g_device.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
|
|
|
|
return wgpu::TextureFormat::BC1RGBAUnorm;
|
|
|
|
}
|
|
|
|
[[fallthrough]];
|
|
|
|
default:
|
|
|
|
return wgpu::TextureFormat::RGBA8Unorm;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-13 23:40:19 +00:00
|
|
|
ByteBuffer convert_texture(GX::TextureFormat format, uint32_t width, uint32_t height, uint32_t mips,
|
2022-03-04 07:47:21 +00:00
|
|
|
ArrayRef<uint8_t> data);
|
|
|
|
} // namespace aurora::gfx
|