Via een d3d9.dll proxy kan ik voor sommige dx9 games de direct3d calls afvangen. Ik wil in de render phase een stukje custom code uitvoeren, en dat lukt ook. Het doel is dat ik de frontbuffer in een texture prop en daar dan de mip-maps van laat genereren door de hardware. Alles lukt, behalve de auto generatie van de mipmap sublevels (tot 1x1 pixel), dat gaat mis. Dwz, de levelcount blijft 1.
M'n kaart support 100% auto-gen mipmap. Iemand een idee?
code:
M'n kaart support 100% auto-gen mipmap. Iemand een idee?
code:
C++: custom.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
| void CustomActions::Screenshot(void) { IDirect3DSurface9* frontbuf = NULL; D3DDISPLAYMODE dMode; volatile DWORD levelCount = 0; HRESULT res = S_OK; //Capture FrontBuffer to a (off-screen) Surface m_pDevice->GetDisplayMode(0, &dMode); res = m_pDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR); m_pDevice->CreateOffscreenPlainSurface(dMode.Width, dMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &frontbuf, NULL); //D3DFMT_A8R8G8B8 res = m_pDevice->GetFrontBufferData(0,frontbuf); if (res != D3D_OK) { frontbuf->Release(); return; } //Save the captured frontbuffer to an in-memory file LPD3DXBUFFER buf; res = D3DXSaveSurfaceToFileInMemory(&buf, D3DXIFF_DIB, frontbuf, NULL, NULL); //Create a Texture from the in-memory file and enable mip-map generation IDirect3DTexture9 * pMipMap = NULL; D3DXIMAGE_INFO imgInfo; res = D3DXCreateTextureFromFileInMemoryEx(m_pDevice, buf->GetBufferPointer(), buf->GetBufferSize(), dMode.Width, dMode.Height, 0 /* do all mipmap levels*/, D3DUSAGE_AUTOGENMIPMAP, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, D3DX_FILTER_LINEAR, D3DX_FILTER_LINEAR , 0xFF000000, &imgInfo, NULL, &pMipMap); if (res == D3D_OK) { pMipMap->AddDirtyRect(NULL); pMipMap->GenerateMipSubLevels(); //this should force mip-map generation levelCount = pMipMap->GetLevelCount(); //we would like this to be > 1 pMipMap->Release(); } frontbuf->Release(); } |
ASUS Commando | Core2Duo E6600 @ 3Ghz air-cooled | Geforce 8800GTX | Raid-0 | 4 GB DDR2-800