Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change C++ standard to C++17. #277

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ if(MSVC)
# 26812: unscoped enums are widely used by the project and dependencies.
set(MSVC_DISABLED_WARNINGS "/wd26812")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MSVC_DISABLED_WARNINGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS} /MP /Zc:__cplusplus /std:c++20")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_DISABLED_WARNINGS} /MP /Zc:__cplusplus /std:c++17")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-std=c++20 \
-std=c++17 \
-fdiagnostics-color=always \
-Wno-nullability-completeness \
-Wno-deprecated-anon-enum-enum-conversion \
Expand All @@ -133,7 +133,7 @@ else()
endif ()
endif()

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 17)

# ------------------------------------------------------------------------------
# Configure PPX directories.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ your changes:
* Ensure the code follows the
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
Running `clang-format -style=file -i [modified-files]` can help.
* Code should target C++17
* Create a pull request (PR) with your patch.
* 1 PR = 1 change. If you want to add 3 features, that's 3 PRs.
* If your PR brings a non-trivial performance improvement, do provide proof.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Supported graphics APIs:
# Requirements
* Software
* Linux
* C++17 compliant compiler (clang 10+ or gcc 9+)
* Visual Studio Code or CLI
* Recent Vulkan SDK
* 1.3.216.0 or later
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ subprojects {
'-DPPX_BUILD_TESTS=FALSE'
}
if (project.name.contains("_xr")) {
cppFlags '-std=c++20',
cppFlags '-std=c++17',
'-DXR_USE_PLATFORM_ANDROID'
}
else {
cppFlags '-std=c++20'
cppFlags '-std=c++17'
}

if (project.hasProperty('DXC_PATH')) {
Expand Down
2 changes: 1 addition & 1 deletion include/ppx/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ struct StandardOptions
// Flags
std::shared_ptr<KnobFlag<bool>> pListGpus;
std::shared_ptr<KnobFlag<bool>> pUseSoftwareRenderer;
#if not defined(PPX_LINUX_HEADLESS)
#if !defined(PPX_LINUX_HEADLESS)
std::shared_ptr<KnobFlag<bool>> pHeadless;
#endif
std::shared_ptr<KnobFlag<bool>> pDeterministic;
Expand Down
2 changes: 1 addition & 1 deletion include/ppx/command_line_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CliOptions
public:
CliOptions() = default;

bool HasExtraOption(const std::string& option) const { return mAllOptions.contains(option); }
bool HasExtraOption(const std::string& option) const { return mAllOptions.find(option) != mAllOptions.end(); }

// Returns the number of unique options and flags that were specified on the commandline,
// not counting multiple appearances of the same flag such as: --assets-path a --assets-path b
Expand Down
2 changes: 1 addition & 1 deletion include/ppx/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct WindowSize
WindowSize(uint32_t width_, uint32_t height_)
: width(width_), height(height_) {}

bool operator==(const WindowSize&) const = default;
bool operator==(const WindowSize& other) const { return width == other.width && height == other.height; };
};

class Window
Expand Down
4 changes: 1 addition & 3 deletions include/ppx/xr_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ class XrComponent
std::optional<float> mFarPlaneForFrame = std::nullopt;
bool mShouldSubmitDepthInfo = false;

XrFrameState mFrameState = {
.type = XR_TYPE_FRAME_STATE,
};
XrFrameState mFrameState = {XR_TYPE_FRAME_STATE};

XrEventDataBuffer mEventDataBuffer;

Expand Down
13 changes: 7 additions & 6 deletions src/ppx/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ void Application::InitStandardKnobs()
"Select the gpu with the given index. To determine the set of valid "
"indices use --list-gpus.");

