mirror of https://github.com/AxioDL/metaforce.git
aurora: Fix mismatched filter mode for palette samplers
Update Dawn to fix asserts in Debug mode
This commit is contained in:
parent
d7c62d8d90
commit
0ba73696f5
|
@ -1117,7 +1117,7 @@ GXBindGroups build_bind_groups(const ShaderInfo& info, const ShaderConfig& confi
|
||||||
++textureCount;
|
++textureCount;
|
||||||
// Load palette
|
// Load palette
|
||||||
const auto& texConfig = config.textureConfig[i];
|
const auto& texConfig = config.textureConfig[i];
|
||||||
if (texConfig.loadFmt == GX::TF_C4 || texConfig.loadFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2) {
|
if (is_palette_format(texConfig.loadFmt)) {
|
||||||
u32 tlut = tex.texObj.tlut;
|
u32 tlut = tex.texObj.tlut;
|
||||||
if (tlut < GX_TLUT0 || tlut > GX_TLUT7) {
|
if (tlut < GX_TLUT0 || tlut > GX_TLUT7) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("tlut out of bounds {}"), tlut);
|
Log.report(logvisor::Fatal, FMT_STRING("tlut out of bounds {}"), tlut);
|
||||||
|
@ -1234,22 +1234,23 @@ GXBindGroupLayouts build_bind_group_layouts(const ShaderInfo& info, const Shader
|
||||||
if (!info.sampledTextures.test(i)) {
|
if (!info.sampledTextures.test(i)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const auto& texConfig = config.textureConfig[i];
|
||||||
|
bool copyAsPalette = is_palette_format(texConfig.copyFmt);
|
||||||
|
bool loadAsPalette = is_palette_format(texConfig.loadFmt);
|
||||||
samplerEntries[numSamplers] = {
|
samplerEntries[numSamplers] = {
|
||||||
.binding = numSamplers,
|
.binding = numSamplers,
|
||||||
.visibility = wgpu::ShaderStage::Fragment,
|
.visibility = wgpu::ShaderStage::Fragment,
|
||||||
.sampler = {.type = wgpu::SamplerBindingType::Filtering},
|
.sampler = {.type = copyAsPalette && loadAsPalette ? wgpu::SamplerBindingType::NonFiltering
|
||||||
|
: wgpu::SamplerBindingType::Filtering},
|
||||||
};
|
};
|
||||||
++numSamplers;
|
++numSamplers;
|
||||||
const auto& texConfig = config.textureConfig[i];
|
if (loadAsPalette) {
|
||||||
if (texConfig.loadFmt == GX::TF_C4 || texConfig.loadFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2) {
|
|
||||||
bool isPaletted =
|
|
||||||
texConfig.copyFmt == GX::TF_C4 || texConfig.copyFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2;
|
|
||||||
textureEntries[numTextures] = {
|
textureEntries[numTextures] = {
|
||||||
.binding = numTextures,
|
.binding = numTextures,
|
||||||
.visibility = wgpu::ShaderStage::Fragment,
|
.visibility = wgpu::ShaderStage::Fragment,
|
||||||
.texture =
|
.texture =
|
||||||
{
|
{
|
||||||
.sampleType = isPaletted ? wgpu::TextureSampleType::Sint : wgpu::TextureSampleType::Float,
|
.sampleType = copyAsPalette ? wgpu::TextureSampleType::Sint : wgpu::TextureSampleType::Float,
|
||||||
.viewDimension = wgpu::TextureViewDimension::e2D,
|
.viewDimension = wgpu::TextureViewDimension::e2D,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1359,10 +1360,22 @@ static u16 wgpu_aniso(GXAnisotropy aniso) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wgpu::SamplerDescriptor TextureBind::get_descriptor() const noexcept {
|
wgpu::SamplerDescriptor TextureBind::get_descriptor() const noexcept {
|
||||||
|
if (requires_copy_conversion(texObj) && is_palette_format(texObj.ref->gxFormat)) {
|
||||||
|
return {
|
||||||
|
.label = "Generated Non-Filtering Sampler",
|
||||||
|
.addressModeU = wgpu_address_mode(texObj.wrapS),
|
||||||
|
.addressModeV = wgpu_address_mode(texObj.wrapT),
|
||||||
|
.addressModeW = wgpu::AddressMode::Repeat,
|
||||||
|
.magFilter = wgpu::FilterMode::Nearest,
|
||||||
|
.minFilter = wgpu::FilterMode::Nearest,
|
||||||
|
.mipmapFilter = wgpu::FilterMode::Nearest,
|
||||||
|
.maxAnisotropy = 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
const auto [minFilter, mipFilter] = wgpu_filter_mode(texObj.minFilter);
|
const auto [minFilter, mipFilter] = wgpu_filter_mode(texObj.minFilter);
|
||||||
const auto [magFilter, _] = wgpu_filter_mode(texObj.magFilter);
|
const auto [magFilter, _] = wgpu_filter_mode(texObj.magFilter);
|
||||||
return {
|
return {
|
||||||
.label = "Generated Sampler",
|
.label = "Generated Filtering Sampler",
|
||||||
.addressModeU = wgpu_address_mode(texObj.wrapS),
|
.addressModeU = wgpu_address_mode(texObj.wrapS),
|
||||||
.addressModeV = wgpu_address_mode(texObj.wrapT),
|
.addressModeV = wgpu_address_mode(texObj.wrapT),
|
||||||
.addressModeW = wgpu::AddressMode::Repeat,
|
.addressModeW = wgpu::AddressMode::Repeat,
|
||||||
|
|
|
@ -234,6 +234,9 @@ static inline bool requires_load_conversion(const GXTexObj& obj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static inline bool is_palette_format(GX::TextureFormat fmt) {
|
||||||
|
return fmt == GX::TF_C4 || fmt == GX::TF_C8 || fmt == GX::TF_C14X2;
|
||||||
|
}
|
||||||
|
|
||||||
struct TextureConfig {
|
struct TextureConfig {
|
||||||
GX::TextureFormat copyFmt = InvalidTextureFormat; // Underlying texture format
|
GX::TextureFormat copyFmt = InvalidTextureFormat; // Underlying texture format
|
||||||
|
|
|
@ -1084,12 +1084,10 @@ wgpu::ShaderModule build_shader(const ShaderConfig& config, const ShaderInfo& in
|
||||||
// } else {
|
// } else {
|
||||||
uvIn = fmt::format(FMT_STRING("in.tex{0}_uv"), stage.texCoordId);
|
uvIn = fmt::format(FMT_STRING("in.tex{0}_uv"), stage.texCoordId);
|
||||||
// }
|
// }
|
||||||
if (texConfig.loadFmt == GX::TF_C4 || texConfig.loadFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2) {
|
if (is_palette_format(texConfig.loadFmt)) {
|
||||||
bool isPaletted =
|
|
||||||
texConfig.copyFmt == GX::TF_C4 || texConfig.copyFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2;
|
|
||||||
fragmentFnPre +=
|
fragmentFnPre +=
|
||||||
fmt::format(FMT_STRING("\n var sampled{0} = textureSamplePalette{3}(tex{1}, tex{1}_samp, {2}, tlut{1});"),
|
fmt::format(FMT_STRING("\n var sampled{0} = textureSamplePalette{3}(tex{1}, tex{1}_samp, {2}, tlut{1});"),
|
||||||
i, stage.texMapId, uvIn, isPaletted ? ""sv : "RGB"sv);
|
i, stage.texMapId, uvIn, is_palette_format(texConfig.copyFmt) ? ""sv : "RGB"sv);
|
||||||
} else {
|
} else {
|
||||||
fragmentFnPre += fmt::format(
|
fragmentFnPre += fmt::format(
|
||||||
FMT_STRING("\n var sampled{0} = textureSampleBias(tex{1}, tex{1}_samp, {2}, ubuf.tex{1}_lod);"), i,
|
FMT_STRING("\n var sampled{0} = textureSampleBias(tex{1}, tex{1}_samp, {2}, ubuf.tex{1}_lod);"), i,
|
||||||
|
@ -1171,12 +1169,10 @@ wgpu::ShaderModule build_shader(const ShaderConfig& config, const ShaderInfo& in
|
||||||
texBindIdx, i);
|
texBindIdx, i);
|
||||||
|
|
||||||
const auto& texConfig = config.textureConfig[i];
|
const auto& texConfig = config.textureConfig[i];
|
||||||
if (texConfig.loadFmt == GX::TF_C4 || texConfig.loadFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2) {
|
if (is_palette_format(texConfig.loadFmt)) {
|
||||||
bool isPaletted =
|
|
||||||
texConfig.copyFmt == GX::TF_C4 || texConfig.copyFmt == GX::TF_C8 || texConfig.loadFmt == GX::TF_C14X2;
|
|
||||||
texBindings += fmt::format(FMT_STRING("\n@group(2) @binding({})\n"
|
texBindings += fmt::format(FMT_STRING("\n@group(2) @binding({})\n"
|
||||||
"var tex{}: texture_2d<{}>;"),
|
"var tex{}: texture_2d<{}>;"),
|
||||||
texBindIdx, i, isPaletted ? "i32"sv : "f32"sv);
|
texBindIdx, i, is_palette_format(texConfig.copyFmt) ? "i32"sv : "f32"sv);
|
||||||
++texBindIdx;
|
++texBindIdx;
|
||||||
texBindings += fmt::format(FMT_STRING("\n@group(2) @binding({})\n"
|
texBindings += fmt::format(FMT_STRING("\n@group(2) @binding({})\n"
|
||||||
"var tlut{}: texture_2d<f32>;"),
|
"var tlut{}: texture_2d<f32>;"),
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit f223c5af9ff49c1d25ec862e11f0191e1339916e
|
Subproject commit 369c345a2d40e46b926a1ec5ae75720f2c188247
|
Loading…
Reference in New Issue