fix: preserve D3D texture addressing in native UI sampling
This commit is contained in:
@@ -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