Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/CloudFlightPerformance11Tests.h

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

1// Reproducible in-cloud flight workloads. These are synthetic scenes, not a
2// reconstruction of Bill's uncaptured camera, depth buffer or weather maps.
3void TestCloudFlightPerformance(Device11& gpu,CloudRenderer11& after,CloudRenderer11& before,
4 UINT samples,const std::filesystem::path& output)
5{
6 Check(!output.empty(),"flight comparison requires --fog-output");
7 Check(samples==2 || samples==4,"flight comparison supports 2x/4x original samples");
8 char option[256]{};
9 const bool full=GetEnvironmentVariableA("RISE_FLIGHT_FULL",option,sizeof(option))!=0;
10 const bool detailed=GetEnvironmentVariableA("RISE_FLIGHT_SAMPLE_COVERAGE",option,sizeof(option))!=0;
11 const UINT width=full ? 3840u : detailed ? 641u : 640u,height=full ? 2035u : detailed ? 363u : 360u;
12 const unsigned batches=GetEnvironmentVariableA("RISE_FLIGHT_BATCHES",option,sizeof(option)) ? unsigned(std::stoul(option)) : 4u;
13 const std::string selected=GetEnvironmentVariableA("RISE_FLIGHT_CASES",option,sizeof(option)) ? option : "";
14 const float cockpitFraction=GetEnvironmentVariableA("RISE_FLIGHT_COCKPIT",option,sizeof(option)) ? std::stof(option) : .22f;
15 std::vector<float> altitudes{6.369629f,9.290283f,10.f,12.5f,15.f};
16 if(GetEnvironmentVariableA("RISE_FLIGHT_ALTITUDES",option,sizeof(option)))
17 {
18 altitudes.clear();std::string values=option;size_t position=0;
19 while(position<values.size())
20 {
21 const auto end=values.find(',',position);
22 altitudes.push_back(std::stof(values.substr(position,end-position)));
23 if(end==std::string::npos)break;position=end+1;
24 }
25 Check(!altitudes.empty() && altitudes.size()<=32,"bounded flight altitude matrix");
26 for(float altitude:altitudes)Check(std::isfinite(altitude) && altitude>=0 && altitude<=100,"flight test altitude range");
27 }
28 const bool headlights=GetEnvironmentVariableA("RISE_FLIGHT_HEADLIGHTS",option,sizeof(option))!=0;
29 const bool flashes=GetEnvironmentVariableA("RISE_FLIGHT_LIGHTNING",option,sizeof(option))!=0;
30 const bool comparePrimary=GetEnvironmentVariableA("RISE_FLIGHT_COMPARE_PRIMARY",option,sizeof(option))!=0;
31 const bool keepHistory=GetEnvironmentVariableA("RISE_FLIGHT_KEEP_HISTORY",option,sizeof(option))!=0;
32 const bool requireHistory=GetEnvironmentVariableA("RISE_FLIGHT_REQUIRE_HISTORY",option,sizeof(option))!=0;
33 const bool expectHistoryReset=GetEnvironmentVariableA("RISE_FLIGHT_EXPECT_HISTORY_RESET",option,sizeof(option))!=0;
34 const bool maskAll=GetEnvironmentVariableA("RISE_FLIGHT_ALL_MASKED",option,sizeof(option))!=0;
35 const bool fractional=GetEnvironmentVariableA("RISE_FLIGHT_FRACTIONAL",option,sizeof(option))!=0;
36 const bool shaderOffset=GetEnvironmentVariableA("RISE_FLIGHT_SHADER_OFFSET",option,sizeof(option))!=0;
37 std::vector<unsigned> geometries{0,1,2};
38 if(GetEnvironmentVariableA("RISE_FLIGHT_TRANSITIONS",option,sizeof(option)))geometries={0,2,0,2,1,0};
39 if(GetEnvironmentVariableA("RISE_FLIGHT_HIDDEN_OFF",option,sizeof(option)))
40 after.Pass().SetHiddenRayOptimizationEnabled(false);
41 Check(batches>=1 && batches<=100,"bounded flight timing batches");
42 Check(std::isfinite(cockpitFraction) && cockpitFraction>=0 && cockpitFraction<=.9f,"bounded cockpit coverage");
43 std::filesystem::create_directories(output);
44 std::ofstream csv(output/"comparison.csv");
45 csv<<"case,altitude_km,geometry,light,fog,msaa,width,height,before_ms,after_ms,color_samples_changed,depth_samples_changed,max_color_error\n";
46 constexpr char comparisonSource[]=R"(
47Texture2DMS<float4,SAMPLES> beforeColor : register(t0);
48Texture2DMS<float4,SAMPLES> afterColor : register(t1);
49Texture2DMS<float,SAMPLES> beforeDepth : register(t2);
50Texture2DMS<float,SAMPLES> afterDepth : register(t3);
51RWStructuredBuffer<uint4> differences : register(u0);
52[numthreads(16,16,1)] void Compare(uint3 id:SV_DispatchThreadID)
53{
54 uint width,height,count;beforeColor.GetDimensions(width,height,count);
55 if(id.x>=width || id.y>=height)return;
56 [unroll] for(uint sample=0;sample<SAMPLES;++sample)
57 {
58 float4 a=beforeColor.Load(id.xy,sample),b=afterColor.Load(id.xy,sample);
59 if(any(a!=b))
60 {
61 InterlockedAdd(differences[0].x,1);
62 float4 delta=abs(a-b);
63 InterlockedMax(differences[0].z,asuint(max(max(delta.x,delta.y),max(delta.z,delta.w))));
64 }
65 if(beforeDepth.Load(id.xy,sample)!=afterDepth.Load(id.xy,sample))InterlockedAdd(differences[0].y,1);
66 }
67})";
68 const auto count=std::to_string(samples);
69 const D3D_SHADER_MACRO macros[]={{"SAMPLES",count.c_str()},{nullptr,nullptr}};
70 ComPtr<ID3DBlob> code,errors;ComPtr<ID3D11ComputeShader> compare;
71 HR(D3DCompile(comparisonSource,strlen(comparisonSource),"CloudFlightComparison",macros,nullptr,"Compare","cs_5_0",
72 D3DCOMPILE_ENABLE_STRICTNESS|D3DCOMPILE_OPTIMIZATION_LEVEL3,0,&code,&errors),"flight comparison shader");
73 HR(gpu.Device()->CreateComputeShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&compare),"flight comparison CS");
74 ComPtr<ID3D11ComputeShader> primaryCompare;
75 if(comparePrimary)
76 {
77 constexpr char primarySource[]=R"(
78Texture2D<float4> beforeColor:register(t0),afterColor:register(t1);
79Texture2D<float2> beforeDistance:register(t2),afterDistance:register(t3);
80RWStructuredBuffer<uint4> differences:register(u0);
81[numthreads(16,16,1)] void ComparePrimary(uint3 at:SV_DispatchThreadID)
82{
83 uint w,h;beforeColor.GetDimensions(w,h);if(at.x>=w || at.y>=h)return;
84 int3 p=int3(at.xy,0);
85 if(any(beforeColor.Load(p)!=afterColor.Load(p)))InterlockedAdd(differences[0].x,1);
86 if(any(beforeDistance.Load(p)!=afterDistance.Load(p)))InterlockedAdd(differences[0].y,1);
87})";
88 code.Reset();errors.Reset();
89 HR(D3DCompile(primarySource,strlen(primarySource),"CloudPrimaryComparison",nullptr,nullptr,"ComparePrimary","cs_5_0",
90 D3DCOMPILE_ENABLE_STRICTNESS|D3DCOMPILE_OPTIMIZATION_LEVEL3,0,&code,&errors),"primary comparison shader");
91 HR(gpu.Device()->CreateComputeShader(code->GetBufferPointer(),code->GetBufferSize(),nullptr,&primaryCompare),"primary comparison CS");
92 }
93 D3D11_BUFFER_DESC buffer{};buffer.ByteWidth=16;buffer.BindFlags=D3D11_BIND_UNORDERED_ACCESS;
94 buffer.MiscFlags=D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;buffer.StructureByteStride=16;
95 ComPtr<ID3D11Buffer> counters,readback;ComPtr<ID3D11UnorderedAccessView> counterView;
96 HR(gpu.Device()->CreateBuffer(&buffer,nullptr,&counters),"flight comparison counters");
97 D3D11_UNORDERED_ACCESS_VIEW_DESC uav{};uav.ViewDimension=D3D11_UAV_DIMENSION_BUFFER;uav.Buffer.NumElements=1;
98 HR(gpu.Device()->CreateUnorderedAccessView(counters.Get(),&uav,&counterView),"flight counter view");
99 buffer.BindFlags=buffer.MiscFlags=buffer.StructureByteStride=0;buffer.Usage=D3D11_USAGE_STAGING;buffer.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
100 HR(gpu.Device()->CreateBuffer(&buffer,nullptr,&readback),"flight counter readback");
101 auto* context=gpu.Context();
102 const auto compareScenes=[&](Scene& a,Scene& b,UINT w,UINT h)
103 {
104 context->ClearState();const UINT zero[4]{};context->ClearUnorderedAccessViewUint(counterView.Get(),zero);
105 ID3D11ShaderResourceView* resources[]={a.view.Get(),b.view.Get(),a.depth.ShaderView(),b.depth.ShaderView()};
106 auto* target=counterView.Get();context->CSSetShader(compare.Get(),nullptr,0);context->CSSetShaderResources(0,4,resources);
107 context->CSSetUnorderedAccessViews(0,1,&target,nullptr);context->Dispatch((w+15)/16,(h+15)/16,1);context->ClearState();
108 context->CopyResource(readback.Get(),counters.Get());D3D11_MAPPED_SUBRESOURCE mapped{};
109 HR(context->Map(readback.Get(),0,D3D11_MAP_READ,0,&mapped),"flight comparison readback");
110 std::array<UINT,4> values{};memcpy(values.data(),mapped.pData,16);context->Unmap(readback.Get(),0);return values;
111 };
112 {
113 Scene a(gpu.Device(),samples,1,1),b(gpu.Device(),samples,1,1);a.Clear(context);b.Clear(context);
114 const float pink[]={1,0,1,1};context->ClearRenderTargetView(b.target.Get(),pink);
115 context->ClearDepthStencilView(b.depth.WriteView(),D3D11_CLEAR_DEPTH,.5f,0);
116 auto delta=compareScenes(a,b,1,1);Check(delta[0]==samples && delta[1]==samples,"flight comparator detects intentional errors");
117 b.Clear(context);delta=compareScenes(a,b,1,1);Check(delta[0]==0 && delta[1]==0,"flight comparator equal control");
118 }
119 Scene a(gpu.Device(),samples,width,height),b(gpu.Device(),samples,width,height);
120 RainMsaaFixture fixture(gpu.Device(),samples);const D3D11_VIEWPORT viewport{
121 detailed ? 3.f : 0,detailed ? 5.f : 0,float(width)-(detailed ? 3.f : 0),float(height)-(detailed ? 5.f : 0),0,1};
122 Program11 destinationProgram;Parameters11 destinationValues;
123 ComPtr<ID3D11DepthStencilState> destinationState;
124 if(detailed)
125 {
126 constexpr char destinationSource[]="float4 destinationColor; float4 Color():SV_Target{return destinationColor;}";
127 ComPtr<ID3DBlob> pixelCode;auto vertexCode=Compile("Fullscreen","vs_5_0",samples);
128 HR(D3DCompile(destinationSource,strlen(destinationSource),"OriginalSampleDestination",nullptr,nullptr,"Color","ps_5_0",
129 D3DCOMPILE_ENABLE_STRICTNESS|D3DCOMPILE_OPTIMIZATION_LEVEL3,0,&pixelCode,nullptr),"destination sample shader");
130 HR(destinationProgram.Create(gpu.Device(),vertexCode->GetBufferPointer(),vertexCode->GetBufferSize(),pixelCode->GetBufferPointer(),pixelCode->GetBufferSize()),"destination sample program");
131 D3D11_DEPTH_STENCIL_DESC stencil{};stencil.DepthEnable=FALSE;stencil.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ZERO;
132 stencil.StencilEnable=TRUE;stencil.StencilReadMask=stencil.StencilWriteMask=255;
133 stencil.FrontFace={D3D11_STENCIL_OP_REPLACE,D3D11_STENCIL_OP_REPLACE,D3D11_STENCIL_OP_REPLACE,D3D11_COMPARISON_ALWAYS};
134 stencil.BackFace=stencil.FrontFace;HR(gpu.Device()->CreateDepthStencilState(&stencil,&destinationState),"destination sample stencil");
135 }
136 XMFLOAT4X4 view,projection;XMStoreFloat4x4(&view,XMMatrixIdentity());
137 XMStoreFloat4x4(&projection,XMMatrixPerspectiveFovRH(1.f,float(width)/height,.001f,384));
138 ComPtr<ID3D11Query> disjoint,begin,end;D3D11_QUERY_DESC desc{D3D11_QUERY_TIMESTAMP_DISJOINT,0};
139 HR(gpu.Device()->CreateQuery(&desc,&disjoint),"flight disjoint");desc.Query=D3D11_QUERY_TIMESTAMP;
140 HR(gpu.Device()->CreateQuery(&desc,&begin),"flight begin");HR(gpu.Device()->CreateQuery(&desc,&end),"flight end");
141 unsigned scenario=0,executed=0;unsigned long long colorDifferences=0,depthDifferences=0;
142 std::array<unsigned,2> historyFrames{},historyReused{},historyReset{},historyPhases{};
143 unsigned viewportIteration[2]{};
144 for(float altitude:altitudes)
145 for(unsigned geometry:geometries)for(unsigned light=0;light<3;++light)for(unsigned fog=0;fog<2;++fog,++scenario)
146 {
147 if(!selected.empty() && (","+selected+",").find(","+std::to_string(scenario)+",")==std::string::npos)continue;
148 ++executed;CloudVolume::Parameters cloud;cloud.organic=true;cloud.weather=after.WeatherFrame();
149 cloud.base=6.098395f;cloud.top=11.314094f;
150 for(auto* renderer:{&before,&after}){renderer->SetRainGrid(nullptr);renderer->SetLightningEnabled(false);renderer->SetHeadlights({});if(!keepHistory)renderer->ResetCloudHistory();}
151 if(headlights)
152 {
153 CloudRenderer11::Headlight lamp;lamp.position={0,cloud.radius+altitude,0};
154 lamp.direction={0,0,-1};lamp.up={0,1,0};lamp.color={1,1,1,1};
155 lamp.rangeKm=lamp.profile.rangeKm=2;lamp.extinctionPerKm=3.912f/20;
156 for(auto* renderer:{&before,&after})renderer->SetHeadlights({lamp});
157 }
158 if(flashes)for(auto* renderer:{&before,&after})
159 {
160 renderer->SetLightningEnabled(true);
161 renderer->SetLocalLightning({0,cloud.radius+altitude,-1},{1,.7f,.5f,1},3,{0,cloud.radius,-1});
162 }
163 const auto draw=[&](CloudRenderer11& renderer,Scene& scene)
164 {
165 D3D11_VIEWPORT activeViewport=viewport;
166 if(fractional && (viewportIteration[&renderer==&after ? 1 : 0]++&1))
167 activeViewport={3.6f,5.6f,float(width)-4.2f,float(height)-6.2f,0,1};
168 if(geometry==0){context->ClearState();scene.Clear(context);}
169 else fixture.Draw(gpu,scene,activeViewport,geometry==1 ? XMFLOAT4(.9997f,.00024f,0,0)
170 : XMFLOAT4(.3f,8.f,-projection._33,projection._43),geometry==1);
171 if(detailed)
172 {
173 // Distinct original destination RGBA and opposing per-sample
174 // cockpit masks. Both sample0-masked and sample0-visible cases
175 // occur at equal depths as well as mixed geometry/sky edges.
176 auto* destination=scene.target.Get();context->OMSetRenderTargets(1,&destination,scene.depth.WriteView());
177 context->RSSetState(fixture.pipeline.raster.Get());context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
178 for(UINT s=0;s<samples;++s)for(UINT band=0;band<4;++band)
179 {
180 const D3D11_VIEWPORT stripe{float(width)*band/4,0,float(width)/4,float(height),0,1};
181 context->RSSetViewports(1,&stripe);context->OMSetBlendState(nullptr,nullptr,1u<<s);
182 context->OMSetDepthStencilState(destinationState.Get(),maskAll || (band<2 && (s+band)%2==0) ? 3 : 0);
183 destinationValues.Set("destinationColor",XMFLOAT4(.1f+.15f*s,.2f+.1f*band,.7f-.1f*s,.2f+.15f*s));
184 HR(destinationProgram.Bind(context,destinationValues),"destination sample bind");context->Draw(3,0);
185 }
186 context->OMSetBlendState(nullptr,nullptr,UINT_MAX);
187 }
188 // Original per-sample cockpit stencil must survive every candidate.
189 auto* target=scene.target.Get();context->OMSetRenderTargets(1,&target,scene.depth.WriteView());
190 const D3D11_VIEWPORT cockpit{0,float(height)*(1-cockpitFraction),float(width),float(height)*cockpitFraction,0,1};context->RSSetViewports(1,&cockpit);
191 context->RSSetState(fixture.pipeline.raster.Get());context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
192 context->VSSetShader(fixture.pipeline.full.Get(),nullptr,0);context->PSSetShader(fixture.pipeline.blue.Get(),nullptr,0);
193 context->OMSetDepthStencilState(fixture.pipeline.stencil.Get(),3);if(cockpitFraction>0)context->Draw(3,0);context->OMSetRenderTargets(0,nullptr,nullptr);
194 const XMFLOAT4 nvg=light==2 ? XMFLOAT4(1.8f,2.3f,1.5f,1) : XMFLOAT4(1,1,1,0);
195 if(detailed)
196 {
197 context->OMSetBlendState(nullptr,nullptr,0x55555555u);
198 auto* callerSource=scene.view.Get();auto* callerTarget=counterView.Get();
199 context->CSSetShader(compare.Get(),nullptr,0);context->CSSetShaderResources(5,1,&callerSource);
200 context->CSSetUnorderedAccessViews(3,1,&callerTarget,nullptr);
201 }
202 auto& profiler=FrameProfiler11::Get();
203 profiler.BeginFrame(gpu.Device(),context,width,height,samples,false,0);
204 profiler.Scene(&renderer==&after ? 1 : 0,altitude,false,false,0,0);profiler.BeginGpu();
205 HR(renderer.Render(context,scene.target.Get(),scene.depth,activeViewport,view,projection,{0,cloud.radius+altitude,0},cloud,
206 light==0 ? XMFLOAT3(0,-1,0) : XMFLOAT3(0,1,0),light==0 ? XMFLOAT4(1,1,1,1) : XMFLOAT4(0,0,0,0),
207 {.15f,.16f,.18f,1},{.125f,.375f,.25f,1},{.02f,.01f,.02f,fog ? 42.16f : 0}, {},nvg),"flight comparison draw");
208 profiler.EndFrame();
209 if(requireHistory && !renderer.Parameters().ZeroOrUnset("_testTemporalActive"))
210 {
211 const unsigned index=&renderer==&after ? 1u : 0u;++historyFrames[index];
212 if(!renderer.Parameters().ZeroOrUnset("_testTemporalHistory"))
213 {
214 ++historyReused[index];
215 for(unsigned phase=0;phase<4;++phase)
216 if(!renderer.Parameters().ZeroOrUnset("_testTemporalPhase"+std::to_string(phase)))historyPhases[index]|=1u<<phase;
217 }
218 else ++historyReset[index];
219 }
220 if(shaderOffset)
221 {
222 // The first draw populated the cache with zero raster offset.
223 // Reuse it with a shifted fullscreen triangle and fresh scene
224 // samples; missed classifier centers must take the fallback.
225 if(geometry==0){context->ClearState();scene.Clear(context);}
226 else fixture.Draw(gpu,scene,activeViewport,geometry==1 ? XMFLOAT4(.9997f,.00024f,0,0)
227 : XMFLOAT4(.3f,8.f,-projection._33,projection._43),geometry==1);
228 Parameters11 shifted=renderer.Parameters();
229 Check(shifted.ZeroOrUnset("_risePixelCenterOffset"),"renderer uses default native pixel centers");
230 shifted.Set("_risePixelCenterOffset",XMFLOAT2(1.2f/activeViewport.Width,-1.2f/activeViewport.Height));
231 Check(!shifted.ZeroOrUnset("_risePixelCenterOffset"),"shifted pass requires guarded cache coverage");
232 context->OMSetRenderTargets(0,nullptr,nullptr);
233 if(detailed)
234 {
235 context->OMSetBlendState(nullptr,nullptr,0x55555555u);
236 auto* callerSource=scene.view.Get();auto* callerTarget=counterView.Get();
237 context->CSSetShader(compare.Get(),nullptr,0);context->CSSetShaderResources(5,1,&callerSource);
238 context->CSSetUnorderedAccessViews(3,1,&callerTarget,nullptr);
239 }
240 HR(renderer.Pass().Render(context,shifted,scene.target.Get(),scene.depth,activeViewport,0,fog!=0),"shifted cloud pass");
241 }
242 if(detailed)
243 {
244 UINT restoredMask=0;context->OMGetBlendState(nullptr,nullptr,&restoredMask);
245 Check(restoredMask==0x55555555u,"cloud pass restores caller sample mask");
246 ComPtr<ID3D11ComputeShader> restoredShader;ComPtr<ID3D11ShaderResourceView> restoredSource;
247 ComPtr<ID3D11UnorderedAccessView> restoredTarget;
248 context->CSGetShader(&restoredShader,nullptr,nullptr);context->CSGetShaderResources(5,1,&restoredSource);
249 context->CSGetUnorderedAccessViews(3,1,&restoredTarget);
250 Check(restoredShader.Get()==compare.Get() && restoredSource.Get()==scene.view.Get()
251 && restoredTarget.Get()==counterView.Get(),"cloud pass restores caller compute shader/resources");
252 }
253 };
254 if(requireHistory && executed==1)
255 {
256 // Remove first-use driver delays before testing the 350ms history
257 // compatibility limit; both renderers then start at the same phase.
258 draw(before,a);draw(after,b);(void)compareScenes(a,b,width,height);
259 before.ResetCloudHistory();after.ResetCloudHistory();
260 historyFrames={};historyReused={};historyReset={};historyPhases={};
261 }
262 double total[2]{};
263 for(unsigned repeat=0;repeat<batches;++repeat)for(unsigned order=0;order<2;++order)
264 {
265 const unsigned changed=order^(repeat&1);auto& renderer=changed ? after : before;auto& scene=changed ? b : a;
266 draw(renderer,scene); // Warm the exact state outside the measurement.
267 context->Begin(disjoint.Get());context->End(begin.Get());draw(renderer,scene);context->End(end.Get());context->End(disjoint.Get());
268 const auto read=[&](ID3D11Query* query,void* value,UINT bytes)
269 {
270 HRESULT hr;const auto deadline=GetTickCount64()+30000;
271 while((hr=context->GetData(query,value,bytes,0))==S_FALSE){Check(GetTickCount64()<deadline,"flight query deadline");Sleep(1);}HR(hr,"flight timestamp");
272 };
273 D3D11_QUERY_DATA_TIMESTAMP_DISJOINT frequency{};UINT64 first=0,last=0;
274 read(disjoint.Get(),&frequency,sizeof(frequency));read(begin.Get(),&first,sizeof(first));read(end.Get(),&last,sizeof(last));
275 Check(!frequency.Disjoint,"flight stable timestamp frequency");total[changed]+=double(last-first)*1000/frequency.Frequency;
276 }
277 const auto difference=compareScenes(a,b,width,height);float maximum=0;memcpy(&maximum,&difference[2],4);
278 if(comparePrimary && before.Pass().SelectedOrganicPath()==CloudPass11::OrganicPath::Top
279 && after.Pass().SelectedOrganicPath()==CloudPass11::OrganicPath::Top)
280 {
281 for(unsigned surface=0;surface<(requireHistory ? 2u : 1u);++surface)
282 {
283 context->ClearState();const UINT zero[4]{};context->ClearUnorderedAccessViewUint(counterView.Get(),zero);
284 ID3D11ShaderResourceView* sources[]={before.Pass().Image(),after.Pass().Image(),before.Pass().Distance(),after.Pass().Distance()};
285 if(surface)
286 {
287 sources[0]=before.Parameters().Texture("_testRawCloudImage");sources[1]=after.Parameters().Texture("_testRawCloudImage");
288 sources[2]=before.Parameters().Texture("_testRawCloudDistance");sources[3]=after.Parameters().Texture("_testRawCloudDistance");
289 }
290 for(auto* sourceView:sources)Check(sourceView!=nullptr,"primary/history diagnostic texture bound");
291 ComPtr<ID3D11Resource> resource;sources[0]->GetResource(&resource);ComPtr<ID3D11Texture2D> texture;
292 HR(resource.As(&texture),"primary comparison texture");D3D11_TEXTURE2D_DESC size{};texture->GetDesc(&size);
293 auto* target=counterView.Get();context->CSSetShader(primaryCompare.Get(),nullptr,0);context->CSSetShaderResources(0,4,sources);
294 context->CSSetUnorderedAccessViews(0,1,&target,nullptr);context->Dispatch((size.Width+15)/16,(size.Height+15)/16,1);context->ClearState();
295 context->CopyResource(readback.Get(),counters.Get());D3D11_MAPPED_SUBRESOURCE mapped{};
296 HR(context->Map(readback.Get(),0,D3D11_MAP_READ,0,&mapped),"primary comparison readback");
297 std::array<UINT,4> values{};memcpy(values.data(),mapped.pData,16);context->Unmap(readback.Get(),0);
298 std::cout<<(surface ? "Raw primary case " : "Primary/history case ")<<scenario<<": color/distance "<<values[0]<<'/'<<values[1]<<std::endl;
299 Check(values[0]==0 && values[1]==0,"exact original Top primary color and both distance channels");
300 }
301 }
302 csv<<scenario<<','<<altitude<<','<<geometry<<','<<light<<','<<fog<<','<<samples<<','<<width<<','<<height<<','
303 <<total[0]/batches<<','<<total[1]/batches<<','<<difference[0]<<','<<difference[1]<<','<<maximum<<'\n';csv.flush();
304 colorDifferences+=difference[0];depthDifferences+=difference[1];
305 std::cout<<"Flight case "<<scenario<<": "<<total[0]/batches<<" -> "<<total[1]/batches<<" ms; color/depth "<<difference[0]<<'/'<<difference[1]<<std::endl;
306 if(difference[0]){SaveFullCloudImage(gpu,a,output/(std::to_string(scenario)+"-before.ppm"));SaveFullCloudImage(gpu,b,output/(std::to_string(scenario)+"-after.ppm"));}
307 }
308 Check(executed>0,"flight comparison executed cases");DebugMessages(gpu);
309 Check(depthDifferences==0,"original flight MSAA depth preserved");
310 Check(colorDifferences==0,"exact original flight MSAA colors");
311 if(requireHistory)for(unsigned index=0;index<2;++index)
312 {
313 std::cout<<"Temporal "<<index<<": frames="<<historyFrames[index]<<",reused="<<historyReused[index]
314 <<",reset="<<historyReset[index]<<",phaseMask="<<historyPhases[index]<<std::endl;
315 Check(historyFrames[index]>0,"temporal diagnostics observed active orbital history");
316 if(expectHistoryReset)Check(historyReused[index]==0 && historyReset[index]>0,"transient lighting resets orbital history");
317 else Check(historyReused[index]>=4 && historyPhases[index]==15,"orbital history reused all four jitter phases");
318 }
319 std::cout<<"PASS: "<<executed<<" controlled flight cases, original MSAA samples unchanged\n";
320}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
typedef void(S_CALLTYPE *SteamAPIWarningMessageHook_t)(int
CloudWeather::Frame weather
Definition CloudVolume.h:35