Exemple #1
0
  bool CreateHooks(const char *libName)
  {
    bool success = true;

    WrappedIDXGISwapChain3::RegisterD3DDeviceCallback(GetD3D12DeviceIfAlloc);

    // also require d3dcompiler_??.dll
    if(GetD3DCompiler() == NULL)
    {
      RDCERR("Failed to load d3dcompiler_??.dll - not inserting D3D12 hooks.");
      return false;
    }

    success &= CreateDevice.Initialize("D3D12CreateDevice", DLL_NAME, D3D12CreateDevice_hook);
    success &= GetDebugInterface.Initialize("D3D12GetDebugInterface", DLL_NAME,
                                            D3D12GetDebugInterface_hook);

    if(!success)
      return false;

    m_HasHooks = true;
    m_EnabledHooks = true;

    return true;
  }
Exemple #2
0
	bool CreateHooks(const char *libName)
	{
		bool success = true;

#if USE_MHOOK
		// require dxgi.dll hooked as well for proper operation
		if(GetModuleHandleA("dxgi.dll") == NULL)
		{
			RDCWARN("Failed to load dxgi.dll - not inserting D3D11 hooks.");
			return false;
		}
#endif

		// also require d3dcompiler_??.dll
		if(GetD3DCompiler() == NULL)
		{
			RDCERR("Failed to load d3dcompiler_??.dll - not inserting D3D11 hooks.");
			return false;
		}

		success &= CreateDevice.Initialize("D3D11CreateDevice", DLL_NAME, D3D11CreateDevice_hook);
		success &= CreateDeviceAndSwapChain.Initialize("D3D11CreateDeviceAndSwapChain", DLL_NAME, D3D11CreateDeviceAndSwapChain_hook);

		if(!success) return false;
		
#if USE_MHOOK
		// FRAPS compatibility. Save out the first 16 bytes (arbitrary number) of the 'real' function code.
		// this should be
		// jmp D3D11CreateDeviceAndSwapChain_hook
		// push r12 <- this is where our trampoline jumps back to
		// push r13
		//
		// FRAPS stomps over this with its own hook that we detect and handle later.
		void *hooked_func_ptr = GetProcAddress(GetModuleHandleA("d3d11.dll"), "D3D11CreateDeviceAndSwapChain");
		if(hooked_func_ptr == NULL) return false;
		memcpy(CreateDeviceAndSwapChain_ident, hooked_func_ptr, 16);
#endif

		m_HasHooks = true;
		m_EnabledHooks = true;

		return true;
	}
Exemple #3
0
	bool CreateHooks(const char *libName)
	{
		bool success = true;

		// also require d3dcompiler_??.dll
		if(GetD3DCompiler() == NULL)
		{
			RDCERR("Failed to load d3dcompiler_??.dll - not inserting D3D11 hooks.");
			return false;
		}

		success &= CreateDevice.Initialize("D3D11CreateDevice", DLL_NAME, D3D11CreateDevice_hook);
		success &= CreateDeviceAndSwapChain.Initialize("D3D11CreateDeviceAndSwapChain", DLL_NAME, D3D11CreateDeviceAndSwapChain_hook);

		if(!success) return false;
		
		m_HasHooks = true;
		m_EnabledHooks = true;

		return true;
	}
Exemple #4
0
ReplayCreateStatus D3D12_CreateReplayDevice(const char *logfile, IReplayDriver **driver)
{
  RDCDEBUG("Creating a D3D12 replay device");

  WrappedIDXGISwapChain3::RegisterD3DDeviceCallback(GetD3D12DeviceIfAlloc);

  HMODULE lib = NULL;
  lib = LoadLibraryA("d3d12.dll");
  if(lib == NULL)
  {
    RDCERR("Failed to load d3d12.dll");
    return eReplayCreate_APIInitFailed;
  }

  lib = LoadLibraryA("dxgi.dll");
  if(lib == NULL)
  {
    RDCERR("Failed to load dxgi.dll");
    return eReplayCreate_APIInitFailed;
  }

  if(GetD3DCompiler() == NULL)
  {
    RDCERR("Failed to load d3dcompiler_??.dll");
    return eReplayCreate_APIInitFailed;
  }

  D3D12InitParams initParams;
  RDCDriver driverFileType = RDC_D3D12;
  string driverName = "D3D12";
  if(logfile)
  {
    auto status = RenderDoc::Inst().FillInitParams(logfile, driverFileType, driverName,
                                                   (RDCInitParams *)&initParams);
    if(status != eReplayCreate_Success)
      return status;
  }

  // initParams.SerialiseVersion is guaranteed to be valid/supported since otherwise the
  // FillInitParams (which calls D3D12InitParams::Serialise) would have failed above, so no need to
  // check it here.

  if(initParams.MinimumFeatureLevel < D3D_FEATURE_LEVEL_11_0)
    initParams.MinimumFeatureLevel = D3D_FEATURE_LEVEL_11_0;

  ID3D12Device *dev = NULL;
  HRESULT hr = RENDERDOC_CreateWrappedD3D12Device(NULL, initParams.MinimumFeatureLevel,
                                                  __uuidof(ID3D12Device), (void **)&dev);

  if(FAILED(hr))
  {
    RDCERR("Couldn't create a d3d12 device :(.");

    return eReplayCreate_APIHardwareUnsupported;
  }

  WrappedID3D12Device *wrappedDev = (WrappedID3D12Device *)dev;
  if(logfile)
    wrappedDev->SetLogFile(logfile);
  wrappedDev->SetLogVersion(initParams.SerialiseVersion);

  RDCLOG("Created device.");
  D3D12Replay *replay = wrappedDev->GetReplay();

  replay->SetProxy(logfile == NULL);

  *driver = (IReplayDriver *)replay;
  return eReplayCreate_Success;
}