GPUOpen-Tools / ocat

The Open Capture and Analytics Tool (OCAT) provides an FPS overlay and performance measurement for D3D11, D3D12, and Vulkan
325 stars 29 forks source link

Get C2102 - '&' requires l-value - ERROR in: GameOverlay - d3d12_rederer.cpp #86

Closed csyslabs closed 3 years ago

csyslabs commented 3 years ago

In this function:

bool d3d12_renderer::CreateConstantBuffer()
{
  viewportOffsetCB_.Reset();
  HRESULT hr = device_->CreateCommittedResource(
    &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE,
    &CD3DX12_RESOURCE_DESC::Buffer(sizeof(ConstantBuffer)), D3D12_RESOURCE_STATE_GENERIC_READ,
    nullptr, IID_PPV_ARGS(&viewportOffsetCB_));

  if (FAILED(hr)) {
    g_messageLog.LogError("D3D12", "CreateConstantBuffer - failed to create constant buffer.", hr);
    return false;
  }

  lagIndicatorKeyDownCB_.Reset();
  hr = device_->CreateCommittedResource(
    &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD), D3D12_HEAP_FLAG_NONE,
    &CD3DX12_RESOURCE_DESC::Buffer(sizeof(int) * 4), D3D12_RESOURCE_STATE_GENERIC_READ,
    nullptr, IID_PPV_ARGS(&lagIndicatorKeyDownCB_));

  if (FAILED(hr)) {
    g_messageLog.LogError("D3D12", "CreateConstantBuffer - failed to create constant buffer for lag meter.", hr);
    return false;
  }

  return true;
}

These will cause the error: &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD) &CD3DX12_RESOURCE_DESC::Buffer(sizeof(ConstantBuffer)) &CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD) &CD3DX12_RESOURCE_DESC::Buffer(sizeof(int) * 4) Is this due to my vs version ? I'm using vs2019. Thnx for the project BTW~

aurolou commented 3 years ago

hi! Yes, that's very likely. OCAT is currently built using VS 2017, SDK 10.0.17134.0, and Vulkan SDK 1.2.154.1. Updating this is on the roadmap, but no ETA yet.

csyslabs commented 3 years ago

@aurolou Problem solved, I changed the vs version to 2017 and VLKAN SDK to the specific version, all errors disappear. And finally, the project was been built, now I'm trying to learn this project. Thnx for you guys work.