2022-07-27 15:25:25 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
|
|
|
#include "texture.hpp"
|
|
|
|
#include "../webgpu/gpu.hpp"
|
|
|
|
|
|
|
|
namespace aurora::gfx {
|
2022-08-02 20:37:56 +00:00
|
|
|
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:
|
2022-08-02 20:37:56 +00:00
|
|
|
return wgpu::TextureFormat::R8Unorm;
|
2022-07-27 15:25:25 +00:00
|
|
|
case GX_TF_C4:
|
|
|
|
case GX_TF_C8:
|
|
|
|
case GX_TF_C14X2:
|
2022-08-02 20:37:56 +00:00
|
|
|
return wgpu::TextureFormat::R16Sint;
|
2022-07-27 15:25:25 +00:00
|
|
|
case GX_TF_CMPR:
|
2022-08-02 20:37:56 +00:00
|
|
|
if (webgpu::g_device.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
|
|
|
|
return wgpu::TextureFormat::BC1RGBAUnorm;
|
2022-07-27 15:25:25 +00:00
|
|
|
}
|
|
|
|
[[fallthrough]];
|
|
|
|
default:
|
2022-08-02 20:37:56 +00:00
|
|
|
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
|