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

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

1#include "NativeUiTest11.h"
2#include "../Rendering/AdDiagnostics11.h"
3#include "../Rendering/CloudRenderer11.h"
4#include "../Rendering/WindshieldRain11.h"
5#include <iostream>
6#include <limits>
7
8using namespace Rendering;
9using namespace DirectX;
10using Microsoft::WRL::ComPtr;
11namespace Rendering
12{
13 struct WindshieldRain11TestAccess
14 {
15 static WindshieldRain::Surface& Water(WindshieldRain11& rain){return rain.panes[0].water;}
16 };
17}
18namespace
19{
20 unsigned checks=0;
21 void Check(bool value,const char* message){++checks;if(!value)throw std::runtime_error(message);}
22 void Model()
23 {
24 using namespace AdViewability;
25 Placement p;p.entity=1;p.creative="test";
26 Observation good;good.screenPixels=1000000;good.referencePixels=30000;good.visiblePixels=good.clearPixels=15000;
27 Check(Evaluate(good)==Reason::Passing,"inclusive 50% / 1.5% boundaries");
28 auto piecewise=good;piecewise.anglePixels=15000;piecewise.pitch=70;
29 Check(Evaluate(piecewise)==Reason::Passing,"measured angular pixels override display angle");
30 piecewise.anglePixels=14999;piecewise.clearPixels=14999;
31 Check(Evaluate(piecewise)==Reason::Angle,"less than half the creative meets angular limits");
32 piecewise=good;piecewise.backFacing=true;piecewise.referencePixels=0;
33 Check(Evaluate(piecewise)==Reason::BackFacing,"back-facing surfaces are excluded explicitly");
34 auto value=good;value.clearPixels=14999;Check(Evaluate(value)!=Reason::Passing,"below threshold rejected");
35 value=good;value.yaw=55;Check(Evaluate(value)==Reason::Passing,"55 degrees inclusive");
36 value.yaw=55.01;Check(Evaluate(value)==Reason::Angle,"angle rejection");
37 value=good;value.mirrored=true;Check(Evaluate(value)==Reason::Angle,"backward creative rejected");
38 value=good;value.clipped=true;Check(Evaluate(value)==Reason::Passing,"partial screen clipping can meet both thresholds");
39 value.projectionInvalid=true;Check(Evaluate(value)==Reason::Clipped,"near-plane projection remains unsupported");
40 value=good;value.measurable=false;Check(Evaluate(value)==Reason::Unmeasured,"missing measurement");
41 Tracker tracker;
42 for(int i=0;i<5;++i){good.seconds=i*.2;tracker.Observe(p,good);}
43 Check(!tracker.Records().at(p).qualified,"five observations span only .8 seconds");
44 good.seconds=1;tracker.Observe(p,good);
45 Check(tracker.Records().at(p).qualified,"one continuous second qualifies");
46 Check(std::abs(tracker.Records().at(p).qualifiedSeconds-1)<1e-8,"initial second counted once");
47 good.seconds=1.2;tracker.Observe(p,good);
48 Check(std::abs(tracker.Records().at(p).qualifiedSeconds-1.2)<1e-8,"additional exposure duration");
49 good.seconds=1.4;good.visiblePixels=0;good.clearPixels=0;tracker.Observe(p,good);
50 Check(tracker.Records().at(p).continuousSeconds==0,"obstruction resets streak");
51 good.visiblePixels=good.clearPixels=15000;good.seconds=1.6;tracker.Observe(p,good);
52 good.seconds=2.2;tracker.Observe(p,good);
53 Check(tracker.Records().at(p).continuousSeconds==0,"gap cannot earn time");
54 good.seconds=2;Check(!tracker.Observe(p,good),"out of order result ignored");
55 good.seconds=std::numeric_limits<double>::quiet_NaN();Check(!tracker.Observe(p,good),"invalid clock ignored");
56 tracker.Interrupt(2.3,Reason::Inactive);Check(tracker.Records().at(p).qualified,"qualification remains single per run");
57 auto newCreative=p;newCreative.creative="new";good.seconds=3;tracker.Observe(newCreative,good);
58 Check(!tracker.Records().at(newCreative).qualified,"creative replacement starts fresh");
59 Tracker exposure;Observation distantObservation=good;distantObservation.seconds=0;
60 distantObservation.referencePixels=distantObservation.visiblePixels=distantObservation.clearPixels=distantObservation.anglePixels=500;
61 for(int i=0;i<=150;++i){distantObservation.seconds=i*.2;exposure.Observe(p,distantObservation);}
62 const auto& distant=exposure.Records().at(p);
63 Check(distant.reason==Reason::TooSmall && !distant.qualified,"small branding remains below the standard threshold");
64 Check(std::abs(distant.screenPercentageSeconds-1.5)<1e-8,"0.05 percent for 30 seconds is 1.5 screen-percentage-seconds");
65 Check(std::abs(distant.visibleSeconds-30)<1e-8 && distant.aboveMinimumScreenPercentageSeconds==0,
66 "small exposure earns visible time without earning the 1.5 percent metric");
67 Check(std::abs(distant.readableScreenPercentageSeconds-1.5)<1e-8 && std::abs(distant.angleScreenPercentageSeconds-1.5)<1e-8,
68 "quality areas are accumulated independently of the standard size cutoff");
69 const double before=distant.screenPercentageSeconds;
70 distantObservation.seconds=30.2;exposure.Interrupt(30.1,Reason::Inactive);exposure.Observe(p,distantObservation);
71 Check(exposure.Records().at(p).screenPercentageSeconds==before,"non-sampled foreground interruption cannot bridge exposure");
72 distantObservation.seconds=30.4;distantObservation.measurable=false;exposure.Observe(p,distantObservation);
73 distantObservation.seconds=30.6;distantObservation.measurable=true;exposure.Observe(p,distantObservation);
74 Check(exposure.Records().at(p).screenPercentageSeconds==before,"missing GPU observation cannot earn inferred exposure");
75 distantObservation.seconds=31.2;exposure.Observe(p,distantObservation);
76 Check(exposure.Records().at(p).screenPercentageSeconds==before,"large observation gap cannot earn area-time");
77 distantObservation.seconds=31.4;distantObservation.sizeRejected=true;exposure.Observe(p,distantObservation);
78 Check(exposure.Records().at(p).screenPercentageSeconds==before,"CPU admission estimates cannot earn exposure");
79 Tracker standard;good.seconds=0;good.anglePixels=15000;standard.Observe(p,good);
80 for(int i=1;i<=5;++i){good.seconds=i*.2;standard.Observe(p,good);}
81 const auto& qualified=standard.Records().at(p);
82 Check(std::abs(qualified.screenPercentageSeconds-1.5)<1e-8 &&
83 std::abs(qualified.aboveMinimumScreenPercentageSeconds-1.5)<1e-8 &&
84 std::abs(qualified.qualifiedScreenPercentageSeconds-1.5)<1e-8,"qualification backfills exactly the initial second of area-time");
85 good.seconds=1.2;standard.Observe(p,good);
86 Check(std::abs(standard.Records().at(p).qualifiedScreenPercentageSeconds-1.8)<1e-8,"qualified area-time is not backfilled twice");
87 standard.Interrupt(1.3,Reason::Inactive);good.seconds=2;standard.Observe(p,good);
88 good.seconds=2.2;standard.Observe(p,good);
89 Check(std::abs(standard.Records().at(p).qualifiedScreenPercentageSeconds-1.8)<1e-8 &&
90 std::abs(standard.Records().at(p).qualifiedSeconds-1.2)<1e-8,"a later short flash must earn its own continuous second");
91 Check(std::abs(standard.Records().at(p).screenPercentageSeconds-2.1)<1e-8 &&
92 std::abs(standard.Records().at(p).aboveMinimumScreenPercentageSeconds-2.1)<1e-8,"short flashes still earn diagnostic and size-qualified exposure");
93 for(int i=2;i<=5;++i){good.seconds=2+i*.2;standard.Observe(p,good);}
94 Check(std::abs(standard.Records().at(p).qualifiedScreenPercentageSeconds-3.3)<1e-8 &&
95 std::abs(standard.Records().at(p).qualifiedSeconds-2.2)<1e-8,"a second full streak backfills its initial second exactly once");
96 good.seconds=3.2;standard.Observe(p,good);
97 Check(std::abs(standard.Records().at(p).qualifiedScreenPercentageSeconds-3.6)<1e-8 &&
98 standard.Summaries().begin()->second.qualifiedPlacements==1,"continued second streak accrues without a duplicate qualified placement");
99 Tracker impaired;value=good;value.seconds=0;value.clearPixels=value.anglePixels=0;impaired.Observe(p,value);
100 value.seconds=.2;impaired.Observe(p,value);
101 const auto& angled=impaired.Records().at(p);
102 Check(angled.screenPercentageSeconds>0 && angled.aboveMinimumScreenPercentageSeconds>0 &&
103 angled.qualifiedScreenPercentageSeconds==0 && angled.readableScreenPercentageSeconds==0,
104 "1.5 percent size alone does not imply full threshold qualification or readable exposure");
105 Tracker clippedExposure;value=good;value.seconds=0;value.referencePixels=100000;value.visiblePixels=value.clearPixels=value.anglePixels=1000;
106 clippedExposure.Observe(p,value);value.seconds=.2;clippedExposure.Observe(p,value);
107 Check(clippedExposure.Records().at(p).reason==Reason::Obstructed &&
108 std::abs(clippedExposure.Records().at(p).screenPercentageSeconds-.02)<1e-8,"less than half a creative visible still contributes its actual diagnostic area");
109 Tracker scaled;value=good;value.seconds=0;scaled.Observe(p,value);value.seconds=.2;
110 value.screenPixels*=4;value.referencePixels*=4;value.visiblePixels*=4;value.clearPixels*=4;value.anglePixels*=4;scaled.Observe(p,value);
111 Check(std::abs(scaled.Records().at(p).screenPercentageSeconds-.3)<1e-8,"resolution changes do not create extra exposure credit");
112 Tracker changing;value=good;value.seconds=0;changing.Observe(p,value);value.seconds=.2;
113 value.visiblePixels=value.clearPixels=value.anglePixels=30000;changing.Observe(p,value);
114 Check(std::abs(changing.Records().at(p).screenPercentageSeconds-.45)<1e-8,"varying screen size uses source-time trapezoidal area integration");
115 Tracker content;value=good;value.seconds=0;value.creativeHash=1;content.Observe(p,value);value.seconds=.2;content.Observe(p,value);
116 auto second=p;second.entity=2;value.seconds=0;content.Observe(second,value);value.seconds=.2;content.Observe(second,value);
117 auto hiddenPlacement=p;hiddenPlacement.entity=3;value.backFacing=true;value.seconds=0;content.Observe(hiddenPlacement,value);
118 auto summaries=content.Summaries();const CreativeKey creative{PlacementKind::Vehicle,"test",1};
119 Check(summaries.at(creative).observedPlacements==3 && summaries.at(creative).visiblePlacements==2 &&
120 std::abs(summaries.at(creative).screenPercentageSeconds-.6)<1e-8,"creative summary counts distinct observed and visible placements");
121 value.backFacing=false;value.creativeHash=2;value.seconds=.4;content.Observe(p,value);
122 Check(content.Summaries().size()==2,"filename reused with different artwork retains separate creative histories");
123 }
124 void AnimatedMetadata()
125 {
126 AnimatedAdMetadata stats;stats.Initialize(2,1,{100,1000,1000},42);
127 const std::vector<uint32_t> original={0xff000000,0x80ffffff},changed={0xffffffff,0xffffffff};
128 Check(stats.Analyze(0,original,1,true)==1 && !stats.Frame(0),"GIF metadata scanning obeys the pixel budget");
129 Check(stats.Analyze(1,changed,1,false)==1 && stats.Frame(0) && !stats.Frame(1),"a frame transition cannot contaminate the pending canvas snapshot");
130 const auto first=*stats.Frame(0);
131 Check(first.hash==42 && first.bounds.x==0 && first.bounds.z==1 && first.bounds.w==1,"animation uses stable content identity and a fixed full-canvas area");
132 Check(std::abs(first.alphaPixels-(1+128/255.))<1e-9 && !first.empty,"black opaque artwork retains its alpha coverage");
133 Check(std::abs(first.meanLuminance-(128/383.))<1e-9,"relative luminance excludes transparent contributions and weights partial alpha");
134 Check(stats.Analyze(0,changed,100,true)==0,"cached GIF frames do not rescan pixels");
135 Check(std::abs(stats.Average().analyzedFraction-.1)<1e-9,"partial animation summaries disclose analyzed duration");
136 stats.Analyze(1,{0xff000000,0xff000000},100,true);
137 Check(std::abs(stats.Average().luminance-first.meanLuminance*.1)<1e-9 && stats.Average().analyzedFraction==1,
138 "whole-animation luminance is weighted by frame duration, not frame count");
139 stats.Analyze(2,{0x00ffffff,0x00000000},100,true);
140 Check(stats.Frame(2)->empty && stats.Frame(2)->alphaPixels==0,"fully transparent frames are empty even with white RGB");
141 stats.Initialize(1,1,{0},99);stats.Analyze(0,{0xffffffff},1,true);
142 Check(stats.Frame(0)->hash==99 && stats.Average().luminance==1 && stats.Average().analyzedFraction==1,
143 "zero-duration held frame and metadata reinitialization are supported");
144 stats.Initialize(8192,8192,{100},1);
145 Check(!stats.Supported() && stats.Analyze(0,{},65536,true)==0,"oversized metadata cannot allocate a canvas or earn inferred exposure");
146 }
147 void OverlayBounds()
148 {
149 NativeUiTest11 fixture(1920,400);auto& device=fixture.device;
150 ComPtr<RenderFont> font;ComPtr<RenderSprite> sprite;
151 NativeUiTest11::HR(CreateFontW(&device,12,0,FW_NORMAL,1,FALSE,DEFAULT_CHARSET,
152 OUT_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Arial",&font));
153 NativeUiTest11::HR(CreateSprite(&device,&sprite));
154 const float black[4]{};device.Context()->ClearRenderTargetView(fixture.host.Device().SceneTarget(),black);
155 AdDiagnostics11 diagnostic;diagnostic.SetEnabled(true);std::vector<RECT> bounds;
156 diagnostic.DrawOverlay(font.Get(),sprite.Get(),1920,400,&bounds);
157 Check(bounds.size()==1,"readout publishes its measured text bounds");
158 const auto rectangle=bounds.front();
159 Check(rectangle.right<960 && rectangle.bottom<200,"empty upper-right and lower readout space are not masked");
160 const auto pixels=fixture.Pixels();size_t painted=0;bool contained=true;
161 for(unsigned y=0;y<400;++y)for(unsigned x=0;x<1920;++x)if(pixels[y*1920+x]&0x00ffffff)
162 {
163 ++painted;contained=contained && x>=unsigned(rectangle.left) && x<unsigned(rectangle.right) &&
164 y>=unsigned(rectangle.top) && y<unsigned(rectangle.bottom);
165 }
166 Check(painted>100 && contained,"text UI mask contains all rendered readout pixels");
167 bounds.clear();diagnostic.SetOverlayVisible(false);diagnostic.DrawOverlay(font.Get(),sprite.Get(),1920,400,&bounds);
168 Check(bounds.empty(),"hidden ADVIEW2 readout adds no UI mask");
169 diagnostic.SetOverlayVisible(true);diagnostic.DrawOverlay(font.Get(),sprite.Get(),360,80,&bounds);
170 Check(bounds.size()==1 && bounds.front().right<=348 && bounds.front().bottom<=68,"readout bounds follow the actual text clipping rectangle");
171 diagnostic.SetEnabled(false);fixture.DebugClean();
172 }
173 ComPtr<ID3D11ShaderResourceView> Texture(RenderDevice& device,DWORD rgba,unsigned extent=1)
174 {
175 const std::vector<DWORD> pixels(size_t(extent)*extent,rgba);
176 D3D11_TEXTURE2D_DESC desc{};desc.Width=desc.Height=extent;desc.MipLevels=desc.ArraySize=desc.SampleDesc.Count=1;
177 desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
178 D3D11_SUBRESOURCE_DATA data{pixels.data(),extent*4,extent*extent*4};ComPtr<ID3D11Texture2D> texture;ComPtr<ID3D11ShaderResourceView> view;
179 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,&data,&texture));
180 NativeUiTest11::HR(device.Native()->CreateShaderResourceView(texture.Get(),nullptr,&view));return view;
181 }
182 ComPtr<ID3D11ShaderResourceView> SparseTexture(RenderDevice& device)
183 {
184 const DWORD rgba[]={0xffffffff,0x00ffffff,0xffffffff,0x00ffffff};
185 D3D11_TEXTURE2D_DESC desc{};desc.Width=desc.Height=2;desc.MipLevels=desc.ArraySize=desc.SampleDesc.Count=1;
186 desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
187 D3D11_SUBRESOURCE_DATA data{rgba,8,16};ComPtr<ID3D11Texture2D> texture;ComPtr<ID3D11ShaderResourceView> view;
188 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,&data,&texture));
189 NativeUiTest11::HR(device.Native()->CreateShaderResourceView(texture.Get(),nullptr,&view));return view;
190 }
191 ComPtr<ID3D11ShaderResourceView> UnevenTexture(RenderDevice& device)
192 {
193 DWORD rgba[16]{};for(unsigned y=0;y<4;++y)rgba[y*4]=0xffffffff;rgba[3]=0xffffffff;
194 D3D11_TEXTURE2D_DESC desc{};desc.Width=desc.Height=4;desc.MipLevels=desc.ArraySize=desc.SampleDesc.Count=1;
195 desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
196 D3D11_SUBRESOURCE_DATA data{rgba,16,64};ComPtr<ID3D11Texture2D> texture;ComPtr<ID3D11ShaderResourceView> view;
197 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,&data,&texture));
198 NativeUiTest11::HR(device.Native()->CreateShaderResourceView(texture.Get(),nullptr,&view));return view;
199 }
200 std::vector<BYTE> Read(RenderDevice& device,ID3D11Texture2D* source,unsigned channels)
201 {
202 D3D11_TEXTURE2D_DESC desc{};source->GetDesc(&desc);ComPtr<ID3D11Texture2D> resolved,staging;
203 if(desc.SampleDesc.Count>1)
204 {
205 desc.SampleDesc={1,0};desc.BindFlags=0;
206 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,nullptr,&resolved));
207 device.Context()->ResolveSubresource(resolved.Get(),0,source,0,desc.Format);source=resolved.Get();
208 }
209 desc.Usage=D3D11_USAGE_STAGING;desc.CPUAccessFlags=D3D11_CPU_ACCESS_READ;desc.BindFlags=desc.MiscFlags=0;
210 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,nullptr,&staging));device.Context()->CopyResource(staging.Get(),source);
211 D3D11_MAPPED_SUBRESOURCE map{};NativeUiTest11::HR(device.Context()->Map(staging.Get(),0,D3D11_MAP_READ,0,&map));
212 std::vector<BYTE> bytes(size_t(desc.Width)*desc.Height*channels);
213 for(unsigned y=0;y<desc.Height;++y)memcpy(bytes.data()+size_t(y)*desc.Width*channels,static_cast<BYTE*>(map.pData)+size_t(y)*map.RowPitch,desc.Width*channels);
214 device.Context()->Unmap(staging.Get(),0);return bytes;
215 }
216 void CloudExport(unsigned samples)
217 {
218 NativeUiTest11 fixture(160,120);if(!fixture.host.Device().SupportsSamples(samples))return;
219 NativeUiTest11::HR(fixture.host.SetSamples(samples));fixture.device.Reset();
220 auto& device=fixture.device;CloudRenderer11 clouds;NativeUiTest11::HR(clouds.Initialize(device.Native()));clouds.SetLightningEnabled(false);
221 CloudVolume::Parameters cloud;cloud.activity=.6f;
222 XMFLOAT4X4 view,projection;
223 XMStoreFloat4x4(&view,XMMatrixLookAtRH(XMVectorZero(),XMVectorSet(0,-.6f,-1,0),XMVectorSet(0,1,0,0)));
224 XMStoreFloat4x4(&projection,XMMatrixPerspectiveFovRH(1.f,160.f/120,.001f,384));
225 const auto& depth=fixture.host.Device().Depth();const auto vp=device.Draws().Viewport();
226 ComPtr<ID3D11Texture2D> opacity;ComPtr<ID3D11RenderTargetView> target;
227 D3D11_TEXTURE2D_DESC desc{};fixture.host.Device().SceneColor()->GetDesc(&desc);desc.Format=DXGI_FORMAT_R8_UNORM;
228 NativeUiTest11::HR(device.Native()->CreateTexture2D(&desc,nullptr,&opacity));
229 NativeUiTest11::HR(device.Native()->CreateRenderTargetView(opacity.Get(),nullptr,&target));
230 const float zero[4]{};
231 auto render=[&](bool diagnostic)
232 {
233 device.Context()->ClearRenderTargetView(fixture.host.Device().SceneTarget(),zero);
234 device.Context()->ClearRenderTargetView(target.Get(),zero);
235 device.Context()->ClearDepthStencilView(depth.WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
236 clouds.Pass().SetAdOpacityTarget(diagnostic ? target.Get() : nullptr);
237 NativeUiTest11::HR(clouds.Render(device.Context(),fixture.host.Device().SceneTarget(),depth,vp,view,projection,
238 {0,cloud.radius+14,0},cloud,{0,-1,0},{1,1,1,1},{.3f,.4f,.5f,1}));
239 if(diagnostic)Check(clouds.Pass().AdOpacityWritten(),"cloud MRT actually rendered");
240 return Read(device,fixture.host.Device().SceneColor(),4);
241 };
242 const auto baseline=render(false),measured=render(true),alpha=Read(device,opacity.Get(),1);
243 Check(baseline==measured,"opacity MRT preserves cloud color and alpha");
244 unsigned nonzero=0;
245 for(size_t i=0;i<alpha.size();++i){Check(std::abs(int(alpha[i])-int(measured[i*4+3]))<=1,"exported opacity equals actual composite alpha");nonzero+=alpha[i]>0;}
246 Check(nonzero>100,"cloud opacity fixture has visible cloud pixels");
247 clouds.Pass().SetAdOpacityTarget(nullptr);clouds.Reset();fixture.DebugClean();
248 std::cout<<samples<<"x cloud opacity MRT matches production composite\n";
249 }
250 void Billboards(unsigned samples)
251 {
252 NativeUiTest11 fixture(320,240);
253 if(!fixture.host.Device().SupportsSamples(samples))return;
254 NativeUiTest11::HR(fixture.host.SetSamples(samples));fixture.device.Reset();
255 auto& device=fixture.device;auto& draws=device.Draws();auto* context=device.Context();
256 Geometry11 mesh;AdDiagnostics11::Vertex vertices[]={
257 {{-.6f,.6f,.5f},{0,0,-1},{0,0},{0,0}},{{.6f,.6f,.5f},{0,0,-1},{1,0},{1,0}},{{-.6f,-.6f,.5f},{0,0,-1},{0,1},{0,1}},
258 {{-.6f,-.6f,.5f},{0,0,-1},{0,1},{0,1}},{{.6f,.6f,.5f},{0,0,-1},{1,0},{1,0}},{{.6f,-.6f,.5f},{0,0,-1},{1,1},{1,1}}};
259 // Deliberately unrelated legacy lighting normals: city query angles
260 // must come from transformed triangles rather than these values.
261 for(auto& vertex:vertices)vertex.normal={1,0,0};
262 NativeUiTest11::HR(mesh.Create(device.Native(),sizeof(vertices),false));void* destination=nullptr;
263 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,vertices,sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
264 VertexLayout11 layout;layout.stride=40;layout.normal=12;layout.uv[0]=24;layout.uv[1]=32;
265 XMFLOAT4X4 identity;XMStoreFloat4x4(&identity,XMMatrixIdentity());auto world=identity;
266 auto white=Texture(device,0xffffffff),black=Texture(device,0xff000000),base=Texture(device,0xff404040),half=Texture(device,0x80ffffff);
267 AnimatedAdMetadata stats;stats.Initialize(1,1,{100,200,300,400},123);
268 for(unsigned f=0;f<4;++f)stats.Analyze(f,{f==1 ? 0xff000000u : f==2 ? 0x80ffffffu : f==3 ? 0x00ffffffu : 0xffffffffu},1,true);
269 auto lifetime=std::make_shared<int>(1);
270 AdDiagnostics11 diagnostic;diagnostic.SetEnabled(true);diagnostic.SetAnimatedInventory(true);
272 placement.entity=4002;placement.component=26;placement.creative="animated";placement.creativeHash=123;
273 auto& parameters=draws.Materials().Values();
274 parameters.Texture("ColorMap",base.Get());parameters.Set("CityOverlayEnabled",1);parameters.Set("Features",XMFLOAT4(26,0,0,0));
275 parameters.Set("WeapPos",XMFLOAT4{});parameters.Set("shiplight",XMFLOAT4{});parameters.Set("light",XMFLOAT4{});
276 parameters.Set("clouduv",XMFLOAT4{});
277 draws.Pipeline().raster.CullMode=D3D11_CULL_NONE;
278 WindshieldRain11 rain;NativeUiTest11::HR(rain.Initialize(device.Native()));
280 {-.0008f,.0008f,.0002f,0,0,-1,0,0},{.0008f,.0008f,.0002f,0,0,-1,1,0},{-.0008f,-.0008f,.0002f,0,0,-1,0,1},
281 {-.0008f,-.0008f,.0002f,0,0,-1,0,1},{.0008f,.0008f,.0002f,0,0,-1,1,0},{.0008f,-.0008f,.0002f,0,0,-1,1,1}};
282 rain.AddGlass(0,pane,std::size(pane));rain.FinishGeometry();
283 XMFLOAT4X4 paneWorld;XMStoreFloat4x4(&paneWorld,XMMatrixScaling(1000,1000,1000));
284 double clock=0;
285 const auto sample=[&](unsigned material,unsigned frame,float daylight,const std::vector<XMFLOAT4>& masks={},float cloud=0,float sceneDepth=1,unsigned wet=0,UINT sceneStencil=0)
286 {
287 clock+=.24;const double source=clock;diagnostic.BeginFrame(device,source,true);draws.BindScene();
288 const float zero[4]{};context->ClearRenderTargetView(fixture.host.Device().SceneTarget(),zero);
289 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,sceneDepth,UINT8(sceneStencil));
290 parameters.Set("matWorld",world);parameters.Set("matWorldViewProj",world);parameters.Set("ambient",XMFLOAT4(daylight,daylight,daylight,100));
291 parameters.Texture("CityOverlayMap",frame==1 ? black.Get() : frame==2 ? half.Get() : white.Get());
292 draws.Material(material);NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,2));
293 auto before=Read(device,fixture.host.Device().SceneColor(),4);
294 diagnostic.RegisterSignDraw(device,placement,stats.Frame(frame),lifetime,frame,4,stats.Average(),mesh,0,2,material,world,identity,identity,.5f);
295 const HRESULT captured=diagnostic.CaptureScene(device);
296 if(frame!=3)NativeUiTest11::HR(captured);
297 if(diagnostic.CloudOpacityTarget()){const float opacity[]={cloud,0,0,0};context->ClearRenderTargetView(diagnostic.CloudOpacityTarget(),opacity);}
298 if(wet)
299 {
300 auto& water=WindshieldRain11TestAccess::Water(rain);water.Clear();
301 if(wet==2)
302 for(unsigned y=0;y<16;++y)for(unsigned x=0;x<16;++x)water.Impact({(x+.5f)*.1f,(y+.5f)*.1f},.08f,false);
303 else water.Impact({.8f,.8f},.08f,false);
304 water.Rebuild();
305 const float opacity=wet==3 ? 0.f : 1.f;
306 auto paneTransform=paneWorld;if(wet==5)paneTransform._41=3;
307 const auto renderWater=[&](ID3D11RenderTargetView* exclusion)
308 {
309 return rain.Render(context,fixture.host.Device().SceneTarget(),fixture.host.Device().Depth().WriteView(),draws.Viewport(),
310 {paneTransform},identity,opacity,WindshieldRain11::DepthLayout::CockpitAndWorld,1,exclusion);
311 };
312 NativeUiTest11::HR(renderWater(nullptr));const auto baseline=Read(device,fixture.host.Device().SceneColor(),4);
313 draws.BindScene();context->ClearRenderTargetView(fixture.host.Device().SceneTarget(),zero);
314 draws.Material(material);NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,2));
315 auto* exclusion=diagnostic.WetGlassExclusionTarget();Check(exclusion!=nullptr,"sampled sign exposes the shared wet-glass target");
316 const HRESULT result=renderWater(exclusion);NativeUiTest11::HR(result);
317 diagnostic.WetGlassResult(wet==4 ? E_FAIL : result);
318 before=Read(device,fixture.host.Device().SceneColor(),4);
319 Check(before==baseline,"wet-glass MRT preserves production rain color at every MSAA level");
320 ComPtr<ID3D11Resource> resource;exclusion->GetResource(&resource);ComPtr<ID3D11Texture2D> mask;
321 NativeUiTest11::HR(resource.As(&mask));const auto pixels=Read(device,mask.Get(),1);
322 const auto affected=std::count_if(pixels.begin(),pixels.end(),[](BYTE v){return v!=0;});
323 // World and cockpit use different projection/depth domains:
324 // only cockpit stencil/depth can hide glass in this rain pass.
325 if(wet==3 || wet==5 || (sceneStencil>=3 && sceneDepth<.2f))
326 Check(affected==0,"faded, offscreen or cockpit-hidden water leaves the exposure mask clear");
327 else if(wet==1)Check(affected>20 && affected<10000,"localized water excludes droplets rather than the whole apartment window");
328 }
329 diagnostic.FinishScene(device,true,masks);context->Flush();
330 Check(before==Read(device,fixture.host.Device().SceneColor(),4),"billboard measurement does not modify scene color");
332 for(unsigned attempt=0;attempt<200;++attempt)
333 {
334 for(const auto& item:diagnostic.Results().Records())if(item.first.entity==placement.entity && item.first.creativeHash==123 &&
335 std::abs(item.second.last.seconds-source)<1e-8){result=item.second;return result;}
336 Sleep(1);diagnostic.BeginFrame(device,source+.001,true);
337 }
338 throw std::runtime_error("billboard GPU query did not complete");
339 };
340 for(unsigned material:{2u,3u})
341 {
342 auto value=sample(material,0,1);
343 Check(value.reason==AdViewability::Reason::Passing && value.last.visiblePixels>27000,"near/far billboard full canvas qualifies in daylight");
344 value=sample(material,0,0);
345 Check(value.reason==AdViewability::Reason::Passing && value.last.clearPixels/value.last.referencePixels>.99,"emissive billboard remains readable at night");
346 value=sample(material,1,0);
347 Check(value.last.visiblePixels/value.last.referencePixels>.99 && value.last.sourceMeanLuminance==0 && value.last.artworkVisiblePixels>27000,
348 "black GIF artwork retains physical and alpha visibility");
349 value=sample(material,2,0);
350 Check(std::abs(value.last.artworkVisiblePixels/value.last.visiblePixels-128/255.)<.03,"animated partial-alpha ink uses the current frame");
351 value=sample(material,0,0,{{0,0,.5f,1}});
352 Check(value.last.visiblePixels/value.last.referencePixels>.48 && value.last.visiblePixels/value.last.referencePixels<.52,
353 "billboard UI obstruction uses the same physical pixel mask as vehicle logos");
354 value=sample(material,0,0,{},.7f);
355 Check(value.last.visiblePixels>0 && value.last.clearPixels==0 && value.reason==AdViewability::Reason::Appearance,
356 "cloud impairment remains separate from raw sign exposure");
357 value=sample(material,0,0,{},0,.1f);
358 Check(value.last.visiblePixels==0,"opaque foreground geometry blocks sign exposure");
359 value=sample(material,0,0,{},0,1,1);
360 Check(value.last.wetGlassExcluded && value.last.visiblePixels/value.last.referencePixels>.9
361 && value.last.visiblePixels<value.last.referencePixels && value.reason==AdViewability::Reason::Passing,
362 "clear majority of a wet apartment window measures and qualifies the near/far sign");
363 value=sample(material,0,0,{},0,1,2);
364 Check(value.last.wetGlassExcluded && value.last.visiblePixels/value.last.referencePixels<.5,
365 "heavy water does not receive full creative exposure credit");
366 value=sample(material,0,0,{},0,1,3);
367 Check(!value.last.wetGlassExcluded && value.last.visiblePixels/value.last.referencePixels>.99,
368 "fully faded water neither blocks exposure nor reports an active exclusion");
369 value=sample(material,0,0,{},0,.1f,1);
370 Check(value.last.visiblePixels==0,"wet-glass support preserves opaque obstruction checks");
371 for(UINT stencil:{3u,4u})
372 {
373 value=sample(material,0,0,{},0,.1f,1,stencil);
374 Check(value.last.visiblePixels==0,"cockpit foreground depth/stencil remains excluded through wet glass");
375 }
376 value=sample(material,0,0,{},0,1,4);
377 Check(value.reason==AdViewability::Reason::Unmeasured && diagnostic.Blocker()=="wet-glass exclusion unavailable",
378 "failed wet-glass mask cannot silently earn sign exposure");
379 value=sample(material,0,0,{},0,1,5);
380 Check(!value.last.wetGlassExcluded && value.last.visiblePixels/value.last.referencePixels>.99,
381 "wet windows outside the view do not block the visible billboard");
382 }
383 for(unsigned triangle=0;triangle<6;triangle+=3)std::swap(vertices[triangle],vertices[triangle+1]);
384 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,vertices,sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
385 draws.Pipeline().raster.CullMode=D3D11_CULL_BACK;draws.Pipeline().raster.FrontCounterClockwise=TRUE;
386 Check(sample(2,0,0).reason==AdViewability::Reason::Passing,"sign facing follows reversed production winding/culling, not authored normals");
387 XMStoreFloat4x4(&world,XMMatrixRotationY(XM_PI)*XMMatrixTranslation(0,0,1));
388 Check(sample(2,0,0).reason==AdViewability::Reason::BackFacing,"back of a city sign is excluded");
389 XMStoreFloat4x4(&world,XMMatrixTranslation(1.1f,0,0));
390 const auto clipped=sample(3,0,0);
391 Check(clipped.reason==AdViewability::Reason::Obstructed && clipped.last.clipped &&
392 clipped.last.visiblePixels>0 && clipped.last.visiblePixels/clipped.last.referencePixels<.5,"partly off-screen signs retain measured exposure below the 50 percent criterion");
393 world=identity;
394 Check(diagnostic.Results().Records().size()==1,"animation frames retain one sign record and exposure history");
395 for(unsigned f=0;f<6;++f)sample(2,f%2,0);
396 const auto& continuous=diagnostic.Results().Records().begin()->second;
397 Check(continuous.qualified && continuous.qualifiedScreenPercentageSeconds>0 &&
398 continuous.aboveMinimumScreenPercentageSeconds>0 && continuous.screenPercentageSeconds>=continuous.qualifiedScreenPercentageSeconds,
399 "animated frame changes preserve SPS and a full continuous qualifying streak");
400 auto value=sample(2,3,0);
401 Check(value.last.sizeRejected && value.last.sourceAlphaPixels==0 && value.continuousSeconds==0,"empty animation frame cannot earn exposure or qualification");
402 placement.entity=4003;sample(2,0,0);
403 Check(diagnostic.Results().Summaries().begin()->second.observedPlacements==2,"shared GIF counts two physical signs separately");
404 // Assignment invalidation after submission must reject delayed GPU data.
405 placement.entity=4004;clock+=.24;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
406 diagnostic.RegisterSignDraw(device,placement,stats.Frame(0),lifetime,0,4,stats.Average(),mesh,0,2,2,world,identity,identity,.5f);
407 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});lifetime.reset();context->Flush();Sleep(5);
408 diagnostic.BeginFrame(device,clock+.01,true);
409 Check(diagnostic.Results().Records().size()==2,"removed artwork cannot publish a delayed query under a new assignment");
410 lifetime=std::make_shared<int>(2);clock+=.24;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
411 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
412 parameters.Texture("CityOverlayMap",white.Get());draws.Material(2);NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,2));
413 const auto dropped=diagnostic.Dropped();
414 for(unsigned i=0;i<70;++i)
415 {
416 placement.entity=10000+i;
417 diagnostic.RegisterSignDraw(device,placement,stats.Frame(0),lifetime,0,4,stats.Average(),mesh,0,2,2,world,identity,identity,.5f);
418 }
419 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
420 Check(diagnostic.Dropped()-dropped==70-AdDiagnostics11::MaximumCandidates,"many signs retain the shared GPU and preparation budgets");
421 diagnostic.SetEnabled(false);fixture.DebugClean();
422 std::cout<<samples<<"x animated billboard queries passed\n";
423 }
424 void GPU(unsigned samples)
425 {
426 NativeUiTest11 fixture(320,240);
427 if(!fixture.host.Device().SupportsSamples(samples))return;
428 NativeUiTest11::HR(fixture.host.SetSamples(samples));fixture.device.Reset();
429 auto& device=fixture.device;auto& draws=device.Draws();auto* context=device.Context();
430 Geometry11 mesh;
431 const AdDiagnostics11::Vertex vertices[]={
432 {{-.6f,.6f,.5f},{0,0,-1},{0,0},{0,0}},{{.6f,.6f,.5f},{0,0,-1},{1,0},{1,0}},{{-.6f,-.6f,.5f},{0,0,-1},{0,1},{0,1}},
433 {{-.6f,-.6f,.5f},{0,0,-1},{0,1},{0,1}},{{.6f,.6f,.5f},{0,0,-1},{1,0},{1,0}},{{.6f,-.6f,.5f},{0,0,-1},{1,1},{1,1}}};
434 NativeUiTest11::HR(mesh.Create(device.Native(),sizeof(vertices),false));void* destination=nullptr;
435 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,vertices,sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
436 XMFLOAT4X4 identity;XMStoreFloat4x4(&identity,XMMatrixIdentity());
437 XMFLOAT4X4 world=identity,projection=identity;
438 VertexLayout11 layout;layout.stride=40;layout.normal=12;layout.uv[0]=24;layout.uv[1]=32;
439 auto white=Texture(device,0xffffffff,64),hull=Texture(device,0xff404040),black=Texture(device,0xff000000,64),
440 half=Texture(device,0x80ffffff,64),transparent=Texture(device,0x00ffffff),sparse=SparseTexture(device),uneven=UnevenTexture(device);
441 auto& parameters=draws.Materials().Values();
442 parameters.Set("matWorld",identity);parameters.Set("matWorldViewProj",identity);
443 parameters.Set("Features",XMFLOAT4(1,1,1,0));parameters.Set("ambient",XMFLOAT4(1,1,1,100));
444 parameters.Set("Sunlight",XMFLOAT4(0,0,0,0));parameters.Set("Radiosity",XMFLOAT4(0,0,0,0));
445 parameters.Set("WeapPos",XMFLOAT4(0,0,0,0));parameters.Set("clouduv",XMFLOAT4(0,0,1,0));
446 parameters.Texture("ColorMap",hull.Get());parameters.Texture("OverlayMap",white.Get());
447 draws.Pipeline().raster.CullMode=D3D11_CULL_NONE;
448 draws.Material(4);
449 AdDiagnostics11 diagnostic;diagnostic.SetEnabled(true);diagnostic.SyncPlacement(1,10,"fixture");
450 AdViewability::Placement placement;placement.entity=10;placement.creative="fixture";
451 double clock=0;
452 struct GlassVertex { XMFLOAT3 position,normal;XMFLOAT2 uv; };
453 const GlassVertex glassVertices[]={
454 {{-1,1,.1f},{0,0,-1},{0,0}},{{1,1,.1f},{0,0,-1},{1,0}},{{-1,-1,.1f},{0,0,-1},{0,1}},
455 {{-1,-1,.1f},{0,0,-1},{0,1}},{{1,1,.1f},{0,0,-1},{1,0}},{{1,-1,.1f},{0,0,-1},{1,1}}};
456 Geometry11 glassMesh;NativeUiTest11::HR(glassMesh.Create(device.Native(),sizeof(glassVertices),false));
457 NativeUiTest11::HR(glassMesh.Lock(0,sizeof(glassVertices),&destination));memcpy(destination,glassVertices,sizeof(glassVertices));NativeUiTest11::HR(glassMesh.Unlock());
458 VertexLayout11 glassLayout;glassLayout.stride=32;glassLayout.normal=12;glassLayout.uv[0]=24;
459 unsigned glassLayers=0;DWORD glassColor=0x00ffffff;
460 const auto warm=[&](ID3D11ShaderResourceView* logo)
461 {
462 for(unsigned attempt=0;attempt<200;++attempt)
463 {
464 if(const auto* ready=diagnostic.PrepareCreative(device,logo))return *ready;
465 context->Flush();Sleep(1);clock+=.21;diagnostic.BeginFrame(device,clock,true);
466 }
467 throw std::runtime_error("creative metadata did not become ready");
468 };
469 auto sample=[&](int pass,float depth,UINT stencil,const std::vector<XMFLOAT4>& masks,float opacity,bool weather=true,const char* uiBlocker=nullptr)
470 {
471 clock+=.21;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
472 warm(parameters.Texture("OverlayMap"));
473 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,depth,UINT8(stencil));
474 XMFLOAT4X4 wvp;XMStoreFloat4x4(&wvp,XMLoadFloat4x4(&world)*XMLoadFloat4x4(&projection));
475 parameters.Set("matWorld",world);parameters.Set("matWorldViewProj",wvp);
476 draws.Material(pass);NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,2));
477 diagnostic.RegisterDraw(device,placement,1,mesh,0,2,unsigned(pass),world,identity,projection,.5f);
478 NativeUiTest11::HR(diagnostic.CaptureScene(device));
479 const float color[]={opacity,0,0,0};if(diagnostic.CloudOpacityTarget())context->ClearRenderTargetView(diagnostic.CloudOpacityTarget(),color);
480 std::vector<BYTE> sceneBefore;
481 if(glassLayers)
482 {
483 auto tint=Texture(device,glassColor);
484 parameters.Set("matWorld",identity);parameters.Set("matWorldViewProj",identity);
485 parameters.Set("Features",XMFLOAT4(0,0,0,0));parameters.Set("ambient",XMFLOAT4(1,1,1,0));
486 parameters.Texture("ColorMap",tint.Get());
487 auto& blend=draws.Pipeline().blend.RenderTarget[0];blend.BlendEnable=TRUE;
488 blend.SrcBlend=D3D11_BLEND_SRC_ALPHA;blend.DestBlend=D3D11_BLEND_INV_SRC_ALPHA;blend.BlendOp=D3D11_BLEND_OP_ADD;
489 draws.Pipeline().depth.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ZERO;draws.Pipeline().depth.DepthFunc=D3D11_COMPARISON_ALWAYS;
490 draws.Material(8);
491 for(unsigned layer=0;layer<glassLayers;++layer)
492 {
493 NativeUiTest11::HR(draws.Draw(glassMesh,glassLayout,Primitive11::Triangles,0,2));
494 diagnostic.RegisterOverlayDraw(device,glassMesh,0,2,8);
495 }
496 sceneBefore=Read(device,fixture.host.Device().SceneColor(),4);
497 }
498 diagnostic.FinishScene(device,weather,masks,uiBlocker);context->Flush();
499 if(glassLayers)
500 {
501 Check(sceneBefore==Read(device,fixture.host.Device().SceneColor(),4),"glass opacity replay preserves production scene pixels");
502 parameters.Texture("ColorMap",hull.Get());parameters.Set("Features",XMFLOAT4(1,1,1,0));parameters.Set("ambient",XMFLOAT4(1,1,1,100));
503 draws.Pipeline().blend.RenderTarget[0].BlendEnable=FALSE;
504 draws.Pipeline().depth.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ALL;draws.Pipeline().depth.DepthFunc=D3D11_COMPARISON_LESS;
505 }
506 const auto latest=[&]() -> const AdViewability::Record*
507 {
508 for(const auto& item:diagnostic.Results().Records())if(std::abs(item.second.last.seconds-clock)<.001)return &item.second;
509 return nullptr;
510 };
511 for(int attempt=0;attempt<100 && !latest();++attempt)
512 {Sleep(1);diagnostic.BeginFrame(device,clock+.01,true);}
513 Check(latest()!=nullptr,"GPU observation returned");
514 const auto& record=*latest();
515 Check(std::abs(record.last.seconds-clock)<.001,"observation source timestamp");
516 return record;
517 };
518 auto record=sample(4,1,0,{},0);
519 std::cout<<samples<<"x MSAA: reference="<<record.last.referencePixels<<" visible="<<record.last.visiblePixels<<" clear="<<record.last.clearPixels<<" reason="<<AdViewability::Name(record.reason)<<"\n";
520 Check(record.reason==AdViewability::Reason::Passing,"clear front-facing surface passes");
521 Check(std::abs(record.last.referencePixels/76800-.36)<.01,"MSAA normalized to pixels");
522 record=sample(5,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"production pass 5 measured");
523 XMStoreFloat4x4(&world,XMMatrixScaling(.04f,.04f,1));record=sample(4,1,0,{},0);
524 Check(record.reason==AdViewability::Reason::TooSmall && !record.last.sizeRejected && record.last.anglePixels>=0 &&
525 record.last.visiblePixels>0,"logo around 0.05 percent receives real GPU measurements");
526 const double smallArea=record.screenPercentageSeconds;record=sample(4,1,0,{},0);
527 Check(record.screenPercentageSeconds>smallArea,"small GPU-measured logo contributes diagnostic area-time");
528 XMStoreFloat4x4(&world,XMMatrixScaling(.02f,.02f,1));record=sample(4,1,0,{},0);
529 Check(record.last.sizeRejected,"work below the disclosed 0.05 percent admission floor stays bounded");
530 world=identity;record=sample(5,1,0,{},0);
531 record=sample(4,1,0,{},1);
532 Check(record.last.visiblePixels==0 && record.last.clearPixels==0,"opaque cloud excludes raw as well as readable area");
533 const double hiddenArea=record.screenPercentageSeconds;record=sample(4,1,0,{},1);
534 Check(record.screenPercentageSeconds==hiddenArea,"steady fully cloud-hidden logo earns no area-time");
535 parameters.Set("volumeFog",XMFLOAT4(0,0,0,10));record=sample(5,1,0,{},0);
536 Check(record.last.visiblePixels==0,"zero fog transmission excludes diagnostic visibility");
537 parameters.Set("volumeFog",XMFLOAT4(0,0,0,0));record=sample(5,1,0,{},0);
538 // Intended area includes the interior spaces; ink coverage is measured
539 // separately and must follow the actual mask under uneven occlusion.
540 const double opaqueInk=record.last.artworkVisiblePixels;
541 parameters.Texture("OverlayMap",half.Get());record=sample(4,1,0,{},0);
542 Check(std::abs(record.last.sourceAlphaPixels-4096.*128/255)<1e-7,"source alpha sum weights partial opacity");
543 Check(std::abs(record.last.sourceMeanLuminance-1)<1e-8,"source luminance is alpha weighted in linear light");
544 Check(std::abs(record.last.referencePixels-27648)<1,"partial alpha does not shrink intended area");
545 Check(std::abs(record.last.artworkVisiblePixels/opaqueInk-128./255)<.015,"half opacity contributes half the corresponding sampled opaque coverage");
546 const auto cached=warm(half.Get());
547 Check(cached.hash==record.last.creativeHash && cached.alphaPixels==record.last.sourceAlphaPixels,"metadata is reused for the same texture");
548 parameters.Texture("OverlayMap",uneven.Get());record=sample(4,1,0,{},0);
549 Check(record.last.sourceAlphaPixels==5 && std::abs(record.last.referencePixels-27648)<1,"tight enclosing area retains transparent interior spaces");
550 const double fullInk=record.last.artworkReferencePixels;
551 record=sample(4,1,0,{{0,0,.5f,1}},0);
552 Check(std::abs(record.last.visiblePixels/record.last.referencePixels-.5)<.01,"half the intended area remains visible");
553 Check(record.last.artworkVisiblePixels/fullInk<.4,"uneven ink visibility uses spatial alpha rather than global fill correction");
554 parameters.Texture("OverlayMap",black.Get());parameters.Texture("ColorMap",white.Get());
555 record=sample(4,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"black artwork on a lit white hull is readable");
556 record=sample(5,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"black artwork contrast works on vehicle material 5");
557 parameters.Texture("ColorMap",black.Get());record=sample(4,1,0,{},0);
558 Check(record.reason==AdViewability::Reason::Appearance,"black artwork on black hull has no contrast");
559 parameters.Texture("ColorMap",hull.Get());parameters.Set("ambient",XMFLOAT4(.08f,.08f,.08f,100));
560 record=sample(4,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"dark artwork retains contrast under dim lighting");
561 parameters.Set("ambient",XMFLOAT4(0,0,0,100));record=sample(4,1,0,{},0);
562 Check(record.reason==AdViewability::Reason::Appearance,"unlit hull and black artwork lose actual contrast");
563 parameters.Texture("ColorMap2",white.Get());parameters.Set("clouduv",XMFLOAT4(0,1,1,0));
564 for(int pass:{4,5})
565 {
566 record=sample(pass,1,0,{},0);
567 Check(record.reason==AdViewability::Reason::Passing,"black paint stays readable under a saturated hull light map");
568 }
569 parameters.Set("clouduv",XMFLOAT4(0,0,1,0));
570 parameters.Set("ambient",XMFLOAT4(1,1,1,100));parameters.Texture("OverlayMap",white.Get());
571 XMStoreFloat4x4(&world,XMMatrixTranslation(.8f,0,.4f));record=sample(4,1,0,{},0);
572 Check(record.last.clipped && record.reason==AdViewability::Reason::Passing,"partially off-screen placement can qualify");
573 Check(std::abs(record.last.referencePixels-27648)<2 && std::abs(record.last.visiblePixels/record.last.referencePixels-2./3)<.01,
574 "off-screen part remains in the full reference denominator");
575 // The production vertex wrapper adds a half-pixel legacy center offset.
576 // Place the final rendered center on the viewport edge, not half a pixel past it.
577 XMStoreFloat4x4(&world,XMMatrixTranslation(1-1/320.f,0,.4f));record=sample(4,1,0,{},0);
578 Check(record.reason==AdViewability::Reason::Passing && std::abs(record.last.visiblePixels/record.last.referencePixels-.5)<.001,
579 "exactly half visible qualifies with enough visible screen area");
580 XMStoreFloat4x4(&world,XMMatrixTranslation(1.02f,0,.4f));record=sample(4,1,0,{},0);
581 Check(record.reason==AdViewability::Reason::Obstructed,"less than half visible cannot qualify");
582 XMStoreFloat4x4(&world,XMMatrixScaling(3,3,1));record=sample(4,1,0,{},0);
583 Check(record.last.referencePixels>record.last.screenPixels*3 && record.reason==AdViewability::Reason::Obstructed,
584 "oversized creative reference includes both off-screen edges");
585 world=identity;
586 // UV clipping must not retriangulate the production depth plane. Tiny
587 // depth-only motion should leave a fully visible, sloped decal stable.
588 auto sloped=std::vector<AdDiagnostics11::Vertex>(std::begin(vertices),std::end(vertices));
589 for(auto& v:sloped){v.position.z+=v.position.x*.173239f+v.position.y*.217231f;v.logo={v.logo.x*1.4f-.2f,v.logo.y*1.4f-.2f};}
590 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,sloped.data(),sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
591 for(int i=0;i<12;++i)
592 {
593 XMStoreFloat4x4(&world,XMMatrixTranslation(0,0,float(i)*.0000007f));record=sample(4,1,0,{},0);
594 Check(record.last.visiblePixels/record.last.referencePixels>.995,"sloped coplanar logo remains visible under tiny depth motion");
595 }
596 world=identity;NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,vertices,sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
597 record=sample(4,.49999f,0,{},0);
598 Check(record.last.visiblePixels==0,"near coplanar foreground blocker remains opaque");
599 glassLayers=1;record=sample(4,1,0,{},0);
600 Check(record.reason==AdViewability::Reason::Passing,"transparent windshield admits logo");
601 glassColor=0x40ffffff;record=sample(4,1,0,{},0);
602 Check(record.reason==AdViewability::Reason::Passing,"mostly transparent windshield admits logo");
603 glassColor=0x66ffffff;record=sample(4,1,0,{},0);
604 Check(record.reason==AdViewability::Reason::Appearance && record.last.clearPixels==0,"heavy glass opacity blocks clarity");
605 glassColor=0xffffffff;record=sample(4,1,0,{},0);
606 Check(record.reason==AdViewability::Reason::Obstructed && record.last.visiblePixels==0,"opaque glass marks obstruct logo");
607 glassLayers=2;glassColor=0x33ffffff;record=sample(4,1,0,{},0);
608 Check(record.reason==AdViewability::Reason::Appearance,"two glass layers compound their opacity");
609 glassColor=0x19ffffff;record=sample(5,1,0,{},0);
610 Check(record.reason==AdViewability::Reason::Passing,"two clear glass layers preserve opportunity to see");
611 glassLayers=0;
612 record=sample(4,1,0,{{0,0,.51f,1}},0);Check(record.reason==AdViewability::Reason::Obstructed,"UI majority blocks qualification");
613 record=sample(4,.1f,0,{},0);Check(record.last.visiblePixels==0,"opaque depth obstruction");
614 record=sample(4,1,3,{},0);Check(record.last.visiblePixels==0,"cockpit stencil occlusion");
615 record=sample(4,1,0,{},.8f);Check(record.reason==AdViewability::Reason::Appearance,"cloud opacity blocks qualification");
616 parameters.Texture("OverlayMap",sparse.Get());record=sample(4,1,0,{},0);
617 Check(record.reason==AdViewability::Reason::Passing && record.last.referencePixels<27000 &&
618 record.last.referencePixels==record.last.visiblePixels,"transparent padding excluded from visibility denominator");
619 parameters.Texture("OverlayMap",transparent.Get());record=sample(4,1,0,{},0);
620 Check(record.last.clearPixels==0,"transparent overlay earns no clear pixels");
621 parameters.Texture("OverlayMap",white.Get());parameters.Set("ambient",XMFLOAT4(0,0,0,100));
622 record=sample(4,1,0,{},0);Check(record.last.clearPixels==0,"unlit logo earns no clear pixels");
623 parameters.Set("ambient",XMFLOAT4(1,1,1,100));
624 record=sample(4,1,0,{},0,false);Check(record.reason==AdViewability::Reason::Unmeasured,"unmeasured weather not credited");
625 XMStoreFloat4x4(&world,XMMatrixRotationZ(XM_PI));record=sample(4,1,0,{},0);
626 Check(record.reason==AdViewability::Reason::Angle,"upside-down creative rejected");
627 XMStoreFloat4x4(&world,XMMatrixScaling(-1,1,1));record=sample(4,1,0,{},0);
628 Check(record.reason==AdViewability::Reason::Angle && record.last.mirrored,"mirrored raster rejected");
629 world=identity;
630 record=sample(4,1,0,{},0,true,"help tooltip");
631 Check(record.reason==AdViewability::Reason::Inactive && !record.last.active,
632 "actually drawn tooltip excludes exposure");
633 Check(diagnostic.Blocker()=="help tooltip","specific UI blocker exposed");
634 record=sample(4,1,0,{},0);
635 Check(record.reason==AdViewability::Reason::Passing && diagnostic.Blocker().empty(),
636 "absent UI permits measurement and clears blocker");
637 for(int i=0;i<5;++i)record=sample(4,1,0,{},0);
638 Check(record.continuousSeconds>=1,"uncovered view can accumulate one second");
639 // A tooltip can appear between 200ms observations. Its draw still
640 // interrupts continuity even on a frame without a GPU sample.
641 clock+=.01;diagnostic.BeginFrame(device,clock,true);
642 Check(!diagnostic.Collecting(),"fixture is between scheduled observations");
643 diagnostic.FinishScene(device,true,{},"help tooltip");
644 auto whitePlacement=placement;whitePlacement.creativeHash=warm(white.Get()).hash;
645 Check(diagnostic.Results().Records().at(whitePlacement).continuousSeconds==0,
646 "UI appearance between polls immediately interrupts exposure");
647 Check(diagnostic.Blocker()=="help tooltip","non-sampled UI blocker visible");
648 clock+=.01;diagnostic.BeginFrame(device,clock,true);
649 diagnostic.FinishScene(device,true,{});
650 record=sample(4,1,0,{},0);
651 Check(record.continuousSeconds==0,"exposure cannot bridge a covered frame");
652 clock+=.21;diagnostic.BeginFrame(device,clock,false,"game not in foreground");
653 diagnostic.FinishScene(device,true,{});
654 Check(!diagnostic.Collecting() && diagnostic.Blocker()=="game not in foreground",
655 "specific inactive-view blocker preserved");
656 record=sample(4,1,0,{},0);
657 Check(record.reason==AdViewability::Reason::Passing && record.continuousSeconds==0,
658 "active view resumes with a new streak");
659 auto rhVertices=std::vector<AdDiagnostics11::Vertex>(std::begin(vertices),std::end(vertices));
660 for(auto& vertex:rhVertices){vertex.position.z=-.5f;vertex.normal.z=1;}
661 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,rhVertices.data(),sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
662 XMStoreFloat4x4(&projection,XMMatrixOrthographicRH(2,2,.001f,2));
663 record=sample(4,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"right-handed camera facing direction");
664 // Real vehicle views use perspective, kilometer units and a steep,
665 // nearly coplanar surface, rather than the identity fixture above.
666 XMStoreFloat4x4(&projection,XMMatrixPerspectiveFovRH(1.f,320.f/240,.001f,384));
667 for(unsigned pass:{4u,5u})for(unsigned pose=0;pose<16;++pose)
668 {
669 XMStoreFloat4x4(&world,XMMatrixScaling(.01f,.01f,.01f)*XMMatrixRotationX(.43f)*
670 XMMatrixRotationY(-.17f)*XMMatrixRotationZ(-.22f)*
671 XMMatrixTranslation(float(pose)*.000031f,-.004f,-.04f));
672 record=sample(pass,1,0,{},0);
673 const double visible=record.last.visiblePixels/record.last.referencePixels;
674 if(visible<.995)std::cout<<samples<<"x perspective pass="<<pass<<" pose="<<pose<<" visible="<<visible<<'\n';
675 Check(visible>.995,"unobstructed perspective vehicle logo remains fully visible");
676 }
677 world=identity;XMStoreFloat4x4(&projection,XMMatrixOrthographicRH(2,2,.001f,2));
678 // Create resets the source revision; the cache must also track resource identity.
679 NativeUiTest11::HR(mesh.Create(device.Native(),sizeof(vertices),false));
680 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,rhVertices.data(),sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
681 record=sample(4,1,0,{},0);Check(record.reason==AdViewability::Reason::Passing,"recreated geometry invalidates cached logo surface");
682 const auto oldCount=record.observations;
683 clock+=.21;diagnostic.BeginFrame(device,clock,true);
684 diagnostic.RegisterDraw(device,placement,1,mesh,0,2,4,world,identity,projection,.5f);
685 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
686 Read(device,fixture.host.Device().SceneColor(),4); // Fixture-only GPU fence, never used in production.
687 diagnostic.SyncPlacement(1,11,"replacement");diagnostic.BeginFrame(device,clock+.01,true);
688 Check(diagnostic.Results().Records().at(whitePlacement).observations==oldCount,"pending result ignored after slot/creative replacement");
689 diagnostic.SetEnabled(false);
690 // Each half covers <1.5%; a continuous creative crossing a shallow
691 // panel crease covers >1.5% and must be assessed as one placement.
692 const AdDiagnostics11::Vertex folded[]={
693 {{-.14f,.14f,.53f},{0,0,-1},{0,0},{0,0}},{{0,.14f,.5f},{0,0,-1},{.5f,0},{.5f,0}},{{-.14f,-.14f,.53f},{0,0,-1},{0,1},{0,1}},
694 {{-.14f,-.14f,.53f},{0,0,-1},{0,1},{0,1}},{{0,.14f,.5f},{0,0,-1},{.5f,0},{.5f,0}},{{0,-.14f,.5f},{0,0,-1},{.5f,1},{.5f,1}},
695 {{0,.14f,.5f},{0,0,-1},{.5f,0},{.5f,0}},{{.14f,.14f,.53f},{0,0,-1},{1,0},{1,0}},{{0,-.14f,.5f},{0,0,-1},{.5f,1},{.5f,1}},
696 {{0,-.14f,.5f},{0,0,-1},{.5f,1},{.5f,1}},{{.14f,.14f,.53f},{0,0,-1},{1,0},{1,0}},{{.14f,-.14f,.53f},{0,0,-1},{1,1},{1,1}}};
697 NativeUiTest11::HR(mesh.Create(device.Native(),sizeof(folded),false));
698 NativeUiTest11::HR(mesh.Lock(0,sizeof(folded),&destination));memcpy(destination,folded,sizeof(folded));NativeUiTest11::HR(mesh.Unlock());
699 world=projection=identity;diagnostic.SetEnabled(true);diagnostic.SyncPlacement(1,10,"fixture");
700 clock+=.21;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
701 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
702 parameters.Set("matWorld",identity);parameters.Set("matWorldViewProj",identity);draws.Material(4);
703 NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,4));
704 diagnostic.RegisterDraw(device,placement,1,mesh,0,4,4,world,identity,projection,.5f);
705 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
706 Read(device,fixture.host.Device().SceneColor(),4);diagnostic.BeginFrame(device,clock+.01,true);
707 Check(diagnostic.Results().Records().size()==1,"connected UV facets form one creative");
708 const auto& combined=diagnostic.Results().Records().begin()->second;
709 Check(combined.reason==AdViewability::Reason::Passing && combined.last.clearPixels/combined.last.screenPixels>.015,
710 "combined creative passes even though individual facets are below 1.5%");
711 diagnostic.SetEnabled(false);
712 // Repeating the whole logo on each panel must remain two placements.
713 auto repeated=std::vector<AdDiagnostics11::Vertex>(std::begin(folded),std::end(folded));
714 for(size_t i=0;i<repeated.size();++i)repeated[i].logo.x=i<6 ? repeated[i].logo.x*2 : (repeated[i].logo.x-.5f)*2;
715 NativeUiTest11::HR(mesh.Lock(0,sizeof(folded),&destination));memcpy(destination,repeated.data(),sizeof(folded));NativeUiTest11::HR(mesh.Unlock());
716 diagnostic.SetEnabled(true);clock+=.21;diagnostic.BeginFrame(device,clock,true);
717 diagnostic.RegisterDraw(device,placement,1,mesh,0,4,4,world,identity,projection,.5f);
718 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
719 Read(device,fixture.host.Device().SceneColor(),4);diagnostic.BeginFrame(device,clock+.01,true);
720 Check(diagnostic.Results().Records().size()==2,"two repeated logos are not summed into one creative");
721 for(const auto& row:diagnostic.Results().Records())Check(row.second.reason==AdViewability::Reason::TooSmall,"separate small logos fail independently");
722 diagnostic.SetEnabled(false);
723 // A small steep piece is excluded from qualified pixels, without vetoing
724 // the readable majority. The reverse distribution must fail the angle gate.
725 const auto panelTest=[&](float left,float crease,float right,float z,float farZ,bool passes)
726 {
727 const AdDiagnostics11::Vertex panels[]={
728 {{left,.4f,z},{0,0,-1},{0,0},{0,0}},{{crease,.4f,z},{0,0,-1},{.8f,0},{.8f,0}},{{left,-.4f,z},{0,0,-1},{0,1},{0,1}},
729 {{left,-.4f,z},{0,0,-1},{0,1},{0,1}},{{crease,.4f,z},{0,0,-1},{.8f,0},{.8f,0}},{{crease,-.4f,z},{0,0,-1},{.8f,1},{.8f,1}},
730 {{crease,.4f,z},{0,0,-1},{.8f,0},{.8f,0}},{{right,.4f,farZ},{0,0,-1},{1,0},{1,0}},{{crease,-.4f,z},{0,0,-1},{.8f,1},{.8f,1}},
731 {{crease,-.4f,z},{0,0,-1},{.8f,1},{.8f,1}},{{right,.4f,farZ},{0,0,-1},{1,0},{1,0}},{{right,-.4f,farZ},{0,0,-1},{1,1},{1,1}}};
732 NativeUiTest11::HR(mesh.Lock(0,sizeof(panels),&destination));memcpy(destination,panels,sizeof(panels));NativeUiTest11::HR(mesh.Unlock());
733 diagnostic.SetEnabled(true);clock+=.21;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
734 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
735 draws.Material(4);NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,4));
736 diagnostic.RegisterDraw(device,placement,1,mesh,0,4,4,world,identity,projection,.5f);
737 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
738 Read(device,fixture.host.Device().SceneColor(),4);diagnostic.BeginFrame(device,clock+.01,true);
739 Check(diagnostic.Results().Records().size()==1,"angular fixture remains one connected creative");
740 const auto& result=diagnostic.Results().Records().begin()->second;
741 Check(result.last.visiblePixels/result.last.referencePixels>.995,"angular fixture has no physical obstruction");
742 Check(result.last.anglePixels>0 && result.last.anglePixels<result.last.visiblePixels,"angular query excludes the steep facet only");
743 Check(result.reason==(passes ? AdViewability::Reason::Passing : AdViewability::Reason::Angle),"angular qualification uses creative pixel proportion");
744 diagnostic.SetEnabled(false);
745 };
746 panelTest(-.6f,.3f,.5f,.8f,.95f,true);
747 panelTest(-.4f,-.1f,.5f,.3f,.9f,false);
748 auto back=std::vector<AdDiagnostics11::Vertex>(std::begin(vertices),std::end(vertices));
749 for(auto& v:back)v.normal.z=1;
750 NativeUiTest11::HR(mesh.Lock(0,sizeof(vertices),&destination));memcpy(destination,back.data(),sizeof(vertices));NativeUiTest11::HR(mesh.Unlock());
751 diagnostic.SetEnabled(true);clock+=.21;diagnostic.BeginFrame(device,clock,true);
752 diagnostic.RegisterDraw(device,placement,1,mesh,0,2,4,world,identity,projection,.5f);
753 const auto& hidden=diagnostic.Results().Records().begin()->second;
754 Check(hidden.reason==AdViewability::Reason::BackFacing && hidden.last.backFacing,"opposite side is classified before GPU queries");
755 Check(diagnostic.CaptureScene(device)==S_FALSE,"back-facing-only scene does not copy depth or run queries");
756 diagnostic.SetEnabled(false);
757 std::vector<AdDiagnostics11::Vertex> corrugated;
758 for(unsigned strip=0;strip<128;++strip)
759 {
760 const float u=float(strip)/128,v=float(strip+1)/128;
761 const float za=.7f+(strip%2)*.004f,zb=.7f+((strip+1)%2)*.004f;
762 const AdDiagnostics11::Vertex a{{u-.5f,.3f,za},{0,0,-1},{u,0},{u,0}},b{{v-.5f,.3f,zb},{0,0,-1},{v,0},{v,0}},
763 c{{u-.5f,-.3f,za},{0,0,-1},{u,1},{u,1}},d{{v-.5f,-.3f,zb},{0,0,-1},{v,1},{v,1}};
764 corrugated.insert(corrugated.end(),{a,b,c,c,b,d});
765 }
766 const unsigned budgetBytes=unsigned(corrugated.size()*sizeof(AdDiagnostics11::Vertex));
767 NativeUiTest11::HR(mesh.Create(device.Native(),budgetBytes,false));
768 NativeUiTest11::HR(mesh.Lock(0,budgetBytes,&destination));memcpy(destination,corrugated.data(),budgetBytes);NativeUiTest11::HR(mesh.Unlock());
769 diagnostic.SetEnabled(true);clock+=.21;diagnostic.BeginFrame(device,clock,true);draws.BindScene();
770 context->ClearDepthStencilView(fixture.host.Device().Depth().WriteView(),D3D11_CLEAR_DEPTH|D3D11_CLEAR_STENCIL,1,0);
771 NativeUiTest11::HR(draws.Draw(mesh,layout,Primitive11::Triangles,0,unsigned(corrugated.size()/3)));
772 diagnostic.RegisterDraw(device,placement,1,mesh,0,unsigned(corrugated.size()/3),4,world,identity,projection,.5f);
773 NativeUiTest11::HR(diagnostic.CaptureScene(device));diagnostic.FinishScene(device,true,{});
774 Check(diagnostic.Results().Records().size()==1,"corrugated fixture is one connected creative");
775 Check(diagnostic.Results().Records().begin()->second.reason==AdViewability::Reason::Unmeasured && diagnostic.Dropped()==1,
776 "excessive facet draw work is bounded and unmeasured");
777 diagnostic.SetEnabled(false);fixture.DebugClean();
778 }
779}
780int main()
781{
782 try{Model();AnimatedMetadata();OverlayBounds();for(unsigned samples:{1u,2u,4u,8u}){GPU(samples);Billboards(samples);CloudExport(samples);}std::cout<<checks<<" ad viewability checks passed\n";return 0;}
783 catch(const std::exception& error){std::cerr<<"FAIL: "<<error.what()<<"\n";return 1;}
784}
HRESULT(WINAPI *CUniBuffer::_ScriptApplyDigitSubstitution)(const SCRIPT_DIGITSUBSTITUTE *
SCRIPT_CONTROL SCRIPT_STATE const void DWORD
std::map< CreativeKey, CreativeSummary > Summaries() const
void Interrupt(double now, Reason reason)
const std::map< Placement, Record > & Records() const
bool Observe(const Placement &key, const Observation &value)
void RegisterSignDraw(RenderDevice &device, const AdViewability::Placement &placement, const CreativeMetadata *metadata, const std::weak_ptr< void > &lifetime, unsigned animationFrame, unsigned animationFrames, const AnimatedAdMetadata::Summary &average, Geometry11 &geometry, unsigned first, unsigned count, unsigned material, const DirectX::XMFLOAT4X4 &world, const DirectX::XMFLOAT4X4 &view, const DirectX::XMFLOAT4X4 &projection, float distanceKm)
const AdViewability::Tracker & Results() const
void SetAnimatedInventory(bool value)
void DrawOverlay(RenderFont *font, RenderSprite *sprite, unsigned width, unsigned height, std::vector< RECT > *drawnBounds=nullptr)
void SyncPlacement(unsigned slot, uint64_t entity, const std::string &creative)
void RegisterDraw(RenderDevice &device, const AdViewability::Placement &placement, unsigned slot, Geometry11 &geometry, unsigned first, unsigned count, unsigned material, const DirectX::XMFLOAT4X4 &world, const DirectX::XMFLOAT4X4 &view, const DirectX::XMFLOAT4X4 &projection, float distanceKm)
void WetGlassResult(HRESULT result)
const std::string & Blocker() const
void BeginFrame(RenderDevice &device, double now, bool eligible, const char *blocker=nullptr)
void RegisterOverlayDraw(RenderDevice &device, Geometry11 &geometry, unsigned first, unsigned count, unsigned material)
void SetOverlayVisible(bool value)
ID3D11RenderTargetView * CloudOpacityTarget() const
ID3D11RenderTargetView * WetGlassExclusionTarget() const
static constexpr unsigned MaximumCandidates
void FinishScene(RenderDevice &device, bool weatherMeasured, const std::vector< DirectX::XMFLOAT4 > &uiRects, const char *uiBlocker=nullptr)
const CreativeMetadata * PrepareCreative(RenderDevice &device, ID3D11ShaderResourceView *view)
HRESULT CaptureScene(RenderDevice &device)
void Initialize(unsigned width, unsigned height, const std::vector< uint64_t > &ends, uint64_t hash)
const AdCreativeMetadata * Frame(size_t index) const
unsigned Analyze(size_t index, const std::vector< uint32_t > &canvas, unsigned budget, bool allowSnapshot)
void SetAdOpacityTarget(ID3D11RenderTargetView *target)
Definition CloudPass11.h:49
bool AdOpacityWritten() const
Definition CloudPass11.h:50
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 &params, 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))
void SetLightningEnabled(bool value)
HRESULT Initialize(ID3D11Device *device, const std::filesystem::path &shaderDirectory={})
const D3D11_VIEWPORT & Viewport() const
HRESULT Create(ID3D11Device *device, UINT bytes, bool dynamic, bool index=false, bool indices32=false)
HRESULT Lock(UINT offset, UINT size, void **destination, bool readOnly=false, bool discard=false)
DrawContext11 & Draws()
ID3D11DeviceContext * Context()
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 AddGlass(int component, const Vertex *vertices, size_t count)
Reason Evaluate(const Observation &value)
const char * Name(Reason reason)
Definition DDS.h:24
HRESULT CreateFontW(RenderDevice *owner, INT height, UINT width, UINT weight, UINT mipLevels, BOOL italic, DWORD charset, DWORD precision, DWORD quality, DWORD pitch, const wchar_t *face, RenderFont **result)
HRESULT CreateSprite(RenderDevice *owner, RenderSprite **result)