1#include "../Rendering/ExteriorRain11.h"
2#include "Reference9/ExteriorRainRenderer.h"
3#include <d3d11sdklayers.h>
4#include <cstring>
5#include <iostream>
6#include <filesystem>
7#include <fstream>
8#include <stdexcept>
9using Microsoft::WRL::ComPtr;
11namespace
12{
13 constexpr UINT Width=640,Height=480;
14 void HR(
HRESULT hr,
const char* message) {
if(FAILED(hr))
throw std::runtime_error(std::string(message)+
": "+std::to_string(hr));}
15 void Check(bool value,const char* message) {if(!value)throw std::runtime_error(message);}
16 void VerifyPhysicalMotion()
17 {
19 DirectX::XMStoreFloat4x4(&identity,DirectX::XMMatrixIdentity());
20 constexpr float expectedMs[]={5.903285f,6.018008f,6.111935f,6.188836f};
21 for(int fps : {30,60,144})
22 {
24 for(
int frame=0;frame<fps;++frame)falling.
Update(1.f/fps,p,identity);
25 for(unsigned group=0;group<4;++group)
26 {
27 const auto phase=falling.
Offsets()[group];
28 const float speed=(phase.w-phase.y)*1000;
29 Check(std::abs(speed-expectedMs[group])<.002f,
30 "Vieneo large drops fall 5.90-6.19 m/s at 30/60/144 FPS");
31 }
32 }
34 "Earth calibration recovers measured 4 mm drop speed");
37 "denser Vieneo air slows rain; lower density increases terminal speed");
40 for(unsigned group=0;group<4;++group)
41 {
42 const auto phase=snow.
Offsets()[group];
43 Check(std::abs((phase.w-phase.y)*1000-(.84f+.24f*group))<.002f,
44 "snow retains its original motion");
45 }
46 std::cout<<"PASS: physical terminal speed, atmospheric density, snow and frame-rate invariance\n";
47 }
48 struct Fixture
49 {
50 HWND window=nullptr;
51 Device11 gpu;
52 ComPtr<IDirect3D9> d3d;
53 ComPtr<IDirect3DDevice9> reference;
54 ComPtr<IDirect3DSurface9> color9,read9,depth9;
55 ComPtr<ID3D11Texture2D> color11,read11;
56 ComPtr<ID3D11RenderTargetView>
target;
57 SceneDepth11 depth;
58 ExteriorRainRenderer oldRain;
59 ExteriorRain11 rain;
60 std::filesystem::path
output;
61 std::ofstream metrics;
62 explicit Fixture(bool warp,bool debug)
63 {
64 output=std::string(
"outputs/direct3d11/rain-")+(warp ?
"warp" :
"hardware");std::filesystem::create_directories(output);
65 metrics.open(output/"metrics.csv");metrics<<"scenario,mean_rgb,mean_alpha,fraction_over_3,reference_energy\n";
66 window=CreateWindowW(L"STATIC",L"Rain comparison",WS_POPUP,0,0,Width,Height,nullptr,nullptr,GetModuleHandleW(nullptr),nullptr);
67 Check(window!=
nullptr,
"fixture window");HR(gpu.
Create({warp ? D3D_DRIVER_TYPE_WARP : D3D_DRIVER_TYPE_HARDWARE,debug}),
"native device");
68 std::cout<<gpu.
Status()<<std::endl;
69 d3d.Attach(Direct3DCreate9(D3D_SDK_VERSION));Check(bool(d3d),"D3D9 reference");
70 D3DPRESENT_PARAMETERS present{};present.Windowed=TRUE;present.SwapEffect=D3DSWAPEFFECT_DISCARD;present.hDeviceWindow=window;
71 present.BackBufferWidth=
Width;present.BackBufferHeight=
Height;
72 HR(d3d->CreateDevice(0,D3DDEVTYPE_HAL,window,D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE,&present,&reference),"reference device");
73 HR(reference->CreateRenderTarget(Width,Height,D3DFMT_A8R8G8B8,D3DMULTISAMPLE_NONE,0,FALSE,&color9,nullptr),"reference color");
74 HR(reference->CreateOffscreenPlainSurface(Width,Height,D3DFMT_A8R8G8B8,D3DPOOL_SYSTEMMEM,&read9,nullptr),"reference staging");
75 HR(reference->CreateDepthStencilSurface(Width,Height,D3DFMT_D24S8,D3DMULTISAMPLE_NONE,0,FALSE,&depth9,nullptr),"reference depth");
76 HR(oldRain.
Initialize(reference.Get()),
"reference rain");
77 D3D11_TEXTURE2D_DESC desc{};desc.Width=
Width;desc.Height=
Height;desc.ArraySize=desc.MipLevels=1;
78 desc.Format=DXGI_FORMAT_B8G8R8A8_UNORM;desc.SampleDesc.Count=1;desc.BindFlags=D3D11_BIND_RENDER_TARGET;
79 HR(gpu.
Device()->CreateTexture2D(&desc,
nullptr,&color11),
"native color");HR(gpu.
Device()->CreateRenderTargetView(color11.Get(),
nullptr,&target),
"native RTV");
80 desc.Usage=D3D11_USAGE_STAGING;desc.BindFlags=0;desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
81 HR(gpu.
Device()->CreateTexture2D(&desc,
nullptr,&read11),
"native staging");HR(depth.
Create(gpu.
Device(),Width,Height,{1,0}),
"native depth");
82 HR(rain.
Initialize(gpu.
Device(),
"outputs/direct3d11/shaders"),
"native rain");
83 }
84 ~Fixture()
85 {
87 reference.Reset();d3d.Reset();if(window)DestroyWindow(window);
88 }
89 void Compare(unsigned scenario)
90 {
94 old.
wind={.003f,-.001f,.004f};current.
wind={.003f,-.001f,.004f};
98 D3DXMATRIX rotation;D3DXMatrixRotationYawPitchRoll(&rotation,.3f,-.1f,.2f);
99 ExteriorRain11::Matrix nativeRotation;memcpy(&nativeRotation,&rotation,sizeof(rotation));
100 for(unsigned frame=0;frame<120;++frame)
101 {
102 oldRain.
Update(1.f/60,old,rotation);rain.
Update(1.f/60,current,nativeRotation);
104 Check(rain.
DropCount()==(scenario==0 ? 16384u : scenario==1 ? 8192u : 3328u),
105 "storm density doubles while snow and lighter rain retain their budgets");
106 for(unsigned group=0;group<4;++group)
107 {
108 const auto& a=oldRain.
Offsets()[group];
const auto& b=rain.
Offsets()[group];
109 Check(std::abs(a.x-b.x)<1e-6f && std::abs(a.y-b.y)<1e-6f && std::abs(a.z-b.z)<1e-6f && a.w==b.w,"bounded advection parity");
110 }
111 }
112 D3DXMATRIX view,projection,correction;D3DXMatrixIdentity(&view);
113 D3DXMatrixPerspectiveFovRH(&projection,1.f,float(Width)/Height,.001f,384);
114 ExteriorRain11::Matrix nativeView,nativeProjection;
115 memcpy(&nativeView,&view,sizeof(view));memcpy(&nativeProjection,&projection,sizeof(projection));
116 D3DXMatrixIdentity(&correction);correction._41=-1.f/
Width;correction._42=1.f/
Height;projection*=correction;
117 reference->SetTransform(D3DTS_VIEW,&view);reference->SetTransform(D3DTS_PROJECTION,&projection);
118 HR(reference->SetRenderTarget(0,color9.Get()),"reference target");HR(reference->SetDepthStencilSurface(depth9.Get()),"reference DSV");
119 const D3DVIEWPORT9 viewport9{0,0,
Width,
Height,0,1};reference->SetViewport(&viewport9);
120 reference->SetRenderState(D3DRS_COLORWRITEENABLE,15);reference->SetRenderState(D3DRS_SRGBWRITEENABLE,FALSE);
121 HR(reference->Clear(0,nullptr,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL,0xff000000,1,0),"reference clear");
122 HR(reference->BeginScene(),
"reference begin");HR(oldRain.
Render(reference.Get()),
"reference rain draw");HR(reference->EndScene(),
"reference end");
123 HR(reference->GetRenderTargetData(color9.Get(),read9.Get()),"reference read");
124 D3DLOCKED_RECT locked{};HR(read9->LockRect(&locked,nullptr,D3DLOCK_READONLY),"reference map");std::vector<uint32_t> expected(Width*Height);
125 for(UINT y=0;y<
Height;++y)memcpy(expected.data()+y*Width,
static_cast<char*
>(locked.pBits)+y*locked.Pitch,Width*4);read9->UnlockRect();
126 const float black[]={0,0,0,1};gpu.
Context()->ClearRenderTargetView(
target.Get(),black);gpu.
Context()->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
127 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};
128 HR(rain.
Render(gpu.
Context(),
target.Get(),depth,viewport,nativeView,nativeProjection),
"native rain draw");
129 gpu.
Context()->CopyResource(read11.Get(),color11.Get());D3D11_MAPPED_SUBRESOURCE mapped{};
130 HR(gpu.
Context()->Map(read11.Get(),0,D3D11_MAP_READ,0,&mapped),
"native read");
double error=0,alpha=0,energy=0;
unsigned over=0;
131 std::vector<uint32_t> actual(Width*Height),difference(Width*Height);
132 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
133 {
134 const auto a=expected[y*
Width+x];
const auto b=
reinterpret_cast<uint32_t*
>(
static_cast<char*
>(mapped.pData)+y*mapped.RowPitch)[x];
136 unsigned worst=0;for(int shift:{0,8,16}){const auto delta=unsigned(std::abs(int((a>>shift)&255)-int((b>>shift)&255)));error+=delta;worst=(std::max)(worst,delta);energy+=(a>>shift)&255;}
137 alpha+=std::abs(int(a>>24)-int(b>>24));if(worst>3)++over;
138 difference[y*
Width+x]=0xff000000|((std::min)(255u,worst*8)*0x10101);
139 }
141 std::cout<<"rain scenario "<<scenario<<" mean="<<error<<" alpha="<<alpha<<" over3="<<fraction<<" referenceEnergy="<<energy<<std::endl;
142 metrics<<scenario<<','<<error<<','<<alpha<<','<<fraction<<','<<energy<<'\n';metrics.flush();
143 Save(expected,scenario,"d3d9");Save(actual,scenario,"d3d11");Save(difference,scenario,"diff8x");
144 Check(energy>1000,"rain reference was not visibly rendered");Check(error<=1 && alpha<=1 && fraction<=.01,"rain pixel parity");
145 }
146 void Save(const std::vector<uint32_t>& pixels,unsigned scenario,const char* suffix)
147 {
148 D3DLOCKED_RECT locked{};HR(read9->LockRect(&locked,nullptr,0),"image export map");
149 for(UINT y=0;y<Height;++y)memcpy(static_cast<char*>(locked.pBits)+y*locked.Pitch,pixels.data()+y*
Width,
Width*4);
150 read9->UnlockRect();
const auto name=
output/(
"rain-"+std::to_string(scenario)+
"-"+suffix+
".png");
151 HR(D3DXSaveSurfaceToFileW(name.c_str(),D3DXIFF_PNG,read9.Get(),nullptr,nullptr),"image export");
152 }
153 void TwoLights()
154 {
155
156 constexpr uint64_t visibleEnergy=100;
157 ExteriorRain11::Parameters p;
165 ExteriorRain11::Matrix identity,projection;
166 DirectX::XMStoreFloat4x4(&identity,DirectX::XMMatrixIdentity());
167 DirectX::XMStoreFloat4x4(&projection,DirectX::XMMatrixPerspectiveFovRH(1.f,float(Width)/Height,.001f,384));
168 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};
169 const auto capture=[&](unsigned image=0) {
170 rain.
Update(0,p,identity);
171 const float black[]={0,0,0,1};gpu.
Context()->ClearRenderTargetView(
target.Get(),black);
172 gpu.
Context()->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
173 HR(rain.
Render(gpu.
Context(),
target.Get(),depth,viewport,identity,projection),
"two-lamp rain");
174 gpu.
Context()->CopyResource(read11.Get(),color11.Get());
175 D3D11_MAPPED_SUBRESOURCE map{};HR(gpu.
Context()->Map(read11.Get(),0,D3D11_MAP_READ,0,&map),
"two-lamp readback");
176 std::array<uint64_t,8> energy{};
177 std::vector<uint32_t> pixels(Width*Height);
178 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
179 {
180 const auto pixel=reinterpret_cast<const uint32_t*>(static_cast<const char*>(map.pData)+y*map.RowPitch)[x];
181 pixels[y*
Width+x]=pixel;
182 energy[0]+=(pixel>>16)&255;energy[1]+=pixel&255;
183 const auto total=((pixel>>16)&255)+(pixel&255);
184 energy[y<
Height/2 ? 2 : 3]+=total;
185 energy[x<
Width/2 ? 4 : 5]+=total;
186 const auto peak=(std::max)({pixel&255,(pixel>>8)&255,(pixel>>16)&255});
187 energy[6]=(std::max)(energy[6],uint64_t(peak));energy[7]+=peak>=230;
188 }
189 gpu.
Context()->Unmap(read11.Get(),0);
190 if(image)Save(pixels,image,"lamp-response");
191 return energy;
192 };
193 const auto both=capture();
194 Check(both[0]>visibleEnergy && both[1]>visibleEnergy,"both independently aimed/positioned lamps illuminate rain");
196 const auto one=capture();Check(one[0]>visibleEnergy && one[1]==0,"single lamp skips unused entry");
198 const auto off=capture();Check(off[0]==0 && off[1]==0,"switch-off clears both lamps");
200 const auto away=capture();Check(away[0]>visibleEnergy && away[1]==0,"second beam uses its own origin and aim");
204 const auto road=capture();
205 Check(road[2]==0 && road[3]>visibleEnergy,"road low beam lights rain only below the cutoff");
206 lamp.up={1,0,0};
207 const auto rolled=capture();
208 Check(rolled[4]>visibleEnergy && rolled[5]==0,"road cutoff rolls with the vehicle");
210 const auto narrow=capture();
212 const auto wide=capture();Check(wide[0]>narrow[0]*1.5,"horizontal taxi spread widens illuminated rain");
213 lamp.range=.008f;const auto shortRange=capture();
214 Check(shortRange[0]<wide[0],"per-lamp range limits rain illumination");
215 lamp.range=lamp.profile.rangeKm;lamp.extinctionPerKm=200;
216 const auto foggy=capture();Check(foggy[0]<wide[0],"weather attenuates rain illumination along the lamp path");
217 std::cout<<"PASS: GPU low-beam cutoff, vehicle roll, taxi spread, range and weather attenuation\n";
218 std::cout<<"PASS: two-lamp rain colors, independent origins/aims, single-lamp and off transitions\n";
219
220
222 lamp.extinctionPerKm=0;lamp.color={1,1,1,1};
223 const auto singleRain=capture();
225 const auto rainLight=capture(3);
226 p.
snow=1;
const auto snowLight=capture(4);
227 std::cout<<"Landing rain/snow peak="<<rainLight[6]<<"/"<<snowLight[6]
228 <<", near-white pixels="<<rainLight[7]<<"/"<<snowLight[7]<<std::endl;
229 Check(rainLight[0]>singleRain[0] && rainLight[0]<singleRain[0]*1.8,
230 "overlapping lamps brighten rain without doubling already intense reflections");
231 Check(rainLight[0]>1000 && rainLight[6]<210 && rainLight[7]==0,
232 "landing-lit rain remains visible without solid-white clipped streaks");
233 Check(snowLight[6]>=230 && snowLight[7]>10 && snowLight[0]>rainLight[0]*2,
234 "snow retains its stronger opaque white scattering response");
235 std::cout<<"PASS: liquid-rain highlights roll off under landing lights; snow remains bright\n";
236 }
237 void StormCoverage()
238 {
239 ExteriorRain11::Matrix identity,view,projection;
240 DirectX::XMStoreFloat4x4(&identity,DirectX::XMMatrixIdentity());
241
242 DirectX::XMStoreFloat4x4(&view,DirectX::XMMatrixTranslation(0,-.004f,-.008f));
243 const float nearWidth=.001f*std::tan(DirectX::XMConvertToRadians(115.f)*.5f);
244 DirectX::XMStoreFloat4x4(&projection,DirectX::XMMatrixPerspectiveRH(
245 nearWidth,nearWidth*Height/Width,.001f,384));
246 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};
247 CloudRenderer11 clouds;HR(clouds.
Initialize(gpu.
Device(),
"outputs/direct3d11/shaders"),
"storm clouds");
248 Check(clouds.
Ready(),
"storm cloud renderer enabled");
249 CloudVolume::Parameters weather;weather.
base=1.4f;weather.
activity=.8f;
250 gpu.
Context()->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
252 {0,weather.radius+.237f,0},weather,{0,1,0},{.015f,.017f,.02f,1},{.015f,.017f,.02f,1}),"prepare storm clouds");
253 std::array<uint64_t,5> clearEnergy{};
254 for(unsigned attenuation=0;attenuation<2;++attenuation)
255 for(unsigned scenario=0;scenario<5;++scenario)
256 {
257 ExteriorRain11 fixture;HR(fixture.
Initialize(gpu.
Device(),
"outputs/direct3d11/shaders"),
"storm fixture");
258 ExteriorRain11::Parameters p;
259 p.
intensity=scenario==0 ? .1f : scenario==1 ? .5f : 1.f;
262 if(scenario==4)
263 {
266 }
271 fixture.
Update(1,p,identity);
273 fixture.
DropCount()==(scenario==0 ? 832u : scenario==1 ? 4160u : 16384u),
274 "light/moderate rain retain their counts; maximum liquid rain doubles");
275 const int bgR=scenario==4 ? 40 : 10,bgG=scenario==4 ? 43 : 14,bgB=scenario==4 ? 46 : 11;
276 const float background[]={bgR/255.f,bgG/255.f,bgB/255.f,1};
277 gpu.
Context()->ClearRenderTargetView(
target.Get(),background);
278 gpu.
Context()->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
279 HR(fixture.
Render(gpu.
Context(),
target.Get(),depth,viewport,view,projection,attenuation ? &clouds :
nullptr),
"parked storm render");
280 gpu.
Context()->CopyResource(read11.Get(),color11.Get());
281 D3D11_MAPPED_SUBRESOURCE map{};HR(gpu.
Context()->Map(read11.Get(),0,D3D11_MAP_READ,0,&map),
"storm readback");
282 std::vector<uint32_t> pixels(Width*Height);unsigned visible=0,peak=0;uint64_t energy=0;
283 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
284 {
285 const auto pixel=reinterpret_cast<const uint32_t*>(static_cast<const char*>(map.pData)+y*map.RowPitch)[x];
286 pixels[y*
Width+x]=pixel;
287 const int contrast=(std::max)({
int((pixel>>16)&255)-bgR,
int((pixel>>8)&255)-bgG,
int(pixel&255)-bgB});
288 visible+=contrast>=3;energy+=(std::max)(0,contrast);peak=(std::max)(peak,unsigned((std::max)(0,contrast)));
289 }
290 gpu.
Context()->Unmap(read11.Get(),0);Save(pixels,10+scenario+5*attenuation,
"parked-storm");
291 std::cout<<
"Parked storm "<<scenario<<
" clouds="<<attenuation<<
": drops="<<fixture.
DropCount()
292 <<" visible="<<visible<<" energy="<<energy<<" peak="<<peak<<std::endl;
293 if(scenario<2)Check(visible<(scenario==0 ? 100u : 600u),"lower rain intensities stay light in a dark sky");
294 else if(scenario<4)Check(visible>6000 && energy>28000,"maximum night storm retains coverage with 30% softer ambient scattering");
295 else Check(visible>6000 && peak<65,"overcast heavy rain remains dense with subdued gray highlights");
296 if(!attenuation)clearEnergy[scenario]=energy;
297 else Check(std::abs(double(energy)-double(clearEnergy[scenario]))<100,
298 "cloud-aware rain retains below-cloud-base storm visibility");
299 if(scenario==3)Check(energy>clearEnergy[2]+50,"nose-mounted lamp still adds rain highlights");
300 }
301 }
302 void BackgroundContrast()
303 {
304 ExteriorRain11::Matrix identity,projection;
305 DirectX::XMStoreFloat4x4(&identity,DirectX::XMMatrixIdentity());
306 DirectX::XMStoreFloat4x4(&projection,DirectX::XMMatrixPerspectiveFovRH(1.f,float(Width)/Height,.001f,384));
307 const D3D11_VIEWPORT viewport{0,0,float(Width),float(Height),0,1};
308 for(unsigned snow=0;snow<2;++snow)
309 {
310 ExteriorRain11 fixture;HR(fixture.
Initialize(gpu.
Device(),
"outputs/direct3d11/shaders"),
"contrast fixture");
313 std::array<uint64_t,2> energy{};
314 for(unsigned sky=0;sky<2;++sky)
315 {
316
317 const unsigned gray=sky ? 82u : 12u;
318 const float background[]={gray/255.f,gray/255.f,gray/255.f,1};
319 gpu.
Context()->ClearRenderTargetView(
target.Get(),background);
320 gpu.
Context()->ClearDepthStencilView(depth.
WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
321 HR(fixture.
Render(gpu.
Context(),
target.Get(),depth,viewport,identity,projection),
"background contrast draw");
322 gpu.
Context()->CopyResource(read11.Get(),color11.Get());D3D11_MAPPED_SUBRESOURCE map{};
323 HR(gpu.
Context()->Map(read11.Get(),0,D3D11_MAP_READ,0,&map),
"background contrast readback");
324 std::vector<uint32_t> pixels(Width*Height);unsigned visible=0;
325 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
326 {
327 const auto pixel=reinterpret_cast<const uint32_t*>(static_cast<const char*>(map.pData)+y*map.RowPitch)[x];
328 pixels[y*
Width+x]=pixel;
unsigned peak=0;
329 for(int shift : {0,8,16})
330 {
331 const unsigned contrast=unsigned(std::abs(int((pixel>>shift)&255)-int(gray)));
332 energy[sky]+=contrast;peak=(std::max)(peak,contrast);
333 }
334 visible+=peak>=3;
335 }
336 gpu.
Context()->Unmap(read11.Get(),0);Save(pixels,30+2*snow+sky,
"background-contrast");
337 std::cout<<"Background contrast snow="<<snow<<" sky="<<sky<<" energy="<<energy[sky]<<" visible="<<visible<<std::endl;
338 }
339 Check(energy[0]>energy[1]*2,"precipitation contrasts more strongly with dark terrain than bright overcast sky");
340
341 if(!snow)
342 {
344 const float gray[]={82.f/255,82.f/255,82.f/255,1};gpu.
Context()->ClearRenderTargetView(
target.Get(),gray);
345 HR(fixture.
Render(gpu.
Context(),
target.Get(),depth,viewport,identity,projection),
"unlit contrast draw");
346 gpu.
Context()->CopyResource(read11.Get(),color11.Get());D3D11_MAPPED_SUBRESOURCE map{};
347 HR(gpu.
Context()->Map(read11.Get(),0,D3D11_MAP_READ,0,&map),
"unlit contrast readback");
348 bool unchanged=true;
349 for(UINT y=0;y<
Height;++y)
for(UINT x=0;x<
Width;++x)
350 unchanged&=(reinterpret_cast<const uint32_t*>(static_cast<const char*>(map.pData)+y*map.RowPitch)[x]&0xffffff)==0x525252;
351 gpu.
Context()->Unmap(read11.Get(),0);Check(unchanged,
"unlit rain leaves the background unchanged");
352 }
353 }
354 }
355 void DebugCheck()
356 {
357 ComPtr<ID3D11InfoQueue> queue;
if(FAILED(gpu.
Device()->QueryInterface(IID_PPV_ARGS(&queue))))
return;
358 for(UINT64 i=0;i<queue->GetNumStoredMessages();++i)
359 {
360 SIZE_T size=0;queue->GetMessage(i,nullptr,&size);std::vector<char> bytes(size);auto* message=reinterpret_cast<D3D11_MESSAGE*>(bytes.data());
361 HR(queue->GetMessage(i,message,&size),"debug message");if(message->Severity<=D3D11_MESSAGE_SEVERITY_WARNING)throw std::runtime_error(message->pDescription);
362 }
363 }
364 };
365}
366int main(
int argc,
char** argv)
367{
368 try
369 {
370 bool warp=false,debug=true;for(int i=1;i<argc;++i){if(!strcmp(argv[i],"--warp"))warp=true;else if(!strcmp(argv[i],"--no-debug-layer"))debug=false;else throw std::runtime_error("unknown argument");}
371 VerifyPhysicalMotion();Fixture test(warp,debug);for(unsigned i=0;i<3;++i)test.Compare(i);test.TwoLights();test.StormCoverage();test.BackgroundContrast();test.DebugCheck();
372 std::cout<<"PASS: rain/snow/headlights, 360 simulation frames and native image parity\n";return 0;
373 }
374 catch(const std::exception& error){std::cerr<<"FAIL: "<<error.what()<<std::endl;return 1;}
375}
SCRIPT_CONTROL SCRIPT_STATE const void int
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
HRESULT Initialize(Rendering::RenderDevice *device)
unsigned DropCount() const
HRESULT Render(Rendering::RenderDevice *device, Rendering::CloudRenderer11 *clouds=nullptr)
const DirectX::XMFLOAT4 * Offsets() const
void Update(float elapsed, const ExteriorRain::Parameters ¶meters, const RiseMath::Matrix &localToWorld)
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const Matrix &view, const Matrix &projection, const Vector &planetEye, const CloudVolume::Parameters ¶ms, const Vector &sunlight, const Color &light, const Color &ambient, const Color &airglow=Color(.125f,.375f,.25f, 1), const Color &horizonHaze=Color(0, 0, 0, 0), const Color &atmosphereHaze=Color(0, 0, 0, 0), const Color &nightVisionGain=Color(1, 1, 1, 0))
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
ID3D11DeviceContext * Context() const
ID3D11Device * Device() const
const std::string & Status() const
HRESULT Create(const DeviceOptions11 &options={})
unsigned DropCount() const
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
ExteriorRain::BasicParameters< Vector, Color > Parameters
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *scene, const SceneDepth11 &depth, const D3D11_VIEWPORT &viewport, const Matrix &view, const Matrix &projection, CloudRenderer11 *clouds=nullptr)
DirectX::XMFLOAT4X4 Matrix
const Color * Offsets() const
void Update(float elapsed, const Parameters ¶meters, const Matrix &localToWorld)
HRESULT Create(ID3D11Device *device, UINT width, UINT height, DXGI_SAMPLE_DESC samples)
ID3D11DepthStencilView * WriteView() const
float TerminalSpeedMs(float diameterMm, float airDensityKgM3, float gravityMs2)
BasicParameters< RiseMath::Vector3, RiseMath::Color > Parameters
constexpr Profile AircraftLanding
constexpr Profile AircraftTaxi
constexpr Profile RoadLow