mirror of
https://github.com/jhaizhou-ops/d2r-mobile
synced 2026-11-26 13:57:52 +08:00
3D resolution levels apply on HarmonyOS; the Vulkan NEAREST fallback also covers linear mipmapping (#214, #218)
- front_ohos.c wrote its platform 3D scale into DM_3D_SCALE, which since #214 overrides the Custom page's three levels, so the row did nothing on HarmonyOS. It now writes DM_3D_SCALE_DEFAULT (the "balanced" level); DM_3D_SCALE stays the manual override. - xbg_game.cpp (#218): VK_SAMPLER_MIPMAP_MODE_LINEAR needs the same linear-filter format bit, so a sampler that only mipmaps linearly also takes the fallback, and the fallback sets NEAREST mipmapping too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
28bded7eab
commit
c38657300b
2 files changed
+4
-3
No files matched your search
@@ -2584,11 +2584,12 @@ VkSampler sampler_slow(const samp_par &p,Image &im,VkFormat viewed,bool integer_
|
||||
VkSamplerCreateInfo s{};int result=xbg_sampler_from_nvn(&input,&limits,&s);
|
||||
if(result)xbg_fatalf("NVN sampler %s result=%d min=%u mag=%u wrap=%u/%u/%u lod=%g/%g bias=%g aniso=%g compare=%u/%u border=%g,%g,%g,%g texture=%llu format=%#x vk=%u mirrorEnabled=%u",xbg_sampler_error(result),result,p.minf,p.magf,p.ws,p.wt,p.wr,p.lod_min,p.lod_max,p.lod_bias,p.aniso,p.cmp_mode,p.cmp_func,p.border[0],p.border[1],p.border[2],p.border[3],(unsigned long long)im.source.serial,im.source.d.format,unsigned(viewed),sampler_mirror_clamp_enabled);
|
||||
const VkFormatProperties &fp=format_properties(viewed);
|
||||
if((s.minFilter==VK_FILTER_LINEAR || s.magFilter==VK_FILTER_LINEAR) && !(fp.optimalTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)){
|
||||
if((s.minFilter==VK_FILTER_LINEAR || s.magFilter==VK_FILTER_LINEAR || s.mipmapMode==VK_SAMPLER_MIPMAP_MODE_LINEAR) && !(fp.optimalTilingFeatures&VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)){
|
||||
// 个别驱动(如 Mali)不为某些格式报告线性过滤(Adreno 报告):降级为最近点并记日志,不再中止 | Some drivers (e.g. Mali) omit the linear-filter bit for formats Adreno reports it for: fall back to NEAREST with a log line instead of aborting
|
||||
xbg_logf("NVN sampler linear unsupported min=%u mag=%u compare=%u/%u format=%#x vk=%u optimalFeatures=%#x texture=%llu decoded=%d imfmt=%u -> NEAREST",p.minf,p.magf,p.cmp_mode,p.cmp_func,im.source.d.format,unsigned(viewed),fp.optimalTilingFeatures,(unsigned long long)im.source.serial,int(im.decoded),unsigned(im.fmt));
|
||||
if(s.minFilter==VK_FILTER_LINEAR)s.minFilter=VK_FILTER_NEAREST;
|
||||
if(s.magFilter==VK_FILTER_LINEAR)s.magFilter=VK_FILTER_NEAREST;
|
||||
s.mipmapMode=VK_SAMPLER_MIPMAP_MODE_NEAREST; // 线性 mipmap 同样要求这一能力位(Vulkan 规范)| linear mipmapping needs the same feature bit (Vulkan spec)
|
||||
s.anisotropyEnable=VK_FALSE;s.maxAnisotropy=1.0f;
|
||||
}
|
||||
need(s.pNext==nullptr,"Unexpected sampler extension chain");
|
||||
|
||||
@@ -301,10 +301,10 @@ uint64_t front_game_res(int docked) {
|
||||
// 900 tall x 0.75 while UI text is sharp; measured about 2-3 FPS less on the Pura X (GPU 24 -> 27 ms). A DM_3D_SCALE given in dm/env is left alone
|
||||
const char *nr = getenv("DM_NATIVE_RES");
|
||||
if ((!nr || *nr != '0') && docked && nh >= 720) { unsigned nw = (unsigned)(llround(nh * aspect / 8) * 8); if (nw > 4096) { nw = 4096; nh = (unsigned)llround(4096 / aspect); }
|
||||
if (!getenv("DM_3D_SCALE")) { double sc = 700.0 / nh; char v[16]; snprintf(v, sizeof v, "%.2f", sc < 0.5 ? 0.5 : sc > 0.75 ? 0.75 : sc); setenv("DM_3D_SCALE", v, 0); setenv("DM_3D_SCALE_FLOOR", v, 0);
|
||||
if (!getenv("DM_3D_SCALE")) { double sc = 700.0 / nh; char v[16]; snprintf(v, sizeof v, "%.2f", sc < 0.5 ? 0.5 : sc > 0.75 ? 0.75 : sc); setenv("DM_3D_SCALE_DEFAULT", v, 0); setenv("DM_3D_SCALE_FLOOR", v, 0);
|
||||
LOG("画面:原生像素出图 %ux%u,3D 比例 %s", nw, nh, v); }
|
||||
return (uint64_t)nh << 32 | nw; }
|
||||
if (docked && !getenv("DM_3D_SCALE")) { setenv("DM_3D_SCALE", "0.75", 0); setenv("DM_3D_SCALE_FLOOR", "0.75", 0); }
|
||||
if (docked && !getenv("DM_3D_SCALE")) { setenv("DM_3D_SCALE_DEFAULT", "0.75", 0); setenv("DM_3D_SCALE_FLOOR", "0.75", 0); }
|
||||
unsigned bw = (unsigned)(llround((double)bh * aspect / 8) * 8); if (bw > 4096) bw = 4096;
|
||||
return (uint64_t)bh << 32 | bw;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user