fix: preserve D3D texture addressing in native UI sampling
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# UI texture addressing, 2026-10-18
|
||||
|
||||
Scope: CGraphicExpandedImageInstance::OnRender / SetRenderingRect and the native sampler path. This does not establish full HUD or Windows visual parity.
|
||||
|
||||
The full reference ExpandedImageInstance unit was read alongside its platform counterpart. The geometry and UV arithmetic remain unchanged. Reference EterLib/StateManager.cpp SetDefaultState sets stage U/V to D3DTADDRESS_WRAP; the runtime ui.py Board.SetSize expands the texture coordinates to repeat a background. The former native UI descriptor unconditionally used CLAMP_TO_EDGE, producing stretched final-row/column stripes.
|
||||
|
||||
UIRenderAddImageNamed now carries stage-0 U/V from CStateManager. Vulkan reuses its D3D sampler cache for non-clamp addressing, preserving independent wrap/mirror/clamp, mip-zero UI filtering and point/linear choice. Direct platform commands retain their previous clamp defaults; the second-stage mask retains clamp. Capture version 11 serializes U/V; version 1–10 remains readable with the old UI clamp behavior.
|
||||
|
||||
Validation:
|
||||
|
||||
- port_grp_resource_test: repeated UV extent, independent wrap/mirror state and explicit clamp.
|
||||
- host_ui_sampler_capture_test: version 11 roundtrip and version 10 backward compatibility.
|
||||
- host.ui_quality regression unchanged.
|
||||
- `ctest --test-dir build/native -R '^(host.ui_sampler_capture|port.grp_resource|host.ui_quality)$' --output-on-failure`: 3 passed.
|
||||
- Native macOS sbtest client: the same AVA2 pickup panel lost its stretched stripes and renders the repeated stone texture. Evidence: build/parity-acceptance-20261018/before-ui-address.png and after-ui-address.png, captured through CUA. The icon for persisted affect 705 also renders.
|
||||
|
||||
No Android visual acceptance or Windows pixel comparison was performed in this round. Aggregate UI contracts remain PARTIAL.
|
||||
@@ -653,3 +653,4 @@
|
||||
{"date": "2026-10-01", "unit": "UserInterface/PythonPlayerAutoHunt.cpp", "action": "user-authorized-extension", "evidence": ["docs/AUTO-HUNT-ENHANCEMENTS.md", "build/autohunt-enhance-test.log", "build/autohunt-enhance-mobile-test.log", "build/autohunt-enhance-mac-build.log", "build/autohunt-enhance-android-build.log", "build/qa/autohunt-enhance-ui/settings.png"], "finding": "Added bounded terrain/scene-collision A* and reachability for combat/loot/return; independent learned skill-ID selection with legacy config migration; optional server restart_here and 5-second/70%-HP recovery; acknowledged dismount/cast/remount batching. Original manual movement and packed Python scripts unchanged. Desktop/mobile fake-server integration and macOS/Android builds pass; real-server soak not claimed."}
|
||||
{"date": "2026-10-16", "unit": "UserInterface/PythonApplication.cpp:Destroy / PythonBoot::Stop", "action": "fix-host-teardown-order", "finding": "40250 drains flying instances before effects/characters; host previously reset effects before CFlyingManager destruction. Explicit flying and character cleanup fixes live-projectile shutdown; overall Destroy remains DIVERGENT for unrelated omissions.", "evidence": ["tests/port/port_app_loop_test.cpp", "build/followup-shutdown-before.log", "build/followup-shutdown-after.log"]}
|
||||
{"date": "2026-10-17", "unit": "UserInterface/PythonPlayerAutoHunt.cpp::__AutoHunt_BuildPath", "action": "user-authorized-extension", "finding": "Live snow floor 1 knockback left the player at (18730.742,22544.762), inside blocked attribute row 225. Exact-start-only exemption rejected every path/attack sample, including monsters 90 units away. Permit only the occupied loaded blocked terrain cell, retaining adjacent blocked cells, scene collision and unloaded-data rejection. AutoHunt is an authorized extension, not a newly claimed 40250 counterpart.", "evidence": ["tests/host/autohunt_navigation_test.cpp", "docs/AVA2-FOLLOWUP-20261016.md"], "remaining": "Live dungeon soak pending; no parity status upgraded. Port-map helper script absent on this branch."}
|
||||
{"time": "2026-10-18T10:49:04.284335+00:00", "event": "platform_fix", "unit": "EterLib/GrpExpandedImageInstance.cpp", "result": "ADAPTED", "reason": "Preserve stage-0 U/V in UI command/sampler path instead of unconditional clamp; repeated Board backgrounds validated on macOS. Aggregate UI remains PARTIAL.", "evidence": ["audit/evidence/2026-10-18-ui-addressing.md", "tests/port/port_grp_resource_test.cpp", "tests/host/ui_sampler_capture_test.cpp"]}
|
||||
|
||||
+2
-1
@@ -4270,7 +4270,8 @@
|
||||
"2026-09-30: native UI HiDPI font refresh and sampling checks PASS; previous font runtime fails 9 new assertions. Full native CTest: 29 pass, codepage and live login skipped. Actual mac app HD archive/launch/screenshot checks recorded in audit/evidence/2026-09-30-mac-ui-clarity.md. Aggregate HUD parity remains PARTIAL."
|
||||
],
|
||||
"notes": [
|
||||
"2026-10-02: SCREEN waypoint atlas must retain original black RGB under alpha=0; HD minimap.dds colour bleed reproduced, native five-frame waypoint smoke renders clean rings after original-atlas fallback. build/minimap-fix-smoke.png. Full Windows visual parity remains unverified."
|
||||
"2026-10-02: SCREEN waypoint atlas must retain original black RGB under alpha=0; HD minimap.dds colour bleed reproduced, native five-frame waypoint smoke renders clean rings after original-atlas fallback. build/minimap-fix-smoke.png. Full Windows visual parity remains unverified.",
|
||||
"2026-10-18: native UI stage-0 wrap/mirror/clamp now follows CStateManager, fixing repeated Board backgrounds. Three focused CTests and real macOS before/after screenshots pass; audit/evidence/2026-10-18-ui-addressing.md. Aggregate remains PARTIAL; Android/Windows comparison outstanding."
|
||||
]
|
||||
},
|
||||
"remaining": [
|
||||
|
||||
@@ -46,9 +46,10 @@
|
||||
"src/platform/EterLib/GrpExpandedImageInstance.cpp:CGraphicExpandedImageInstance::OnRender"
|
||||
],
|
||||
"test": [
|
||||
"tests/port/port_grp_resource_test.cpp"
|
||||
"tests/port/port_grp_resource_test.cpp",
|
||||
"tests/host/ui_sampler_capture_test.cpp"
|
||||
],
|
||||
"note": "40250: CULLMODE CCW for a mirrored scale, Save/RestoreRenderState SRCBLEND/DESTBLEND per RENDERING_MODE, PDT-stream fill-rect draw. Port: the verbatim vertices plus m_iRenderingMode go to UIRenderAddImage; the Vulkan UI pipeline (cull none) maps SCREEN/COLOR_DODGE to INVDESTCOLOR+ONE and MODULATE to ZERO+SRCCOLOR (ui_batches.cpp). Invariant: same corners, UVs and blend factors."
|
||||
"note": "40250: CULLMODE CCW for a mirrored scale, Save/RestoreRenderState SRCBLEND/DESTBLEND per RENDERING_MODE, PDT-stream fill-rect draw. Port: the verbatim vertices plus m_iRenderingMode go to UIRenderAddImage; the Vulkan UI pipeline (cull none) maps SCREEN/COLOR_DODGE to INVDESTCOLOR+ONE and MODULATE to ZERO+SRCCOLOR (ui_batches.cpp). Invariant: same corners, UVs and blend factors. 2026-10-18: stage-0 U/V addressing is carried into Vulkan UI descriptors; the prior unconditional clamp stretched Board.SetRenderingRect tiling into edge stripes. Native before/after screenshots and independent wrap/mirror/clamp tests are recorded in audit/evidence/2026-10-18-ui-addressing.md."
|
||||
},
|
||||
"CGraphicExpandedImageInstance::SetDepth": {
|
||||
"status": "PORTED",
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
// and 2D UIRenderCommand stream + memory textures ("MTRA").
|
||||
// - Version 5: adds per-draw fog color, mode, range and distance/density state.
|
||||
// - Version 6: adds texture address and filtering state for both stages.
|
||||
// - Version 11: adds D3D8 UI stage-0 U/V addressing; older UI captures retain clamp.
|
||||
// - Version 7: adds two fixed-function lights and material color sources.
|
||||
// - Version 8: eight lights, back-buffer clear entries, viewport MinZ/MaxZ, border color,
|
||||
// TEXCOORDINDEX / TEXTURETRANSFORMFLAGS / D3DTS_TEXTUREn per stage, emissive
|
||||
@@ -28,7 +29,7 @@
|
||||
namespace native_draw_capture {
|
||||
|
||||
struct Capture {
|
||||
std::uint32_t version = 10;
|
||||
std::uint32_t version = 11;
|
||||
std::vector<Render3DDraw> draws;
|
||||
std::unordered_map<std::string, std::vector<std::uint8_t>> textures;
|
||||
std::uint32_t ui_width = 960;
|
||||
@@ -114,7 +115,7 @@ inline void write(
|
||||
std::ofstream file(path, std::ios::binary | std::ios::trunc);
|
||||
if (!file) throw std::runtime_error("cannot create native draw capture: " + path);
|
||||
const std::uint32_t magic = 0x4d544452; // MTDR
|
||||
const std::uint32_t version = 10;
|
||||
const std::uint32_t version = 11;
|
||||
const auto count = static_cast<std::uint32_t>(draws.size());
|
||||
write_scalar(file, magic); write_scalar(file, version); write_scalar(file, count);
|
||||
for (const auto& draw : draws) {
|
||||
@@ -233,6 +234,7 @@ inline void write(
|
||||
write_string(file, cmd.mask);
|
||||
file.write(reinterpret_cast<const char*>(cmd.mu), sizeof(cmd.mu));
|
||||
file.write(reinterpret_cast<const char*>(cmd.mv), sizeof(cmd.mv));
|
||||
write_scalar(file,cmd.address_u);write_scalar(file,cmd.address_v);
|
||||
}
|
||||
if (!file) throw std::runtime_error("failed to write native draw capture: " + path);
|
||||
}
|
||||
@@ -242,7 +244,7 @@ inline Capture read_capture(const std::string& path) {
|
||||
if (!file) throw std::runtime_error("cannot open native draw capture: " + path);
|
||||
std::uint32_t magic = 0, version = 0, count = 0;
|
||||
read_scalar(file, magic); read_scalar(file, version); read_scalar(file, count);
|
||||
if (magic != 0x4d544452 || (version < 1 || version > 10) || count > 10'000)
|
||||
if (magic != 0x4d544452 || (version < 1 || version > 11) || count > 10'000)
|
||||
throw std::runtime_error("unsupported native draw capture format");
|
||||
Capture capture;
|
||||
capture.version = version;
|
||||
@@ -404,6 +406,7 @@ inline Capture read_capture(const std::string& path) {
|
||||
read_string(file, cmd.mask);
|
||||
file.read(reinterpret_cast<char*>(cmd.mu), sizeof(cmd.mu));
|
||||
file.read(reinterpret_cast<char*>(cmd.mv), sizeof(cmd.mv));
|
||||
if(version>=11) {read_scalar(file,cmd.address_u);read_scalar(file,cmd.address_v);}
|
||||
if (!file) throw std::runtime_error("truncated native draw capture UI command");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void VulkanWindow::build_ui_batches(
|
||||
? ((cmd.blend == 1 || cmd.blend == 2) ? 0x2A : (cmd.blend == 3 ? 0x31 : 1))
|
||||
: 1;
|
||||
const VkPipeline pipeline = get_pipeline(0, 0, blend_mode);
|
||||
const VkDescriptorSet descriptor = get_ui_texture_descriptor(tex_name, mask_name, capture_textures, point);
|
||||
const VkDescriptorSet descriptor = get_ui_texture_descriptor(tex_name, mask_name, capture_textures, point, cmd.address_u, cmd.address_v);
|
||||
|
||||
for (int k = 0; k < 4; ++k) {
|
||||
Vertex& vert = vertices[v_count + k];
|
||||
|
||||
@@ -195,7 +195,20 @@ VkDescriptorSet VulkanWindow::get_texture_descriptor(
|
||||
VkDescriptorSet VulkanWindow::get_ui_texture_descriptor(
|
||||
const std::string& texture0_name,
|
||||
const std::string& mask_name,
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures, bool point) {
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures, bool point,
|
||||
std::uint32_t address_u,std::uint32_t address_v) {
|
||||
if(address_u!=3 || address_v!=3) {
|
||||
// 40250 ExpandedImage uses the current D3D8 addressing state. Board backgrounds tile;
|
||||
// clamping them stretches the edge texels into stripes. Reuse the existing sampler cache.
|
||||
Render3DDraw state{};
|
||||
state.address_u[0]=address_u; state.address_v[0]=address_v;
|
||||
state.address_u[1]=state.address_v[1]=3;
|
||||
for(int i=0;i<2;++i) {
|
||||
state.min_filter[i]=state.mag_filter[i]=point?1:2;
|
||||
state.mip_filter[i]=0; // UI remains at mip zero, including the HD archive.
|
||||
}
|
||||
return get_texture_descriptor(texture0_name,mask_name,capture_textures,state);
|
||||
}
|
||||
auto& tex0 = get_gpu_texture(texture0_name, capture_textures);
|
||||
if (point && mask_name.empty() && tex0.view) {
|
||||
if (!tex0.ui_point_descriptor)
|
||||
|
||||
@@ -357,7 +357,7 @@ private:
|
||||
const std::string& texture0_name,
|
||||
const std::string& mask_name,
|
||||
const std::unordered_map<std::string, std::vector<std::uint8_t>>& capture_textures,
|
||||
bool point = false);
|
||||
bool point = false, std::uint32_t address_u = 3, std::uint32_t address_v = 3);
|
||||
|
||||
void upload_texture(
|
||||
std::uint32_t width,
|
||||
|
||||
@@ -112,10 +112,13 @@ void UIRenderAddImageNamed(const std::string& texture_name, const float x[4], co
|
||||
// 40250 draws the image quad through the device: the UI pass's world transform places it
|
||||
// (identity except where a caller sets one, e.g. CPythonMiniMap::RenderAtlas's window offset) and a
|
||||
// stage-0 MODULATE with D3DTA_TFACTOR tints it (the atlas's NPC/warp/waypoint marks).
|
||||
DWORD address_u = D3DTADDRESS_WRAP, address_v = D3DTADDRESS_WRAP;
|
||||
D3DXMATRIX world;
|
||||
D3DXMatrixIdentity(&world);
|
||||
if (CStateManager* state = CStateManager::InstancePtr()) {
|
||||
state->GetTransform(D3DTS_WORLD, &world);
|
||||
state->GetTextureStageState(0,D3DTSS_ADDRESSU,&address_u);
|
||||
state->GetTextureStageState(0,D3DTSS_ADDRESSV,&address_v);
|
||||
DWORD op = 0, arg1 = 0, arg2 = 0;
|
||||
state->GetTextureStageState(0, D3DTSS_COLOROP, &op);
|
||||
state->GetTextureStageState(0, D3DTSS_COLORARG1, &arg1);
|
||||
@@ -148,5 +151,6 @@ void UIRenderAddImageNamed(const std::string& texture_name, const float x[4], co
|
||||
command.quad = true;
|
||||
command.su = su; command.sv = sv; command.eu = eu; command.ev = ev;
|
||||
command.blend = blend;
|
||||
command.address_u = address_u; command.address_v = address_v;
|
||||
UIRenderAdd(std::move(command));
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ struct UIRenderCommand {
|
||||
std::string mask;
|
||||
float mu[4] = {}, mv[4] = {};
|
||||
bool behind_3d = false;
|
||||
// D3D8 texture stage 0 addressing. Direct platform commands retain their clamp default.
|
||||
std::uint32_t address_u = 3, address_v = 3;
|
||||
};
|
||||
|
||||
// D3DXCOLOR (0..1 floats) -> the 0xAARRGGBB the commands carry.
|
||||
|
||||
@@ -197,6 +197,9 @@ if(BUILD_TESTING AND CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME)
|
||||
|
||||
# 批次 2V0-g: the 40250 font path over the FreeType GDI emulation; needs a system Tahoma.
|
||||
add_executable(port_text_test ${PROJECT_SOURCE_DIR}/tests/port/port_text_test.cpp)
|
||||
add_executable(host_ui_sampler_capture_test ${PROJECT_SOURCE_DIR}/tests/host/ui_sampler_capture_test.cpp)
|
||||
target_compile_features(host_ui_sampler_capture_test PRIVATE cxx_std_17)
|
||||
add_test(NAME host.ui_sampler_capture COMMAND host_ui_sampler_capture_test)
|
||||
add_executable(host_ui_quality_test ${PROJECT_SOURCE_DIR}/tests/host/ui_quality_test.cpp)
|
||||
add_test(NAME host.ui_quality COMMAND host_ui_quality_test)
|
||||
add_executable(host_touch_layout_test ${PROJECT_SOURCE_DIR}/tests/host/touch_layout_test.cpp)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include "../../src/host/draw_capture.h"
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <iterator>
|
||||
int main() {
|
||||
char path[]="/tmp/metin2-ui-address-XXXXXX";
|
||||
int fd=mkstemp(path);assert(fd>=0);close(fd);
|
||||
UIRenderCommand cmd{UIRenderCommand::Image,0,0,320,470,0xffffffff};
|
||||
cmd.quad=true;cmd.eu=2.5f;cmd.ev=3.5f;cmd.address_u=1;cmd.address_v=2;
|
||||
native_draw_capture::write(path,{}, {},320,470,{cmd});
|
||||
auto current=native_draw_capture::read_capture(path);
|
||||
assert(current.version==11 && current.ui_commands.size()==1);
|
||||
assert(current.ui_commands[0].address_u==1 && current.ui_commands[0].address_v==2);
|
||||
assert(current.ui_commands[0].eu==2.5f && current.ui_commands[0].ev==3.5f);
|
||||
// Version 10 ends the UI record before the two address fields. Old captures must still load.
|
||||
std::ifstream input(path,std::ios::binary);
|
||||
std::vector<char> bytes((std::istreambuf_iterator<char>(input)),{});input.close();
|
||||
bytes[4]=10;bytes.resize(bytes.size()-8);
|
||||
std::ofstream output(path,std::ios::binary|std::ios::trunc);output.write(bytes.data(),bytes.size());output.close();
|
||||
auto legacy=native_draw_capture::read_capture(path);
|
||||
assert(legacy.version==10 && legacy.ui_commands[0].address_u==3 && legacy.ui_commands[0].address_v==3);
|
||||
unlink(path);
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "EterLib/GrpImageTexture.h"
|
||||
#include "EterLib/GrpIndexBuffer.h"
|
||||
#include "EterLib/GrpVertexBuffer.h"
|
||||
#include "EterLib/StateManager.h"
|
||||
#include "../../src/platform/EterLib/CpuBuffer.h"
|
||||
#include "../../src/platform/EterLib/RecordingDevice.h"
|
||||
#include "../../src/platform/EterLib/UIRenderCommands.h"
|
||||
@@ -78,6 +79,7 @@ int main()
|
||||
{
|
||||
IDirect3DDevice8* device = MtCreateRecordingDevice(800, 600);
|
||||
BaseAccess::SetDevice(device);
|
||||
CStateManager stateManager(device);
|
||||
BaseAccess::SetLowTextureMemory(false);
|
||||
|
||||
// A DXT .dds goes through CDXTCImage::LoadHeaderFromMemory + CreateDDSTexture; the handle names the file.
|
||||
@@ -170,6 +172,20 @@ int main()
|
||||
check(c.qx[1] == 60 && c.qy[2] == 20 && c.eu == 0.5f, "expanded quad and rendering rect");
|
||||
check(c.blend == CGraphicExpandedImageInstance::RENDERING_MODE_MODULATE, "expanded blend mode");
|
||||
}
|
||||
CStateManager& state=CStateManager::Instance();
|
||||
state.SetTextureStageState(0,D3DTSS_ADDRESSU,D3DTADDRESS_WRAP);
|
||||
state.SetTextureStageState(0,D3DTSS_ADDRESSV,D3DTADDRESS_MIRROR);
|
||||
expanded.SetRenderingRect(0,0,2,3);
|
||||
UIRenderBeginFrame();expanded.Render();
|
||||
check(commands.size()==1 && commands[0].eu==3 && commands[0].ev==4,
|
||||
"expanded background preserves repeated UV extent");
|
||||
check(commands[0].address_u==D3DTADDRESS_WRAP && commands[0].address_v==D3DTADDRESS_MIRROR,
|
||||
"UI command preserves independent D3D texture addressing");
|
||||
state.SetTextureStageState(0,D3DTSS_ADDRESSU,D3DTADDRESS_CLAMP);
|
||||
state.SetTextureStageState(0,D3DTSS_ADDRESSV,D3DTADDRESS_CLAMP);
|
||||
UIRenderBeginFrame();expanded.Render();
|
||||
check(commands[0].address_u==D3DTADDRESS_CLAMP && commands[0].address_v==D3DTADDRESS_CLAMP,
|
||||
"UI explicit clamp is retained");
|
||||
instance.Destroy();
|
||||
expanded.Destroy();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user