fix: preserve D3D texture addressing in native UI sampling

This commit is contained in:
shen
2026-10-18 03:49:11 -07:00
parent fe6e41dc8e
commit b61140b8f4
13 changed files with 94 additions and 9 deletions
+24
View File
@@ -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);
}