Hello,
i have video data in the system memory and want the graphic hardware to convert it in RGB data for usage as a texture. I plan to do the following:
First create a surface with DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY caps and YUY2 Pixelformat. Then i want to blit this surface a surface with YUY2 Pixelformat but with DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY caps. This surface is finally blitted to a RGB Surface with DDSCAPS_VIDEOMEMORY | DDSCAPS_TEXTURE caps. Here is my Problem: i can't create the DDSCAPS_SYSTEMMEMORY surface with YUY2 Pixelformat. The following code returns: E_NOTIMPL:
ZeroMemory(pddsd, sizeof(DDSURFACEDESC2));
pddsd->dwSize = sizeof(DDSURFACEDESC2);
pddsd->dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS | DDSD_LPSURFACE | DDSD_PITCH;
pddsd->ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
pddsd->lPitch = (DWORD) ceil((double)(nWidth * dwBPP) / 8.0);
pddsd->lpSurface = pMemoryPtr;
pddsd->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
pddsd->ddpfPixelFormat.dwFlags = DDPF_FOURCC | DDPF_YUV;
pddsd->ddpfPixelFormat.dwFourCC = MAKEFOURCC('Y','U','Y','2');
pddsd->ddpfPixelFormat.dwYUVBitCount = 16U;
pddsd->dwWidth = abs(nWidth);
pddsd->dwHeight= abs(nHeight);
return m_lpDDObj->CreateSurface(pddsd, ppRet, NULL);
Here are my questions:
Is the code above wrong?
Is there a faster way to copy and convert videodata from system memory to a ARGB 32 Texture?
Regards Ulrich