#if not defined(PPX_LINUX_HEADLESS)
#if !defined(PPX_LINUX_HEADLESS)
mStandardOpts.pHeadless =
mKnobManager.CreateKnob<KnobFlag<bool>>("headless", false);
mStandardOpts.pHeadless->SetFlagDescription(
Expand Down Expand Up @@ -1760,11 +1760,12 @@ bool Application::RecordMetricData(metrics::MetricID id, const metrics::MetricDa
void Application::UpdateAppMetrics()
{
// This data is the same for every call to increase the frame count.
static const metrics::MetricData frameCountData = {
.type = metrics::MetricType::COUNTER,
.counter = {
.increment = 1},
};
static const metrics::MetricData frameCountData = []() {
metrics::MetricData data = {};
data.type = metrics::MetricType::COUNTER;
data.counter.increment = 1;
return data;
}();

if (!HasActiveMetricsRun()) {
return;
Expand Down
8 changes: 4 additions & 4 deletions src/ppx/grfx/vk/vk_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ Result Device::ConfigureQueueInfo(const grfx::DeviceCreateInfo* pCreateInfo, std
createdQueues.insert(mGraphicsQueueFamilyIndex);
}
// Compute
if (mComputeQueueFamilyIndex != PPX_VALUE_IGNORED && !createdQueues.contains(mComputeQueueFamilyIndex)) {
if (mComputeQueueFamilyIndex != PPX_VALUE_IGNORED && createdQueues.find(mComputeQueueFamilyIndex) == createdQueues.end()) {
VkDeviceQueueCreateInfo vkci = {VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO};
vkci.queueFamilyIndex = mComputeQueueFamilyIndex;
vkci.queueCount = pCreateInfo->pGpu->GetComputeQueueCount();
vkci.pQueuePriorities = DataPtr(queuePriorities);
queueCreateInfos.push_back(vkci);
createdQueues.insert(mComputeQueueFamilyIndex);
}
else if (createdQueues.contains(mComputeQueueFamilyIndex)) {
else if (createdQueues.find(mComputeQueueFamilyIndex) != createdQueues.end()) {
PPX_LOG_WARN("Graphics queue will be shared with compute queue.");
}
// Transfer
if (mTransferQueueFamilyIndex != PPX_VALUE_IGNORED && !createdQueues.contains(mTransferQueueFamilyIndex)) {
if (mTransferQueueFamilyIndex != PPX_VALUE_IGNORED && createdQueues.find(mTransferQueueFamilyIndex) == createdQueues.end()) {
VkDeviceQueueCreateInfo vkci = {VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO};
vkci.queueFamilyIndex = mTransferQueueFamilyIndex;
vkci.queueCount = pCreateInfo->pGpu->GetTransferQueueCount();
vkci.pQueuePriorities = DataPtr(queuePriorities);
queueCreateInfos.push_back(vkci);
createdQueues.insert(mTransferQueueFamilyIndex);
}
else if (createdQueues.contains(mTransferQueueFamilyIndex)) {
else if (createdQueues.find(mTransferQueueFamilyIndex) != createdQueues.end()) {
PPX_LOG_WARN("Transfer queue will be shared with graphics or compute queue.");
}
}
Expand Down
34 changes: 16 additions & 18 deletions src/ppx/xr_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,7 @@ void XrComponent::HandleSessionStateChangedEvent(const XrEventDataSessionStateCh

void XrComponent::BeginFrame()
{
XrFrameWaitInfo frameWaitInfo = {
.type = XR_TYPE_FRAME_WAIT_INFO,
};
XrFrameWaitInfo frameWaitInfo = {XR_TYPE_FRAME_WAIT_INFO};

CHECK_XR_CALL(xrWaitFrame(mSession, &frameWaitInfo, &mFrameState));
mShouldRender = mFrameState.shouldRender;
Expand All @@ -465,16 +463,17 @@ void XrComponent::BeginFrame()
mFarPlaneForFrame = std::nullopt;

// Create projection matrices and view matrices for each eye.

XrViewLocateInfo viewLocateInfo = {
.type = XR_TYPE_VIEW_LOCATE_INFO,
.viewConfigurationType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO,
.displayTime = mFrameState.predictedDisplayTime,
.space = mRefSpace,
XR_TYPE_VIEW_LOCATE_INFO, // type
nullptr, // next
XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, // viewConfigurationType
mFrameState.predictedDisplayTime, // displayTime
mRefSpace, // space
};

XrViewState viewState = {
.type = XR_TYPE_VIEW_STATE,
};
XrViewState viewState = {XR_TYPE_VIEW_STATE};

uint32_t viewCount = 0;
CHECK_XR_CALL(xrLocateViews(mSession, &viewLocateInfo, &viewState, (uint32_t)mViews.size(), &viewCount, mViews.data()));

Expand All @@ -484,9 +483,7 @@ void XrComponent::BeginFrame()
}

// Begin frame.
XrFrameBeginInfo frameBeginInfo = {
.type = XR_TYPE_FRAME_BEGIN_INFO,
};
XrFrameBeginInfo frameBeginInfo = {XR_TYPE_FRAME_BEGIN_INFO};

XrResult result = xrBeginFrame(mSession, &frameBeginInfo);
if (result != XR_SUCCESS) {
Expand Down Expand Up @@ -590,11 +587,12 @@ void XrComponent::EndFrame(const std::vector<grfx::SwapchainPtr>& swapchains, ui

// Submit layers and end frame.
XrFrameEndInfo frameEndInfo = {
.type = XR_TYPE_FRAME_END_INFO,
.displayTime = mFrameState.predictedDisplayTime,
.environmentBlendMode = blendMode,
.layerCount = static_cast<uint32_t>(layers.size()),
.layers = layers.data(),
XR_TYPE_FRAME_END_INFO, // type
nullptr, // next
mFrameState.predictedDisplayTime, // displayTime
blendMode, // environmentBlendMode
static_cast<uint32_t>(layers.size()), // layerCount
layers.data(), // layers
};

CHECK_XR_CALL(xrEndFrame(mSession, &frameEndInfo));
Expand Down