PixarAnimationStudios / OpenSubdiv

An Open-Source subdivision surface library.
graphics.pixar.com/opensubdiv
Other
2.88k stars 558 forks source link

D3DReflect returns E_NOINTERFACE #775

Open manuelk opened 8 years ago

manuelk commented 8 years ago

The following sanity check can be problematic: https://github.com/PixarAnimationStudios/OpenSubdiv/blob/master/opensubdiv/osd/d3d11ComputeEvaluator.cpp#L258

If a client app links against another version of the DX SDK than OSD was linked with (ex. June 2010 and Windows Kit ), then D3DReflect can return a E_NOINTERFACE error, with a null pointer.

Suggest modifying to something like this:

    ID3D11ShaderReflection *reflector;
    hr = D3DReflect(computeShaderBuffer->GetBufferPointer(),
        computeShaderBuffer->GetBufferSize(),
            IID_ID3D11ShaderReflection, (void**) &reflector);
    if (SUCCEEDED(hr)) {
        assert(reflector);
        if (reflector->GetNumInterfaceSlots() != 1) {
            return false;
        }
        reflector->Release();
    } else {
        // warn error
    }
gyakoo commented 7 years ago

A dirty workaround iif this issue is blocking (not the final solution) may be trying get the winSDK interface by specifying it directly?

// declare this out of a function
EXTERN_C CONST DECLSPEC_SELECTANY GUID IID_ID3D11ShaderReflection_WINSDK = 
{ 0x8d536ca1, 0x0cca, 0x4956, 0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84 }

hr = D3DReflect(computeShaderBuffer->GetBufferPointer(), computeShaderBuffer->GetBufferSize(),            IID_ID3D11ShaderReflection, (void**) &reflector);

// insert this 
if (hr==E_NOINTERFACE || hr==E_INVALIDARG)
{
  // IID changes from version to version. Tries the winsdk hardcoded one.
  hr = D3DReflect(computeShaderBuffer->GetBufferPointer(),  computeShaderBuffer->GetBufferSize(),
            IID_ID3D11ShaderReflection_WINSDK, (void**) &reflector);
}

// original code 
jtran56 commented 6 years ago

Filed as internal issue #151667.