MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / create

Method create

ogsr_engine/Layers/xrRender/SH_RT.cpp:24–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22}
23
24void CRT::create(LPCSTR Name, u32 w, u32 h, D3DFORMAT f, u32 SampleCount)
25{
26 if (pSurface)
27 return;
28
29 R_ASSERT(HW.pDevice && Name && Name[0] && w && h);
30 _order = CPU::GetCLK(); // RDEVICE.GetTimerGlobal()->GetElapsed_clk();
31
32 HRESULT _hr;
33
34 dwWidth = w;
35 dwHeight = h;
36 fmt = f;
37
38 // Get caps
39 D3DCAPS9 caps;
40 R_CHK(HW.pDevice->GetDeviceCaps(&caps));
41
42 // Pow2
43 if (!btwIsPow2(w) || !btwIsPow2(h))
44 {
45 if (!HW.Caps.raster.bNonPow2)
46 return;
47 }
48
49 // Check width-and-height of render target surface
50 if (w > caps.MaxTextureWidth)
51 return;
52 if (h > caps.MaxTextureHeight)
53 return;
54
55 // Select usage
56 u32 usage = 0;
57 if (D3DFMT_D24X8 == fmt)
58 usage = D3DUSAGE_DEPTHSTENCIL;
59 else if (D3DFMT_D24S8 == fmt)
60 usage = D3DUSAGE_DEPTHSTENCIL;
61 else if (D3DFMT_D15S1 == fmt)
62 usage = D3DUSAGE_DEPTHSTENCIL;
63 else if (D3DFMT_D16 == fmt)
64 usage = D3DUSAGE_DEPTHSTENCIL;
65 else if (D3DFMT_D16_LOCKABLE == fmt)
66 usage = D3DUSAGE_DEPTHSTENCIL;
67 else if ((D3DFORMAT)MAKEFOURCC('D', 'F', '2', '4') == fmt)
68 usage = D3DUSAGE_DEPTHSTENCIL;
69 else
70 usage = D3DUSAGE_RENDERTARGET;
71
72 // Validate render-target usage
73 _hr = HW.pD3D->CheckDeviceFormat(HW.DevAdapter, HW.DevT, HW.Caps.fTarget, usage, D3DRTYPE_TEXTURE, f);
74 if (FAILED(_hr))
75 return;
76
77 // Try to create texture/surface
78 DEV->Evict();
79 _hr = HW.pDevice->CreateTexture(w, h, 1, usage, f, D3DPOOL_DEFAULT, &pSurface, NULL);
80 HW.stats_manager.increment_stats_rtarget(pSurface);
81

Callers 15

OnDeviceCreateMethod · 0.45
FBasicVisual.cppFile · 0.45
_Load_hwMethod · 0.45
uber_defferFunction · 0.45
uber_shadowFunction · 0.45
CreateShaderMethod · 0.45
OnDeviceCreateMethod · 0.45
LoadMethod · 0.45
InitializeDebugDrawMethod · 0.45
CWallmarksEngineMethod · 0.45
CreateShaderMethod · 0.45

Calls 7

GetCLKFunction · 0.85
btwIsPow2Function · 0.85
MsgFunction · 0.85
_CreateTextureMethod · 0.45
surface_setMethod · 0.45
_CreateRTMethod · 0.45

Tested by

no test coverage detected