none
problems with D3DX10CreateEffectFromFileW and the ID3D10Blob interface RRS feed

  • Question

  • i have successfully translated the DirectX 10 sample (named Tutorial01 in the SDK) from native C++ to the vb.NET;

    the problem becomes with the sample N°2 (Tutorial02) , in this line:

     MsgBox(D3DX10CreateEffectFromFileW("C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D10\Tutorials\Tutorial02 - Copie\Tutorial02.fx",
                                              Nothing,
                                              Nothing,
                                             "fx_4_0",
                                              D3D10_SHADER_ENABLE_STRICTNESS Or D3D10_SHADER_DEBUG,
                                                0,
                                              device,
                                                Nothing,
                                              Nothing,
                                                eff,
                                                err,
                                                Nothing))

    the return value is -2005530516, which means D3DERR_INVALIDCALL (DxErr look up);

    the err is a valid pointer (intptr), converted to an interface of type ID3D10Blob correctly using the function Marshal.GetTypedObjectForIUnknown();

    this interface contains exactly 02 members (the function GetBufferSize() and the function GetBufferPointer()), these functions returns accessviolationexception;

    so this is my code :

    <DllImport("C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Redist\d3dx10_43.dll",
                   EntryPoint:="D3DX10CreateEffectFromFileW",
                   CallingConvention:=CallingConvention.StdCall)>
        Public Shared Function D3DX10CreateEffectFromFileW(
             <MarshalAs(UnmanagedType.LPWStr)> ByVal pFileName As String,
             ByVal pDefines As IntPtr,
             ByVal pInclude As IntPtr,
           <MarshalAs(UnmanagedType.LPWStr)> ByVal pProfile As String,
             ByVal HLSLFlags As Integer,
             ByVal FXFlags As Integer,
             ByVal pDevice As ID3D10Device,
             ByVal pEffectPool As IntPtr,
             ByVal pPump As IntPtr,
             ByRef ppEffect As IntPtr,
             ByRef ppErrors As IntPtr,
             ByVal pHResult As IntPtr) As Integer

        End Function

    the converted id3d10blob interface

    <ComImport()>
        <Guid("8BA5FB08-5195-40e2-AC58-0D989C3A0102")>
        <InterfaceType(ComInterfaceType.InterfaceIsDual)>
        Interface ID3D10Blob
            Inherits IUnknown


            <PreserveSig()>
            Function GetBufferPointer() As IntPtr


            <PreserveSig()>
            Function GetBufferSize() As UInt32




        End Interface

    remark: i have built a native C++ DLL that acts as a bridge between the vb.NET and the directx sample (Tutorial02)

    , it gives me correct answers with the D3DX10CreateEffectFromFileW and the GetBufferPointer()/GetBufferSize() functions=

    the return value from D3DX10CreateEffectFromFileW = 0 and err = nullptr.

    Thursday, July 26, 2018 8:20 PM

All replies

  • resolved for the function D3DX10CreateEffectFromFileW ===> the unmanaged type of the pProfile must be LPStr not LPWStr.

    but what about the GetBufferPointer()/GetBufferSize() functions?

    Thursday, July 26, 2018 9:35 PM
  • Hi AbdEllah,

    Thanks for posting here.

    >but what about the GetBufferPointer()/GetBufferSize() functions?

    What's the problem you encountered related to GetBufferPointer()/GetBufferSize() functions?

    Best Regards,

    Charles


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 30, 2018 6:39 AM