Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi TCustomDX10Context.CheckDevice中的异常清除接口_Delphi_Delphi Xe3 - Fatal编程技术网

Delphi TCustomDX10Context.CheckDevice中的异常清除接口

Delphi TCustomDX10Context.CheckDevice中的异常清除接口,delphi,delphi-xe3,Delphi,Delphi Xe3,这是对我的建议的后续行动。我意识到我自己在这篇文章中把问题缩小的很糟糕,道歉。我现在对正在发生的事情有了一个非常具体的想法,所以希望有人能够把我推向正确的方向 SSCCE: program SSCCE; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, FMX.Context.DX10; begin try TCustomDX10Context.CheckDevice; WriteLn('Everything we

这是对我的建议的后续行动。我意识到我自己在这篇文章中把问题缩小的很糟糕,道歉。我现在对正在发生的事情有了一个非常具体的想法,所以希望有人能够把我推向正确的方向

SSCCE:

program SSCCE;

{$APPTYPE CONSOLE}

{$R *.res}

uses System.SysUtils, FMX.Context.DX10;

begin
  try
    TCustomDX10Context.CheckDevice;
    WriteLn('Everything went fine, guess we have to dig deeper.');
  except
    on E: Exception do Writeln(E.ClassName, ': ', E.Message);
  end;
  Write('Press enter to exit.');
  ReadLn;
end.
CheckDevice在
@IntfClear
中产生访问冲突。这是FMX.Context.DX10中CheckDevice的代码:

class function TCustomDX10Context.CheckDevice: TD3D10DriverType;
var
  dx10lib: THandle;
  g_pd3dDevice: ID3D10Device1;
begin
  if not FChecked then
  begin
    FChecked := True;
    FDriverType := D3D10_DRIVER_TYPE_NULL;
    dx10lib := LoadLibrary(D3D10_1_dll);
    if dx10lib <> 0 then
    try
      if GlobalUseDX10Software then
        FDriverType := D3D10_DRIVER_TYPE_WARP
      else begin
        if GlobalUseDX10 then
        begin
          { check for support for DX10 hardware }
          SaveClearFPUState;
          try
            if GetProcAddress(dx10lib, 'D3D10CreateDevice1') <> nil then
            begin
              if Succeeded(D3D10CreateDevice1(nil, D3D10_DRIVER_TYPE_HARDWARE, 0, D3D10_CREATE_DEVICE_BGRA_SUPPORT, D3D10_FEATURE_LEVEL_10_1, D3D10_1_SDK_VERSION, g_pd3dDevice)) then
              begin
                g_pd3dDevice := nil;
                FDriverType := D3D10_DRIVER_TYPE_HARDWARE;
              end;
            end;
          finally
            RestoreFPUState;
          end;
        end;
      end;
    finally
      FreeLibrary(dx10Lib);
    end;
  end;
  Result := FDriverType;
end;
314是在成功的API调用后,
g_pd3dDevice
被置零的行,注释该行输出导致在函数结束时超出范围后清除接口时发生AV。这可能是由于D3D10CreateDevice1返回无效设备造成的,还是发生了其他情况?此外,由于AV出现在
@IntfClear
中,我不认为我可以只尝试它,然后吃掉它,即使这两种方式都可能不会有太多好处

0040e028 +010 <...>.exe System            191  +0 @IntfClear
0096a360 +0d0 <...>.exe FMX.Context.DX10  314 +20 TCustomDX10Context.CheckDevice
009759a1 +005 <...>.exe FMX.Canvas.D2D            RegisterCanvasClasses
009900b4 +000 <...>.exe FMX.Platform.Win 3404  +0 TPlatformWin.RegisterCanvasClasses
009d575a +056 <...>.exe FMX.Types                 TCanvasManager.GetDefaultCanvas
009d56f2 +00e <...>.exe FMX.Types                 TCanvasManager.CreateFromWindow