Render to a Video output #_#

I know it could be difficult, but I am requested to Render a 3D scene with alpha to a video output, that request data transfer from the RenderTarget Surface to the DirectDraw Suface with Overlay. the problem is.

Direct3D Surfaces and DirectDraw Surfaces are not mixable. I know that. so I have try to lock both of the surface and do a memcpy.

every one knows this is a large cost to the CPU time.

so if I can direct Direct3D to render to a shared buffer binded to a DirectDraw Surface, It will save a lot of time.

so if Anybody knows how, I'am on my knees




Answer this question

Render to a Video output #_#

  • eajam

    Will, I have read your thread, but unlike you, I programme with C++, if I use managed functions in my part of the programme it will request changes to be made every other programme. so I have to pass, however I looked all over previous released DXSDK samples, find I coud possiable fake an Direct3dSurface9 interface like

    class DidcvDirect3DSurface9Clone : public IUnknown
    {
    private:
    int m_iRefCount;
    BYTE *m_pData;
    D3DSURFACE_DESC m_Desc;

    public:
    DidcvDirect3DSurface9Clone() : m_pData( NULL ), m_iRefCount( 1 ) { }
    ~DidcvDirect3DSurface9Clone() { delete[] m_pData; }

    public:
    // IUnknown methods
    STDMETHOD( QueryInterface )( REFIID riid, VOID **ppvObj ) { return E_NOINTERFACE; }
    STDMETHOD_( ULONG,AddRef )() { return ++m_iRefCount; }
    STDMETHOD_( ULONG,Release )()
    {
    if( !--m_iRefCount )
    {
    delete this;
    return 0;
    }
    return m_iRefCount;
    }

    // IDirect3DResource9 methods
    STDMETHOD( GetDevice )( IDirect3DDevice9 **ppDevice ) { return E_FAIL; }
    STDMETHOD( SetPrivateData )( REFGUID riid, CONST VOID *pvData, DWORD cbData, DWORD dwFlags ) { return E_FAIL; }
    STDMETHOD( GetPrivateData )( REFGUID riid, VOID* pvData, DWORD *pcbData ) { return E_FAIL; }
    STDMETHOD( FreePrivateData )( REFGUID riid ) { return E_FAIL; }
    STDMETHOD( SetPriority )( DWORD PriorityNew ) { return E_FAIL; }
    STDMETHOD_( DWORD, GetPriority )() { return 0; }
    STDMETHOD( PreLoad )() { return E_FAIL; }
    STDMETHOD( GetType )() { return E_FAIL; }

    // IDirect3DSurface9 methods
    STDMETHOD( GetContainer )( REFIID riid, void **ppContainer ) { return E_FAIL; }
    STDMETHOD_( D3DSURFACE_DESC, GetDesc )() { return m_Desc; }
    STDMETHOD( LockRect )( D3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD dwFlags )
    {
    // Assume the entire surface is being locked.
    pLockedRect->Pitch = m_Desc.Width * 4;
    pLockedRect->pBits = m_pData;
    return S_OK;
    }
    STDMETHOD( UnlockRect )() { return S_OK; }
    STDMETHOD( GetDC )() { return E_FAIL; }
    STDMETHOD( ReleaseDC )() { return E_FAIL; }

    BOOL Create( int iWidth, int iHeight )
    {
    m_pData = new BYTE[iWidth * iHeight * 4];
    if( !m_pData ) return FALSE;

    m_Desc.Format = D3DFMT_A8R8G8B8;
    m_Desc.Type = D3DRTYPE_SURFACE;
    m_Desc.Usage = 0;
    m_Desc.Pool = D3DPOOL_SYSTEMMEM;
    m_Desc.MultiSampleType = D3DMULTISAMPLE_NONE;
    m_Desc.MultiSampleQuality = 0;
    m_Desc.Width = iWidth;
    m_Desc.Height = iHeight;
    return TRUE;
    }
    };

    the only thing I'am going to do is to make modifications to this and enable the Surface to Surface ops, problem is I don't know data structures within this Interface



  • rikidude

    First off. I know little about directx and nothing about direct draw, but odly enough it seems we have the excact same task and the same problems. That is... now my problems have gone. That is thanks to the replies I got during the last week here. I suggest that you look at the threads that i created about getting rendered data back from the gfxCard.

    For me the trick was to get a hold of a graphics stream from a locked surface and then access the internaldatapointer to copy the data from the surface to my target. The target was just a pointer in my case, but I assume you could get a pointer to the data in a directxDraw surface the same way you get one to the rendered data.

    Out of curiosity, what kind of videocard are you using, and do your alpha values in the backbuffer actualy get set to a value other than 0


  • Ejan

    As I can see,

    BYTE *m_pData

    is video buffer of surface. Can You tell me, how I can get it in Direct3DRM

    (Sorry 4my English)


  • Render to a Video output #_#