Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/WindshieldDamage11Tests.cpp

Source at documentation-generation time. See Test catalog for fixture associations.

1#include "../Rendering/WindshieldRain11.h"
2#include "../Rendering/Device11.h"
3#include "../Rendering/FixedFunction11.h"
4#include <d3d11sdklayers.h>
5#include <fstream>
6#include <iostream>
7#include <stdexcept>
8using namespace Rendering;
9using Microsoft::WRL::ComPtr;
10namespace Rendering
11{
12struct WindshieldRain11TestAccess
13{
14 static WindshieldRain::Surface& Water(WindshieldRain11& r){return r.panes.front().water;}
15 static bool Healthy(const WindshieldRain11& r){return r.glassCondition>95;}
16 static bool Released(const WindshieldRain11& r)
17 {for(const auto& p:r.panes)if(p.fractures.texture)return false;return true;}
18};
19}
20namespace
21{
22constexpr UINT W=768,H=384;
23void Check(bool ok,const char* text){if(!ok)throw std::runtime_error(text);}
24void HR(HRESULT hr,const char* =nullptr){if(FAILED(hr))throw std::runtime_error("HRESULT "+std::to_string(hr));}
25void Graph()
26{
27 using namespace WindshieldFractures;
28 for(auto dimensions:std::vector<Point>{{2,1},{.4f,1.7f},{1.5f,.45f}})
29 for(uint32_t seed:{9u,17u,328u})
30 {
31 const auto lines=Network(dimensions.x,dimensions.y,seed);
32 Check(lines.size()>=48,"network density");
33 for(size_t i=1;i<lines.size();++i)
34 {
35 float closest=1.e20f;
36 for(size_t j=0;j<i;++j)closest=(std::min)(closest,SegmentDistanceSquared(lines[i].a,lines[j]));
37 Check(closest<1.e-10f,"every fracture attaches to an older fracture");
38 }
39 const auto again=Network(dimensions.x,dimensions.y,seed);
40 Check(lines.size()==again.size() && !memcmp(lines.data(),again.data(),lines.size()*sizeof(Segment)),"stable network");
41
42 }
43 std::cout<<"PASS: nine pane/seed networks; every new fracture joins an older fracture\n";
44}
45template<class T> T Read(std::ifstream& file,std::streamoff offset)
46{
47 T value{};file.seekg(offset);file.read(reinterpret_cast<char*>(&value),sizeof(value));
48 Check(file.good(),"read authored cockpit");return value;
49}
50void Save(const char* name,const std::vector<uint32_t>& pixels);
51struct Fixture
52{
53 Device11 gpu;WindshieldRain11 rain;
54 ComPtr<ID3D11Texture2D> color,readback;
55 ComPtr<ID3D11RenderTargetView> target;
56 ComPtr<ID3D11RasterizerState> raster;
57 SceneDepth11 depth;
58 D3D11_VIEWPORT viewport{0,0,float(W),float(H),0,1};
59 WindshieldRain11::Matrix identity,projection;
60 Fixture()
61 {
62 HR(gpu.Create({D3D_DRIVER_TYPE_WARP,true}));
63 D3D11_TEXTURE2D_DESC d{};d.Width=W;d.Height=H;d.MipLevels=d.ArraySize=d.SampleDesc.Count=1;
64 d.Format=DXGI_FORMAT_R8G8B8A8_UNORM;d.Usage=D3D11_USAGE_DEFAULT;d.BindFlags=D3D11_BIND_RENDER_TARGET;
65 HR(gpu.Device()->CreateTexture2D(&d,nullptr,&color));HR(gpu.Device()->CreateRenderTargetView(color.Get(),nullptr,&target));
66 d.Usage=D3D11_USAGE_STAGING;d.BindFlags=0;d.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
67 HR(gpu.Device()->CreateTexture2D(&d,nullptr,&readback));
68 HR(depth.Create(gpu.Device(),W,H,{1,0}));
69 D3D11_RASTERIZER_DESC r{};r.FillMode=D3D11_FILL_SOLID;r.CullMode=D3D11_CULL_NONE;r.DepthClipEnable=TRUE;
70 HR(gpu.Device()->CreateRasterizerState(&r,&raster));
71 DirectX::XMStoreFloat4x4(&identity,DirectX::XMMatrixIdentity());
72 DirectX::XMStoreFloat4x4(&projection,DirectX::XMMatrixOrthographicOffCenterLH(0,.002f,0,.001f,0,.01f));
73 HR(rain.Initialize(gpu.Device(),"x64/Release/WindshieldDamage11Tests/obj/NativeShaders11"));
74 WindshieldRain11::Vertex v[]={{0,0,.001f,0,0,1,0,0},{.002f,0,.001f,0,0,1,1,0},{0,.001f,.001f,0,0,1,0,1},
75 {.002f,0,.001f,0,0,1,1,0},{.002f,.001f,.001f,0,0,1,1,1},{0,.001f,.001f,0,0,1,0,1}};
76 rain.AddGlass(0,v,6);rain.FinishGeometry();
77 }
78
79 void AuthoredDamage(const char* model)
80 {
81 using namespace Rendering::Math11;
82 WindshieldRain11 wet;
83 HR(wet.Initialize(gpu.Device(),"x64/Release/WindshieldDamage11Tests/obj/NativeShaders11"),"authored rain device");
84 std::ifstream dix(std::string("Meshes/")+model+".dix",std::ios::binary),daw(std::string("Meshes/")+model+".daw",std::ios::binary);
85 Check(dix.good()&&daw.good(),"open authored visibility cockpit");
86 const int count=Read<short>(dix,0),vc=Read<unsigned short>(daw,0);
87 daw.seekg(0,std::ios::end);const int stride=int((std::streamoff(daw.tellg())-4)/vc);
88 Check(stride==32||stride==40,"visibility mesh stride");
89 std::vector<Matrix> transforms(count);
90 std::vector<Rendering::FixedVertex11> interior;
91 for(int i=0;i<count;++i)
92 {
93 const int o=99+i*100,first=Read<short>(dix,o),n=Read<short>(dix,o+2)*3;
94 Check(first>=0&&n>=0&&first+n<=vc,"visibility mesh bounds");
95 const int type=Read<unsigned char>(dix,o+58);
96 const auto xyz=Read<Vector>(dix,o+4),ypr=Read<Vector>(dix,o+16);
97 DirectX::XMStoreFloat4x4(&transforms[i],DirectX::XMMatrixRotationRollPitchYaw(ypr.y,ypr.x,ypr.z)
98 *DirectX::XMMatrixTranslation(xyz.x,xyz.y,xyz.z)*DirectX::XMMatrixRotationX(DirectX::XM_PIDIV2)
99 *DirectX::XMMatrixRotationY(DirectX::XM_PI));
100 std::vector<WindshieldRain11::Vertex> vertices(n);
101 for(int j=0;j<n;++j)
102 {
103 vertices[j]=Read<WindshieldRain11::Vertex>(daw,2+stride*(first+j));
104 if(type!=5 && type!=51 && type!=251 && Read<short>(dix,o+44)>=0 && Read<short>(dix,o+91)==0)
105 {
106 const auto& p=vertices[j];const auto v=TransformPoint({p.x,p.y,p.z},transforms[i]);
107 Rendering::FixedVertex11 f;f.position={v.x,v.y,v.z,1};interior.push_back(f);
108 }
109 }
110 if(type==5)wet.AddGlass(i,vertices.data(),vertices.size());
111 }
112 wet.FinishGeometry();
113 Check(wet.PaneCount()==8,"P-13's five glass components produce eight panes");
114 FixedFunction11 fixed;HR(fixed.Initialize(gpu.Device(),"x64/Release/WindshieldDamage11Tests/obj/NativeShaders11"),"authored depth shader");
115 ComPtr<ID3D11BlendState> depthOnly;const D3D11_BLEND_DESC blend{};
116 HR(gpu.Device()->CreateBlendState(&blend,&depthOnly),"depth-only blend");
117 auto* context=gpu.Context();
118 D3D11_BUFFER_DESC bd{};bd.ByteWidth=UINT(interior.size()*sizeof(interior[0]));bd.Usage=D3D11_USAGE_IMMUTABLE;bd.BindFlags=D3D11_BIND_VERTEX_BUFFER;
119 const D3D11_SUBRESOURCE_DATA init{interior.data(),0,0};ComPtr<ID3D11Buffer> geometry;
120 HR(gpu.Device()->CreateBuffer(&bd,&init,&geometry),"authored interior");
121 for(UINT samples:{1u,4u})
122 {
123 D3D11_TEXTURE2D_DESC sceneDesc{};color->GetDesc(&sceneDesc);sceneDesc.SampleDesc={samples,0};
124 ComPtr<ID3D11Texture2D> authoredTarget;ComPtr<ID3D11RenderTargetView> authoredView;
125 HR(gpu.Device()->CreateTexture2D(&sceneDesc,nullptr,&authoredTarget),"authored scene target");
126 HR(gpu.Device()->CreateRenderTargetView(authoredTarget.Get(),nullptr,&authoredView),"authored scene view");
127 Rendering::SceneDepth11 authoredDepth;HR(authoredDepth.Create(gpu.Device(),W,H,{samples,0}),"authored depth");
128 for(int pan:{-60,0,60})for(bool mask:{false,true})for(int condition:{95,0})
129 {
130 context->ClearState();
131 const float clear[]={64.f/255,96.f/255,128.f/255,1};
132 context->ClearRenderTargetView(authoredView.Get(),clear);
133 auto* targetView=authoredView.Get();context->OMSetRenderTargets(1,&targetView,authoredDepth.WriteView());
134 context->ClearDepthStencilView(authoredDepth.WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
135 const D3D11_VIEWPORT vp{0,0,float(W),float(H),0,1};context->RSSetViewports(1,&vp);
136 D3D11_RASTERIZER_DESC rs{};rs.FillMode=D3D11_FILL_SOLID;rs.CullMode=D3D11_CULL_BACK;
137 rs.FrontCounterClockwise=TRUE;rs.DepthClipEnable=TRUE; // Production cockpit winding.
138 ComPtr<ID3D11RasterizerState> poseRaster;HR(gpu.Device()->CreateRasterizerState(&rs,&poseRaster),"authored raster");context->RSSetState(poseRaster.Get());
139 Matrix project;DirectX::XMStoreFloat4x4(&project,DirectX::XMMatrixRotationY(DirectX::XMConvertToRadians(float(pan)))
140 *DirectX::XMMatrixRotationZ(DirectX::XM_PI)
141 *DirectX::XMMatrixPerspectiveRH(.000025f*std::tan(DirectX::XMConvertToRadians(115.f)*.5f),
142 .000025f*std::tan(DirectX::XMConvertToRadians(115.f)*.5f)*float(H)/W,.000025f,.16f));
143 if(mask)
144 {
145 D3D11_DEPTH_STENCIL_DESC ds{};ds.DepthEnable=TRUE;ds.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ALL;ds.DepthFunc=D3D11_COMPARISON_LESS;
146 ds.StencilEnable=TRUE;ds.StencilReadMask=ds.StencilWriteMask=255;
147 ds.FrontFace=ds.BackFace={D3D11_STENCIL_OP_KEEP,D3D11_STENCIL_OP_KEEP,D3D11_STENCIL_OP_REPLACE,D3D11_COMPARISON_ALWAYS};
148 ComPtr<ID3D11DepthStencilState> state;HR(gpu.Device()->CreateDepthStencilState(&ds,&state),"authored stencil");
149 context->OMSetDepthStencilState(state.Get(),4);context->OMSetBlendState(depthOnly.Get(),nullptr,UINT_MAX);
150 Rendering::FixedState11 f;f.lighting=false;f.projection=project;
151 HR(fixed.Bind(context,f),"authored interior shader");auto* vb=geometry.Get();const UINT bytes=sizeof(Rendering::FixedVertex11),offset=0;
152 context->IASetVertexBuffers(0,1,&vb,&bytes,&offset);context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);context->Draw(UINT(interior.size()),0);
153 }
154 wet.SetGlassCondition(condition);
155 const HRESULT result=wet.Render(context,authoredView.Get(),authoredDepth.ReadView(),vp,transforms,project,1,WindshieldRain11::DepthLayout::CockpitAndWorld);
156 HR(result,"authored water draw");context->OMSetRenderTargets(0,nullptr,nullptr);
157 if(samples>1)context->ResolveSubresource(color.Get(),0,authoredTarget.Get(),0,sceneDesc.Format);
158 else context->CopyResource(color.Get(),authoredTarget.Get());
159 context->CopyResource(readback.Get(),color.Get());
160 D3D11_MAPPED_SUBRESOURCE mapped{};HR(context->Map(readback.Get(),0,D3D11_MAP_READ,0,&mapped),"authored pixels");
161 std::vector<uint32_t> pixels(W*H);unsigned changed=0;
162 for(UINT y=0;y<H;++y)for(UINT x=0;x<W;++x)
163 {pixels[y*W+x]=reinterpret_cast<const uint32_t*>(static_cast<const char*>(mapped.pData)+y*mapped.RowPitch)[x];changed+=(pixels[y*W+x]&0xffffff)!=0x806040;}
164 context->Unmap(readback.Get(),0);
165 Check(result==S_OK && changed>(condition==0 ? 100u : 0u),"damage is visible on authored P-13 front and side glass");
166 std::cout<<"PASS: "<<model<<" samples="<<samples<<" pan="<<pan<<" interior="<<mask<<" condition="<<condition<<" fracture pixels="<<changed<<std::endl;
167 Save((std::string(model)+"-msaa"+std::to_string(samples)+"-pan"+std::to_string(pan)+"-"+std::to_string(mask)+"-hp"+std::to_string(condition)).c_str(),pixels);
168 }
169 }
170 }
171
172 void Multisample()
173 {
174 auto* c=gpu.Context();c->ClearState();
175 D3D11_TEXTURE2D_DESC d{};color->GetDesc(&d);d.SampleDesc={4,0};
176 ComPtr<ID3D11Texture2D> multi,mask,maskRead,maskResolved;
177 ComPtr<ID3D11RenderTargetView> multiView,maskView;
178 HR(gpu.Device()->CreateTexture2D(&d,nullptr,&multi));
179 HR(gpu.Device()->CreateRenderTargetView(multi.Get(),nullptr,&multiView));
180 d.Format=DXGI_FORMAT_R8_UNORM;HR(gpu.Device()->CreateTexture2D(&d,nullptr,&mask));
181 HR(gpu.Device()->CreateRenderTargetView(mask.Get(),nullptr,&maskView));
182 d.SampleDesc={1,0};HR(gpu.Device()->CreateTexture2D(&d,nullptr,&maskResolved));
183 d.Usage=D3D11_USAGE_STAGING;d.BindFlags=0;d.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
184 HR(gpu.Device()->CreateTexture2D(&d,nullptr,&maskRead));
185 SceneDepth11 multiDepth;HR(multiDepth.Create(gpu.Device(),W,H,{4,0}));
186 const float gray[4]={.5f,.5f,.5f,1},zero[4]={};
187 auto* rt=multiView.Get();c->OMSetRenderTargets(1,&rt,multiDepth.WriteView());
188 c->RSSetState(raster.Get());c->RSSetViewports(1,&viewport);
189 c->ClearRenderTargetView(rt,gray);c->ClearRenderTargetView(maskView.Get(),zero);
190 c->ClearDepthStencilView(multiDepth.WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
191 rain.SetGlassCondition(0);
192 HR(rain.Render(c,rt,multiDepth.ReadView(),viewport,{identity},projection,1,
193 WindshieldRain11::DepthLayout::CockpitAndWorld,1,maskView.Get()));
194 ComPtr<ID3D11RenderTargetView> restored;c->OMGetRenderTargets(1,&restored,nullptr);
195 Check(restored==multiView,"caller render target restored");
196 c->OMSetRenderTargets(0,nullptr,nullptr);
197 c->ResolveSubresource(maskResolved.Get(),0,mask.Get(),0,DXGI_FORMAT_R8_UNORM);
198 c->CopyResource(maskRead.Get(),maskResolved.Get());D3D11_MAPPED_SUBRESOURCE map{};
199 HR(c->Map(maskRead.Get(),0,D3D11_MAP_READ,0,&map));size_t excluded=0;
200 for(UINT y=0;y<H;++y)for(UINT x=0;x<W;++x)excluded+=static_cast<const unsigned char*>(map.pData)[y*map.RowPitch+x]>0;
201 c->Unmap(maskRead.Get(),0);
202 Check(excluded>1000 && excluded<W*H/2,"4x MSAA excludes only refracted advertising samples");
203 ComPtr<ID3D11InfoQueue> queue;HR(gpu.Device()->QueryInterface(IID_PPV_ARGS(&queue)));
204 for(UINT64 i=0;i<queue->GetNumStoredMessages();++i)
205 {
206 SIZE_T size=0;queue->GetMessage(i,nullptr,&size);std::vector<char> data(size);
207 auto* m=reinterpret_cast<D3D11_MESSAGE*>(data.data());HR(queue->GetMessage(i,m,&size));
208 if(m->Severity<=D3D11_MESSAGE_SEVERITY_WARNING)throw std::runtime_error(m->pDescription);
209 }
210 queue->ClearStoredMessages();
211 std::cout<<"PASS: 4x MSAA, read-only depth, advertising exclusion and caller-state restoration\n";
212 }
213
214 std::vector<uint32_t> Render(int condition,float lamp,const std::vector<uint32_t>& background,
215 float opacity=1,float z=1,bool cockpitDepth=false)
216 {
217 auto* c=gpu.Context();c->ClearState();c->UpdateSubresource(color.Get(),0,nullptr,background.data(),W*4,0);
218 auto* rt=target.Get();c->OMSetRenderTargets(1,&rt,depth.WriteView());c->RSSetState(raster.Get());c->RSSetViewports(1,&viewport);
219 c->ClearDepthStencilView(depth.WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,z,cockpitDepth ? 3 : 0);
220 rain.SetGlassCondition(condition);
221 HR(rain.Render(c,target.Get(),depth.WriteView(),viewport,{identity},projection,opacity,
222 cockpitDepth ? WindshieldRain11::DepthLayout::CockpitAndWorld : WindshieldRain11::DepthLayout::Unified,lamp));
223 c->CopyResource(readback.Get(),color.Get());D3D11_MAPPED_SUBRESOURCE map{};
224 HR(c->Map(readback.Get(),0,D3D11_MAP_READ,0,&map));std::vector<uint32_t> result(W*H);
225 for(UINT y=0;y<H;++y)memcpy(result.data()+y*W,static_cast<const char*>(map.pData)+y*map.RowPitch,W*4);
226 c->Unmap(readback.Get(),0);
227 ComPtr<ID3D11InfoQueue> queue;HR(gpu.Device()->QueryInterface(IID_PPV_ARGS(&queue)));
228 for(UINT64 i=0;i<queue->GetNumStoredMessages();++i)
229 {
230 SIZE_T size=0;queue->GetMessage(i,nullptr,&size);std::vector<char> data(size);
231 auto* m=reinterpret_cast<D3D11_MESSAGE*>(data.data());HR(queue->GetMessage(i,m,&size));
232 if(m->Severity<=D3D11_MESSAGE_SEVERITY_WARNING)throw std::runtime_error(m->pDescription);
233 }
234 queue->ClearStoredMessages();return result;
235 }
236};
237size_t Changed(const std::vector<uint32_t>& a,const std::vector<uint32_t>& b)
238{size_t n=0;for(size_t i=0;i<a.size();++i)n+=(a[i]&0xffffff)!=(b[i]&0xffffff);return n;}
239void Save(const char* name,const std::vector<uint32_t>& pixels)
240{
241 std::filesystem::create_directories("outputs/windshield-optics");
242 std::ofstream f(std::string("outputs/windshield-optics/")+name+".ppm",std::ios::binary);
243 f<<"P6\n"<<W<<" "<<H<<"\n255\n";
244 for(auto pixel:pixels){const char rgb[]={char(pixel),char(pixel>>8),char(pixel>>16)};f.write(rgb,3);}
245}
246}
247int main()
248{
249 try
250 {
251 Graph();Fixture f;
252 const std::vector<uint32_t> black(W*H,0xff000000),gray(W*H,0xff808080);
253 const auto dark=f.Render(0,0,black),cabin=f.Render(0,1,black);
254 Check(Changed(black,dark)==0,"no self-illumination in darkness");
255 unsigned peak=0;for(auto p:cabin)peak=(std::max)(peak,(p&255));
256 Check(peak>=20 && peak<=64,"visible dome-lit edges without white outlines");
257 const auto halfCabin=f.Render(0,.5f,black);
258 size_t readableNight=0;int lampPowerDelta=0;
259 for(size_t i=0;i<cabin.size();++i)
260 {
261 readableNight+=(cabin[i]&255)>=8;
262 for(unsigned shift:{0u,8u,16u})
263 lampPowerDelta=(std::max)(lampPowerDelta,
264 std::abs(int((halfCabin[i]>>shift)&255)*2-int((cabin[i]>>shift)&255)));
265 }
266 // Allow color/coverage quantization in the UNORM blend path.
267 std::cout<<"Lamp power maximum quantization delta="<<lampPowerDelta<<"/255\n";
268 Check(lampPowerDelta<=2,"dome reflection follows electrical power without a brightness floor");
269 Check(readableNight>W*H/40,"dome light reveals the fracture network, not only isolated glints");
270 const std::vector<uint32_t> night(W*H,0xff0b0e0d);
271 const auto nightOff=f.Render(0,0,night),nightOn=f.Render(0,1,night);
272 size_t nightLift=0;
273 for(size_t i=0;i<night.size();++i)nightLift+=int(nightOn[i]&255)-int(nightOff[i]&255)>=8;
274 Check(nightLift>W*H/40,"dome light adds readable contrast against a dark exterior");
275 const auto day=f.Render(0,0,gray);
276 size_t dayShadow=0,dayHighlight=0;
277 for(auto p:day){dayShadow+=(p&255)<=112;dayHighlight+=(p&255)>=144;}
278 Check(dayShadow>W*H/100 && dayHighlight>100,"daylight fractures retain visible dark and bright optical edges");
279 Save("night-lamp-off",nightOff);Save("night-lamp-on",nightOn);Save("day-gray",day);
280 std::cout<<"PASS: readable dome-lit pixels="<<readableNight<<", night contrast="<<nightLift
281 <<", daylight shadows/highlights="<<dayShadow<<'/'<<dayHighlight<<"; proportional lamp power\n";
282 auto healthy=f.Render(127,1,gray);Check(healthy==gray,"healthy glass untouched");
283 auto first=f.Render(95,1,gray),full=f.Render(0,1,gray);
284 Check(Changed(gray,full)>Changed(gray,first)*8,"damage adds widespread coverage");
285 Check(full==f.Render(0,1,gray),"repeat-frame stability");
286 f.rain.ResetDevice();HR(f.rain.Initialize(f.gpu.Device(),"x64/Release/WindshieldDamage11Tests/obj/NativeShaders11"));
287 Check(full==f.Render(0,1,gray),"device reset rebuilds identical fractures");
288 Check(full==f.Render(0,1,gray,0),"damage persists above rain altitude");
289 Check(f.Render(96,1,gray)==gray && WindshieldRain11TestAccess::Released(f.rain),"repair releases damage and restores view");
290 Check(f.Render(0,1,gray,1,.01f,true)==gray,"cockpit occludes damage");
291 Check(f.Render(0,1,gray,1,.01f)==gray,"unified depth occludes damage");
292 std::vector<uint32_t> stripes(W*H);
293 for(UINT y=0;y<H;++y)for(UINT x=0;x<W;++x)
294 stripes[y*W+x]=0xff000000|((x/9)%2 ? 0x102040 : 0xd0b080);
295 auto view=f.Render(0,0,stripes);Check(Changed(view,stripes)>1000,"scene-dependent refraction");
296 bool mixes=false;
297 for(auto p:view)if((p&255)>65 && (p&255)<127){mixes=true;break;}
298 Check(mixes,"crack edges sample neighboring scene colors");
299 Save("night-cabin",cabin);Save("daylight",view);Save("condition-95",first);Save("condition-0",full);
300 size_t previous=0;
301 for(int hp=95;hp>=0;--hp)
302 {
303 const auto pixels=f.Render(hp,1,gray);const auto count=Changed(pixels,gray);
304 Check(count+8>=previous,"visible crack coverage does not regress as condition falls");
305 previous=count;
306 }
307 f.rain.SetSimulator(true);Check(f.Render(0,1,stripes)==stripes,"simulator suppresses optical damage");
308 Check(WindshieldRain11TestAccess::Released(f.rain) && WindshieldRain11TestAccess::Healthy(f.rain),"simulator discards new optical damage state");
309 f.rain.SetSimulator(false);Check(f.Render(127,1,stripes)==stripes,"simulator exit has no stale damage");
310 auto& water=WindshieldRain11TestAccess::Water(f.rain);
311 water.Impact({1,.5f},.02f,false);water.Rebuild();
312 const auto wet=f.Render(127,1,stripes),both=f.Render(0,1,stripes);
313 Check(Changed(wet,stripes)>0 && Changed(wet,both)>1000,"rain and damage composite together");
314 Check(f.Render(127,1,stripes)==wet,"repair retains rain exactly");
315 f.AuthoredDamage("p13-cockpit1");
316 f.Multisample();
317 std::cout<<"PASS: WARP/debug layer, 96 conditions, dark cabin peak="<<peak
318 <<"/255, refraction, depth, repair, simulator, altitude and rain coexistence\n";
319 return 0;
320 }
321 catch(const std::exception& e){std::cerr<<"FAIL: "<<e.what()<<'\n';return 1;}
322}
SCRIPT_CONTROL SCRIPT_STATE const void int
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
ID3D11DeviceContext * Context() const
Definition Device11.h:66
ID3D11Device * Device() const
Definition Device11.h:65
HRESULT Create(const DeviceOptions11 &options={})
Definition Device11.cpp:84
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
HRESULT Bind(ID3D11DeviceContext *context, const FixedState11 &state, bool pointList=false)
HRESULT Create(ID3D11Device *device, UINT width, UINT height, DXGI_SAMPLE_DESC samples)
Definition Device11.cpp:20
ID3D11DepthStencilView * ReadView() const
Definition Device11.h:19
ID3D11DepthStencilView * WriteView() const
Definition Device11.h:18
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
HRESULT Render(ID3D11DeviceContext *context, ID3D11RenderTargetView *target, ID3D11DepthStencilView *depth, const D3D11_VIEWPORT &viewport, const std::vector< Matrix > &world, const Matrix &viewProjection, float opacity=1, DepthLayout depthLayout=DepthLayout::Unified, float cockpitLight=0, ID3D11RenderTargetView *adExclusion=nullptr)
void SetGlassCondition(int condition)
void AddGlass(int component, const Vertex *vertices, size_t count)
HRESULT Render(RiseDialog &hud, float elapsedTime, int dialogId, Logger &logger)
Vector TransformPoint(const Vector &a, const Matrix &matrix)
Definition Math11.h:25
DirectX::XMFLOAT4X4 Matrix
Definition Math11.h:9
float SegmentDistanceSquared(Point p, Segment line)
std::vector< Segment > Network(float width, float height, uint32_t seed)
type
Definition erin.py:143
DirectX::XMFLOAT4X4 projection