From 098210f906fde88ecf6e374408adc7597eb0dba1 Mon Sep 17 00:00:00 2001 From: Vithorio Polten Date: Sat, 1 Jun 2024 00:22:47 -0300 Subject: [PATCH] lint: missing formats --- src/nvenc/nvenc_base.cpp | 165 ++-- src/nvenc/nvenc_base.h | 37 +- src/nvenc/nvenc_config.h | 3 +- src/nvenc/nvenc_d3d11.cpp | 21 +- src/nvenc/nvenc_d3d11.h | 9 +- src/nvenc/nvenc_utils.cpp | 4 +- src/nvenc/nvenc_utils.h | 3 +- src/platform/linux/input.cpp | 6 +- src/platform/linux/kmsgrab.cpp | 11 +- src/platform/linux/wlgrab.cpp | 3 +- src/platform/linux/x11grab.cpp | 6 +- src/platform/macos/av_audio.m | 35 +- src/platform/macos/av_video.m | 6 +- src/platform/macos/display.mm | 46 +- src/platform/macos/input.cpp | 7 +- src/platform/macos/microphone.mm | 23 +- src/platform/macos/misc.mm | 129 +-- src/platform/windows/audio.cpp | 5 +- src/platform/windows/display_base.cpp | 6 +- src/platform/windows/display_vram.cpp | 4 +- src/platform/windows/display_wgc.cpp | 14 +- src/platform/windows/input.cpp | 24 +- src/platform/windows/misc.cpp | 3 +- .../windows/nvprefs/driver_settings.cpp | 9 +- .../windows/nvprefs/nvprefs_interface.cpp | 6 +- src/platform/windows/nvprefs/undo_file.cpp | 6 +- src/process.cpp | 6 +- src/server/confighttp.cpp | 3 +- src/server/crypto.cpp | 48 +- src/server/nvhttp.cpp | 6 +- src/server/rtsp.cpp | 9 +- src/video.cpp | 6 +- third-party/nvfbc/NvFBC.h | 86 +- third-party/nvfbc/helper_math.h | 843 ++++++------------ tools/sunshinesvc.cpp | 3 +- 35 files changed, 721 insertions(+), 880 deletions(-) diff --git a/src/nvenc/nvenc_base.cpp b/src/nvenc/nvenc_base.cpp index b9eba5a04df..7318eb08c64 100644 --- a/src/nvenc/nvenc_base.cpp +++ b/src/nvenc/nvenc_base.cpp @@ -17,9 +17,9 @@ namespace { - GUID - quality_preset_guid_from_number(unsigned number) { - if (number > 7) number = 7; + GUID quality_preset_guid_from_number(unsigned number) { + if (number > 7) + number = 7; switch (number) { case 1: @@ -46,13 +46,11 @@ namespace { } }; - bool - equal_guids(const GUID &guid1, const GUID &guid2) { + bool equal_guids(const GUID &guid1, const GUID &guid2) { return std::memcmp(&guid1, &guid2, sizeof(GUID)) == 0; } - auto - quality_preset_string_from_guid(const GUID &guid) { + auto quality_preset_string_from_guid(const GUID &guid) { if (equal_guids(guid, NV_ENC_PRESET_P1_GUID)) { return "P1"; } @@ -81,32 +79,39 @@ namespace { namespace nvenc { - nvenc_base::nvenc_base(NV_ENC_DEVICE_TYPE device_type, void *device): - device_type(device_type), - device(device) { + nvenc_base::nvenc_base(NV_ENC_DEVICE_TYPE device_type, void *device): device_type(device_type), device(device) { } nvenc_base::~nvenc_base() { // Use destroy_encoder() instead } - bool - nvenc_base::create_encoder(const nvenc_config &config, const video::config_t &client_config, const nvenc_colorspace_t &colorspace, NV_ENC_BUFFER_FORMAT buffer_format) { + bool nvenc_base::create_encoder( + const nvenc_config &config, + const video::config_t &client_config, + const nvenc_colorspace_t &colorspace, + NV_ENC_BUFFER_FORMAT buffer_format + ) { // Pick the minimum NvEncode API version required to support the specified codec // to maximize driver compatibility. AV1 was introduced in SDK v12.0. minimum_api_version = (client_config.videoFormat <= 1) ? MAKE_NVENC_VER(11U, 0U) : MAKE_NVENC_VER(12U, 0U); - if (!nvenc && !init_library()) return false; + if (!nvenc && !init_library()) + return false; - if (encoder) destroy_encoder(); - auto fail_guard = util::fail_guard([this] { destroy_encoder(); }); + if (encoder) + destroy_encoder(); + auto fail_guard = util::fail_guard([this] { + destroy_encoder(); + }); encoder_params.width = client_config.width; encoder_params.height = client_config.height; encoder_params.buffer_format = buffer_format; encoder_params.rfi = true; - NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS session_params = { min_struct_version(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER) }; + NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS session_params + = { min_struct_version(NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER) }; session_params.device = device; session_params.deviceType = device_type; session_params.apiVersion = minimum_api_version; @@ -122,7 +127,8 @@ namespace nvenc { }; std::vector encode_guids(encode_guid_count); - if (nvenc_failed(nvenc->nvEncGetEncodeGUIDs(encoder, encode_guids.data(), encode_guids.size(), &encode_guid_count))) { + if (nvenc_failed(nvenc->nvEncGetEncodeGUIDs(encoder, encode_guids.data(), encode_guids.size(), &encode_guid_count) + )) { BOOST_LOG(error) << "NvEncGetEncodeGUIDs failed: " << last_error_string; return false; } @@ -179,7 +185,8 @@ namespace nvenc { auto supported_width = get_encoder_cap(NV_ENC_CAPS_WIDTH_MAX); auto supported_height = get_encoder_cap(NV_ENC_CAPS_HEIGHT_MAX); if (encoder_params.width > supported_width || encoder_params.height > supported_height) { - BOOST_LOG(error) << "NvEnc: gpu max encode resolution " << supported_width << "x" << supported_height << ", requested " << encoder_params.width << "x" << encoder_params.height; + BOOST_LOG(error) << "NvEnc: gpu max encode resolution " << supported_width << "x" << supported_height + << ", requested " << encoder_params.width << "x" << encoder_params.height; return false; } } @@ -205,7 +212,8 @@ namespace nvenc { init_params.tuningInfo = NV_ENC_TUNING_INFO_ULTRA_LOW_LATENCY; init_params.enablePTD = 1; init_params.enableEncodeAsync = async_event_handle ? 1 : 0; - init_params.enableWeightedPrediction = config.weighted_prediction && get_encoder_cap(NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION); + init_params.enableWeightedPrediction + = config.weighted_prediction && get_encoder_cap(NV_ENC_CAPS_SUPPORT_WEIGHTED_PREDICTION); init_params.encodeWidth = encoder_params.width; init_params.darWidth = encoder_params.width; @@ -214,8 +222,15 @@ namespace nvenc { init_params.frameRateNum = client_config.framerate; init_params.frameRateDen = 1; - NV_ENC_PRESET_CONFIG preset_config = { min_struct_version(NV_ENC_PRESET_CONFIG_VER), { min_struct_version(NV_ENC_CONFIG_VER, 7, 8) } }; - if (nvenc_failed(nvenc->nvEncGetEncodePresetConfigEx(encoder, init_params.encodeGUID, init_params.presetGUID, init_params.tuningInfo, &preset_config))) { + NV_ENC_PRESET_CONFIG preset_config + = { min_struct_version(NV_ENC_PRESET_CONFIG_VER), { min_struct_version(NV_ENC_CONFIG_VER, 7, 8) } }; + if (nvenc_failed(nvenc->nvEncGetEncodePresetConfigEx( + encoder, + init_params.encodeGUID, + init_params.presetGUID, + init_params.tuningInfo, + &preset_config + ))) { BOOST_LOG(error) << "NvEncGetEncodePresetConfigEx failed: " << last_error_string; return false; } @@ -229,9 +244,10 @@ namespace nvenc { enc_config.rcParams.zeroReorderDelay = 1; enc_config.rcParams.enableLookahead = 0; enc_config.rcParams.lowDelayKeyFrameScale = 1; - enc_config.rcParams.multiPass = config.two_pass == nvenc_two_pass::quarter_resolution ? NV_ENC_TWO_PASS_QUARTER_RESOLUTION : - config.two_pass == nvenc_two_pass::full_resolution ? NV_ENC_TWO_PASS_FULL_RESOLUTION : - NV_ENC_MULTI_PASS_DISABLED; + enc_config.rcParams.multiPass + = config.two_pass == nvenc_two_pass::quarter_resolution ? NV_ENC_TWO_PASS_QUARTER_RESOLUTION : + config.two_pass == nvenc_two_pass::full_resolution ? NV_ENC_TWO_PASS_FULL_RESOLUTION : + NV_ENC_MULTI_PASS_DISABLED; enc_config.rcParams.enableAQ = config.adaptive_quantization; enc_config.rcParams.averageBitRate = client_config.bitrate * 1000; @@ -254,21 +270,23 @@ namespace nvenc { format_config.enableFillerDataInsertion = config.insert_filler_data; }; - auto set_ref_frames = [&](uint32_t &ref_frames_option, NV_ENC_NUM_REF_FRAMES &L0_option, uint32_t ref_frames_default) { - if (client_config.numRefFrames > 0) { - ref_frames_option = client_config.numRefFrames; - } - else { - ref_frames_option = ref_frames_default; - } - if (ref_frames_option > 0 && !get_encoder_cap(NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES)) { - ref_frames_option = 1; - encoder_params.rfi = false; - } - encoder_params.ref_frames_in_dpb = ref_frames_option; - // This limits ref frames any frame can use to 1, but allows larger buffer size for fallback if some frames are invalidated through rfi - L0_option = NV_ENC_NUM_REF_FRAMES_1; - }; + auto set_ref_frames + = [&](uint32_t &ref_frames_option, NV_ENC_NUM_REF_FRAMES &L0_option, uint32_t ref_frames_default) { + if (client_config.numRefFrames > 0) { + ref_frames_option = client_config.numRefFrames; + } + else { + ref_frames_option = ref_frames_default; + } + if (ref_frames_option > 0 && !get_encoder_cap(NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES)) { + ref_frames_option = 1; + encoder_params.rfi = false; + } + encoder_params.ref_frames_in_dpb = ref_frames_option; + // This limits ref frames any frame can use to 1, but allows larger buffer size for fallback if some frames + // are invalidated through rfi + L0_option = NV_ENC_NUM_REF_FRAMES_1; + }; auto set_minqp_if_enabled = [&](int value) { if (config.enable_min_qp) { @@ -380,20 +398,30 @@ namespace nvenc { { auto f = stat_trackers::one_digit_after_decimal(); - BOOST_LOG(debug) << "NvEnc: requested encoded frame size " << f % (client_config.bitrate / 8. / client_config.framerate) << " kB"; + BOOST_LOG(debug) << "NvEnc: requested encoded frame size " + << f % (client_config.bitrate / 8. / client_config.framerate) << " kB"; } { std::string extra; - if (init_params.enableEncodeAsync) extra += " async"; - if (buffer_is_10bit()) extra += " 10-bit"; - if (enc_config.rcParams.multiPass != NV_ENC_MULTI_PASS_DISABLED) extra += " two-pass"; - if (config.vbv_percentage_increase > 0 && get_encoder_cap(NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE)) extra += " vbv+" + std::to_string(config.vbv_percentage_increase); - if (encoder_params.rfi) extra += " rfi"; - if (init_params.enableWeightedPrediction) extra += " weighted-prediction"; - if (enc_config.rcParams.enableAQ) extra += " spatial-aq"; - if (enc_config.rcParams.enableMinQP) extra += " qpmin=" + std::to_string(enc_config.rcParams.minQP.qpInterP); - if (config.insert_filler_data) extra += " filler-data"; + if (init_params.enableEncodeAsync) + extra += " async"; + if (buffer_is_10bit()) + extra += " 10-bit"; + if (enc_config.rcParams.multiPass != NV_ENC_MULTI_PASS_DISABLED) + extra += " two-pass"; + if (config.vbv_percentage_increase > 0 && get_encoder_cap(NV_ENC_CAPS_SUPPORT_CUSTOM_VBV_BUF_SIZE)) + extra += " vbv+" + std::to_string(config.vbv_percentage_increase); + if (encoder_params.rfi) + extra += " rfi"; + if (init_params.enableWeightedPrediction) + extra += " weighted-prediction"; + if (enc_config.rcParams.enableAQ) + extra += " spatial-aq"; + if (enc_config.rcParams.enableMinQP) + extra += " qpmin=" + std::to_string(enc_config.rcParams.minQP.qpInterP); + if (config.insert_filler_data) + extra += " filler-data"; BOOST_LOG(info) << "NvEnc: created encoder " << quality_preset_string_from_guid(init_params.presetGUID) << extra; } @@ -402,8 +430,7 @@ namespace nvenc { return true; } - void - nvenc_base::destroy_encoder() { + void nvenc_base::destroy_encoder() { if (output_bitstream) { nvenc->nvEncDestroyBitstreamBuffer(encoder, output_bitstream); output_bitstream = nullptr; @@ -426,8 +453,7 @@ namespace nvenc { encoder_params = {}; } - nvenc_encoded_frame - nvenc_base::encode_frame(uint64_t frame_index, bool force_idr) { + nvenc_encoded_frame nvenc_base::encode_frame(uint64_t frame_index, bool force_idr) { if (!encoder) { return {}; } @@ -442,7 +468,9 @@ namespace nvenc { BOOST_LOG(error) << "NvEncMapInputResource failed: " << last_error_string; return {}; } - auto unmap_guard = util::fail_guard([&] { nvenc->nvEncUnmapInputResource(encoder, &mapped_input_buffer); }); + auto unmap_guard = util::fail_guard([&] { + nvenc->nvEncUnmapInputResource(encoder, &mapped_input_buffer); + }); NV_ENC_PIC_PARAMS pic_params = { min_struct_version(NV_ENC_PIC_PARAMS_VER, 4, 6) }; pic_params.inputWidth = encoder_params.width; @@ -501,21 +529,22 @@ namespace nvenc { // Print encoded frame size stats to debug log every 20 seconds auto callback = [&](float stat_min, float stat_max, double stat_avg) { auto f = stat_trackers::one_digit_after_decimal(); - BOOST_LOG(debug) << "NvEnc: encoded frame sizes (min max avg) " << f % stat_min << " " << f % stat_max << " " << f % stat_avg << " kB"; + BOOST_LOG(debug) << "NvEnc: encoded frame sizes (min max avg) " << f % stat_min << " " << f % stat_max << " " + << f % stat_avg << " kB"; }; using namespace std::literals; - encoder_state.frame_size_tracker.collect_and_callback_on_interval(encoded_frame.data.size() / 1000., callback, 20s); + encoder_state.frame_size_tracker + .collect_and_callback_on_interval(encoded_frame.data.size() / 1000., callback, 20s); } return encoded_frame; } - bool - nvenc_base::invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame) { - if (!encoder || !encoder_params.rfi) return false; + bool nvenc_base::invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame) { + if (!encoder || !encoder_params.rfi) + return false; - if (first_frame >= encoder_state.last_rfi_range.first && - last_frame <= encoder_state.last_rfi_range.second) { + if (first_frame >= encoder_state.last_rfi_range.first && last_frame <= encoder_state.last_rfi_range.second) { BOOST_LOG(debug) << "NvEnc: rfi request " << first_frame << "-" << last_frame << " already done"; return true; } @@ -527,7 +556,8 @@ namespace nvenc { return false; } - BOOST_LOG(debug) << "NvEnc: rfi request " << first_frame << "-" << last_frame << " expanding to last encoded frame " << encoder_state.last_encoded_frame_index; + BOOST_LOG(debug) << "NvEnc: rfi request " << first_frame << "-" << last_frame << " expanding to last encoded frame " + << encoder_state.last_encoded_frame_index; last_frame = encoder_state.last_encoded_frame_index; encoder_state.last_rfi_range = { first_frame, last_frame }; @@ -547,12 +577,11 @@ namespace nvenc { return true; } - bool - nvenc_base::nvenc_failed(NVENCSTATUS status) { + bool nvenc_base::nvenc_failed(NVENCSTATUS status) { auto status_string = [](NVENCSTATUS status) -> std::string { switch (status) { #define nvenc_status_case(x) \ - case x: \ + case x: \ return #x; nvenc_status_case(NV_ENC_SUCCESS); nvenc_status_case(NV_ENC_ERR_NO_ENCODE_DEVICE); @@ -591,7 +620,8 @@ namespace nvenc { if (status != NV_ENC_SUCCESS) { if (nvenc && encoder) { last_error_string = nvenc->nvEncGetLastErrorString(encoder); - if (!last_error_string.empty()) last_error_string += " "; + if (!last_error_string.empty()) + last_error_string += " "; } last_error_string += status_string(status); return true; @@ -608,8 +638,7 @@ namespace nvenc { * @param v12_struct_version Optionally specifies the struct version to use with v12 SDK major versions. * @return A suitable struct version for the active codec. */ - uint32_t - nvenc_base::min_struct_version(uint32_t version, uint32_t v11_struct_version, uint32_t v12_struct_version) { + uint32_t nvenc_base::min_struct_version(uint32_t version, uint32_t v11_struct_version, uint32_t v12_struct_version) { assert(minimum_api_version); // Mask off and replace the original NVENCAPI_VERSION diff --git a/src/nvenc/nvenc_base.h b/src/nvenc/nvenc_base.h index 2d012ef8da8..4ff37d52b5a 100644 --- a/src/nvenc/nvenc_base.h +++ b/src/nvenc/nvenc_base.h @@ -17,33 +17,31 @@ namespace nvenc { virtual ~nvenc_base(); nvenc_base(const nvenc_base &) = delete; - nvenc_base & - operator=(const nvenc_base &) = delete; + nvenc_base &operator=(const nvenc_base &) = delete; - bool - create_encoder(const nvenc_config &config, const video::config_t &client_config, const nvenc_colorspace_t &colorspace, NV_ENC_BUFFER_FORMAT buffer_format); + bool create_encoder( + const nvenc_config &config, + const video::config_t &client_config, + const nvenc_colorspace_t &colorspace, + NV_ENC_BUFFER_FORMAT buffer_format + ); - void - destroy_encoder(); + void destroy_encoder(); - nvenc_encoded_frame - encode_frame(uint64_t frame_index, bool force_idr); + nvenc_encoded_frame encode_frame(uint64_t frame_index, bool force_idr); - bool - invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame); + bool invalidate_ref_frames(uint64_t first_frame, uint64_t last_frame); protected: - virtual bool - init_library() = 0; + virtual bool init_library() = 0; - virtual bool - create_and_register_input_buffer() = 0; + virtual bool create_and_register_input_buffer() = 0; - virtual bool - wait_for_async_event(uint32_t timeout_ms) { return false; } + virtual bool wait_for_async_event(uint32_t timeout_ms) { + return false; + } - bool - nvenc_failed(NVENCSTATUS status); + bool nvenc_failed(NVENCSTATUS status); /** * @brief This function returns the corresponding struct version for the minimum API required by the codec. @@ -53,8 +51,7 @@ namespace nvenc { * @param v12_struct_version Optionally specifies the struct version to use with v12 SDK major versions. * @return A suitable struct version for the active codec. */ - uint32_t - min_struct_version(uint32_t version, uint32_t v11_struct_version = 0, uint32_t v12_struct_version = 0); + uint32_t min_struct_version(uint32_t version, uint32_t v11_struct_version = 0, uint32_t v12_struct_version = 0); const NV_ENC_DEVICE_TYPE device_type; void *const device; diff --git a/src/nvenc/nvenc_config.h b/src/nvenc/nvenc_config.h index c4aae12a86e..30bece6884b 100644 --- a/src/nvenc/nvenc_config.h +++ b/src/nvenc/nvenc_config.h @@ -17,7 +17,8 @@ namespace nvenc { // Quality preset from 1 to 7, higher is slower int quality_preset = 1; - // Use optional preliminary pass for better motion vectors, bitrate distribution and stricter VBV(HRD), uses CUDA cores + // Use optional preliminary pass for better motion vectors, bitrate distribution and stricter VBV(HRD), uses CUDA + // cores nvenc_two_pass two_pass = nvenc_two_pass::quarter_resolution; // Percentage increase of VBV/HRD from the default single frame, allows low-latency variable bitrate diff --git a/src/nvenc/nvenc_d3d11.cpp b/src/nvenc/nvenc_d3d11.cpp index cb33a1801af..0b97873a7e7 100644 --- a/src/nvenc/nvenc_d3d11.cpp +++ b/src/nvenc/nvenc_d3d11.cpp @@ -8,12 +8,12 @@ namespace nvenc { nvenc_d3d11::nvenc_d3d11(ID3D11Device *d3d_device): - nvenc_base(NV_ENC_DEVICE_TYPE_DIRECTX, d3d_device), - d3d_device(d3d_device) { + nvenc_base(NV_ENC_DEVICE_TYPE_DIRECTX, d3d_device), d3d_device(d3d_device) { } nvenc_d3d11::~nvenc_d3d11() { - if (encoder) destroy_encoder(); + if (encoder) + destroy_encoder(); if (dll) { FreeLibrary(dll); @@ -21,14 +21,13 @@ namespace nvenc { } } - ID3D11Texture2D * - nvenc_d3d11::get_input_texture() { + ID3D11Texture2D *nvenc_d3d11::get_input_texture() { return d3d_input_texture.GetInterfacePtr(); } - bool - nvenc_d3d11::init_library() { - if (dll) return true; + bool nvenc_d3d11::init_library() { + if (dll) + return true; #ifdef _WIN64 auto dll_name = "nvEncodeAPI64.dll"; @@ -37,7 +36,8 @@ namespace nvenc { #endif if ((dll = LoadLibraryEx(dll_name, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32))) { - if (auto create_instance = (decltype(NvEncodeAPICreateInstance) *) GetProcAddress(dll, "NvEncodeAPICreateInstance")) { + if (auto create_instance + = (decltype(NvEncodeAPICreateInstance) *) GetProcAddress(dll, "NvEncodeAPICreateInstance")) { auto new_nvenc = std::make_unique(); new_nvenc->version = min_struct_version(NV_ENCODE_API_FUNCTION_LIST_VER); if (nvenc_failed(create_instance(new_nvenc.get()))) { @@ -64,8 +64,7 @@ namespace nvenc { return false; } - bool - nvenc_d3d11::create_and_register_input_buffer() { + bool nvenc_d3d11::create_and_register_input_buffer() { if (!d3d_input_texture) { D3D11_TEXTURE2D_DESC desc = {}; desc.Width = encoder_params.width; diff --git a/src/nvenc/nvenc_d3d11.h b/src/nvenc/nvenc_d3d11.h index ef1b8d4c232..d707ef57856 100644 --- a/src/nvenc/nvenc_d3d11.h +++ b/src/nvenc/nvenc_d3d11.h @@ -16,15 +16,12 @@ namespace nvenc { nvenc_d3d11(ID3D11Device *d3d_device); ~nvenc_d3d11(); - ID3D11Texture2D * - get_input_texture(); + ID3D11Texture2D *get_input_texture(); private: - bool - init_library() override; + bool init_library() override; - bool - create_and_register_input_buffer() override; + bool create_and_register_input_buffer() override; HMODULE dll = NULL; const ID3D11DevicePtr d3d_device; diff --git a/src/nvenc/nvenc_utils.cpp b/src/nvenc/nvenc_utils.cpp index 1b8b7ec9f10..616687a747c 100644 --- a/src/nvenc/nvenc_utils.cpp +++ b/src/nvenc/nvenc_utils.cpp @@ -34,8 +34,8 @@ namespace nvenc { } } - nvenc_colorspace_t - nvenc_colorspace_from_sunshine_colorspace(const video::sunshine_colorspace_t &sunshine_colorspace) { + nvenc_colorspace_t nvenc_colorspace_from_sunshine_colorspace(const video::sunshine_colorspace_t &sunshine_colorspace + ) { nvenc_colorspace_t colorspace; switch (sunshine_colorspace.colorspace) { diff --git a/src/nvenc/nvenc_utils.h b/src/nvenc/nvenc_utils.h index 67af1037618..cffb1542d90 100644 --- a/src/nvenc/nvenc_utils.h +++ b/src/nvenc/nvenc_utils.h @@ -21,7 +21,6 @@ namespace nvenc { NV_ENC_BUFFER_FORMAT nvenc_format_from_sunshine_format(platf::pix_fmt_e format); - nvenc_colorspace_t - nvenc_colorspace_from_sunshine_colorspace(const video::sunshine_colorspace_t &sunshine_colorspace); + nvenc_colorspace_t nvenc_colorspace_from_sunshine_colorspace(const video::sunshine_colorspace_t &sunshine_colorspace); } // namespace nvenc diff --git a/src/platform/linux/input.cpp b/src/platform/linux/input.cpp index 13d535af64a..67b9357b623 100644 --- a/src/platform/linux/input.cpp +++ b/src/platform/linux/input.cpp @@ -1738,7 +1738,8 @@ namespace platf { } } } - else if (touch.eventType == LI_TOUCH_EVENT_DOWN || touch.eventType == LI_TOUCH_EVENT_MOVE || touch.eventType == LI_TOUCH_EVENT_UP) { + else if (touch.eventType == LI_TOUCH_EVENT_DOWN || touch.eventType == LI_TOUCH_EVENT_MOVE + || touch.eventType == LI_TOUCH_EVENT_UP) { int slot_index; if (touch.eventType == LI_TOUCH_EVENT_DOWN) { // Allocate a new slot for this new touch @@ -1978,7 +1979,8 @@ namespace platf { } // Don't update tool type if we're cancelling or ending a touch/hover - if (pen.eventType != LI_TOUCH_EVENT_CANCEL && pen.eventType != LI_TOUCH_EVENT_CANCEL_ALL && pen.eventType != LI_TOUCH_EVENT_HOVER_LEAVE && pen.eventType != LI_TOUCH_EVENT_UP) { + if (pen.eventType != LI_TOUCH_EVENT_CANCEL && pen.eventType != LI_TOUCH_EVENT_CANCEL_ALL + && pen.eventType != LI_TOUCH_EVENT_HOVER_LEAVE && pen.eventType != LI_TOUCH_EVENT_UP) { // Update the tool type if it is known switch (pen.toolType) { default: diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index 59aa9f96582..f0fb3a887f8 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -926,10 +926,8 @@ namespace platf { BOOST_LOG(debug) << "Refreshing cursor image after FB changed"sv; cursor_dirty = true; } - else if (*prop_src_x != captured_cursor.prop_src_x || - *prop_src_y != captured_cursor.prop_src_y || - *prop_src_w != captured_cursor.prop_src_w || - *prop_src_h != captured_cursor.prop_src_h) { + else if (*prop_src_x != captured_cursor.prop_src_x || *prop_src_y != captured_cursor.prop_src_y + || *prop_src_w != captured_cursor.prop_src_w || *prop_src_h != captured_cursor.prop_src_h) { BOOST_LOG(debug) << "Refreshing cursor image after source dimensions changed"sv; cursor_dirty = true; } @@ -1605,9 +1603,8 @@ namespace platf { monitor_descriptor.viewport.offset_y = monitor->viewport.offset_y; // A sanity check, it's guesswork after all. - if ( - monitor_descriptor.viewport.width != monitor->viewport.width || - monitor_descriptor.viewport.height != monitor->viewport.height) { + if (monitor_descriptor.viewport.width != monitor->viewport.width + || monitor_descriptor.viewport.height != monitor->viewport.height) { BOOST_LOG(warning) << "Mismatch on expected Resolution compared to actual resolution: "sv << monitor_descriptor.viewport.width << 'x' << monitor_descriptor.viewport.height << " vs "sv << monitor->viewport.width << 'x' << monitor->viewport.height; diff --git a/src/platform/linux/wlgrab.cpp b/src/platform/linux/wlgrab.cpp index 80f5fc1e73a..86555fcf5fc 100644 --- a/src/platform/linux/wlgrab.cpp +++ b/src/platform/linux/wlgrab.cpp @@ -402,7 +402,8 @@ namespace wl { namespace platf { std::shared_ptr wl_display(mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config) { - if (hwdevice_type != platf::mem_type_e::system && hwdevice_type != platf::mem_type_e::vaapi && hwdevice_type != platf::mem_type_e::cuda) { + if (hwdevice_type != platf::mem_type_e::system && hwdevice_type != platf::mem_type_e::vaapi + && hwdevice_type != platf::mem_type_e::cuda) { BOOST_LOG(error) << "Could not initialize display with the given hw device type."sv; return nullptr; } diff --git a/src/platform/linux/x11grab.cpp b/src/platform/linux/x11grab.cpp index bece6e62827..6df2b55e0cd 100644 --- a/src/platform/linux/x11grab.cpp +++ b/src/platform/linux/x11grab.cpp @@ -612,8 +612,7 @@ namespace platf { } ~shm_attr_t() override { - while (!task_pool.cancel(refresh_task_id)) - ; + while (!task_pool.cancel(refresh_task_id)); } capture_e capture( @@ -774,7 +773,8 @@ namespace platf { std::shared_ptr x11_display(platf::mem_type_e hwdevice_type, const std::string &display_name, const ::video::config_t &config) { - if (hwdevice_type != platf::mem_type_e::system && hwdevice_type != platf::mem_type_e::vaapi && hwdevice_type != platf::mem_type_e::cuda) { + if (hwdevice_type != platf::mem_type_e::system && hwdevice_type != platf::mem_type_e::vaapi + && hwdevice_type != platf::mem_type_e::cuda) { BOOST_LOG(error) << "Could not initialize x11 display with the given hw device type"sv; return nullptr; } diff --git a/src/platform/macos/av_audio.m b/src/platform/macos/av_audio.m index cb0c83c2e97..6433c7f6529 100644 --- a/src/platform/macos/av_audio.m +++ b/src/platform/macos/av_audio.m @@ -16,10 +16,10 @@ @implementation AVAudio // a different method. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability-new" - AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInMicrophone, - AVCaptureDeviceTypeExternalUnknown] - mediaType:AVMediaTypeAudio - position:AVCaptureDevicePositionUnspecified]; + AVCaptureDeviceDiscoverySession *discoverySession = [AVCaptureDeviceDiscoverySession + discoverySessionWithDeviceTypes:@[AVCaptureDeviceTypeBuiltInMicrophone, AVCaptureDeviceTypeExternalUnknown] + mediaType:AVMediaTypeAudio + position:AVCaptureDevicePositionUnspecified]; return discoverySession.devices; #pragma clang diagnostic pop } @@ -64,7 +64,10 @@ - (void)dealloc { [super dealloc]; } -- (int)setupMicrophone:(AVCaptureDevice *)device sampleRate:(UInt32)sampleRate frameSize:(UInt32)frameSize channels:(UInt8)channels { +- (int)setupMicrophone:(AVCaptureDevice *)device + sampleRate:(UInt32)sampleRate + frameSize:(UInt32)frameSize + channels:(UInt8)channels { self.audioCaptureSession = [[AVCaptureSession alloc] init]; NSError *error; @@ -92,9 +95,11 @@ - (int)setupMicrophone:(AVCaptureDevice *)device sampleRate:(UInt32)sampleRate f (NSString *) AVLinearPCMIsNonInterleaved: @NO }]; - dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_CONCURRENT, + dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class( + DISPATCH_QUEUE_CONCURRENT, QOS_CLASS_USER_INITIATED, - DISPATCH_QUEUE_PRIORITY_HIGH); + DISPATCH_QUEUE_PRIORITY_HIGH + ); dispatch_queue_t recordingQueue = dispatch_queue_create("audioSamplingQueue", qos); [audioOutput setSampleBufferDelegate:self queue:recordingQueue]; @@ -128,9 +133,19 @@ - (void)captureOutput:(AVCaptureOutput *)output AudioBufferList audioBufferList; CMBlockBufferRef blockBuffer; - CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer); - - // NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interleaved PCM format but buffer contained %u streams", audioBufferList.mNumberBuffers); + CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer( + sampleBuffer, + NULL, + &audioBufferList, + sizeof(audioBufferList), + NULL, + NULL, + 0, + &blockBuffer + ); + + // NSAssert(audioBufferList.mNumberBuffers == 1, @"Expected interleaved PCM format but buffer contained %u streams", + // audioBufferList.mNumberBuffers); // this is safe, because an interleaved PCM stream has exactly one buffer, // and we don't want to do sanity checks in a performance critical exec path diff --git a/src/platform/macos/av_video.m b/src/platform/macos/av_video.m index 874a87f7b18..a37e0197a0b 100644 --- a/src/platform/macos/av_video.m +++ b/src/platform/macos/av_video.m @@ -98,9 +98,11 @@ - (dispatch_semaphore_t)capture:(FrameCallbackBlock)frameCallback { (NSString *) AVVideoScalingModeKey: AVVideoScalingModeResizeAspect, }]; - dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, + dispatch_queue_attr_t qos = dispatch_queue_attr_make_with_qos_class( + DISPATCH_QUEUE_SERIAL, QOS_CLASS_USER_INITIATED, - DISPATCH_QUEUE_PRIORITY_HIGH); + DISPATCH_QUEUE_PRIORITY_HIGH + ); dispatch_queue_t recordingQueue = dispatch_queue_create("videoCaptureQueue", qos); [videoOutput setSampleBufferDelegate:self queue:recordingQueue]; diff --git a/src/platform/macos/display.mm b/src/platform/macos/display.mm index dc7c7b68532..ab6f7d752da 100644 --- a/src/platform/macos/display.mm +++ b/src/platform/macos/display.mm @@ -28,8 +28,11 @@ [av_capture release]; } - capture_e - capture(const push_captured_image_cb_t &push_captured_image_cb, const pull_free_image_cb_t &pull_free_image_cb, bool *cursor) override { + capture_e capture( + const push_captured_image_cb_t &push_captured_image_cb, + const pull_free_image_cb_t &pull_free_image_cb, + bool *cursor + ) override { auto signal = [av_capture capture:^(CMSampleBufferRef sampleBuffer) { auto new_sample_buffer = std::make_shared(sampleBuffer); auto new_pixel_buffer = std::make_shared(new_sample_buffer->buf); @@ -42,10 +45,8 @@ } auto av_img = std::static_pointer_cast(img_out); - auto old_data_retainer = std::make_shared( - av_img->sample_buffer, - av_img->pixel_buffer, - img_out->data); + auto old_data_retainer + = std::make_shared(av_img->sample_buffer, av_img->pixel_buffer, img_out->data); av_img->sample_buffer = new_sample_buffer; av_img->pixel_buffer = new_pixel_buffer; @@ -73,13 +74,11 @@ return capture_e::ok; } - std::shared_ptr - alloc_img() override { + std::shared_ptr alloc_img() override { return std::make_shared(); } - std::unique_ptr - make_avcodec_encode_device(pix_fmt_e pix_fmt) override { + std::unique_ptr make_avcodec_encode_device(pix_fmt_e pix_fmt) override { if (pix_fmt == pix_fmt_e::yuv420p) { av_capture.pixelFormat = kCVPixelFormatType_32BGRA; @@ -98,18 +97,15 @@ } } - int - dummy_img(img_t *img) override { + int dummy_img(img_t *img) override { auto signal = [av_capture capture:^(CMSampleBufferRef sampleBuffer) { auto new_sample_buffer = std::make_shared(sampleBuffer); auto new_pixel_buffer = std::make_shared(new_sample_buffer->buf); auto av_img = (av_img_t *) img; - auto old_data_retainer = std::make_shared( - av_img->sample_buffer, - av_img->pixel_buffer, - img->data); + auto old_data_retainer + = std::make_shared(av_img->sample_buffer, av_img->pixel_buffer, img->data); av_img->sample_buffer = new_sample_buffer; av_img->pixel_buffer = new_pixel_buffer; @@ -138,13 +134,11 @@ * width --> the intended capture width * height --> the intended capture height */ - static void - setResolution(void *display, int width, int height) { + static void setResolution(void *display, int width, int height) { [static_cast(display) setFrameWidth:width frameHeight:height]; } - static void - setPixelFormat(void *display, OSType pixelFormat) { + static void setPixelFormat(void *display, OSType pixelFormat) { static_cast(display).pixelFormat = pixelFormat; } }; @@ -168,8 +162,10 @@ NSNumber *display_id = item[@"id"]; // We need show display's product name and corresponding display number given by user NSString *name = item[@"displayName"]; - // We are using CGGetActiveDisplayList that only returns active displays so hardcoded connected value in log to true - BOOST_LOG(info) << "Detected display: "sv << name.UTF8String << " (id: "sv << [NSString stringWithFormat:@"%@", display_id].UTF8String << ") connected: true"sv; + // We are using CGGetActiveDisplayList that only returns active displays so hardcoded connected value in log to + // true + BOOST_LOG(info) << "Detected display: "sv << name.UTF8String << " (id: "sv + << [NSString stringWithFormat:@"%@", display_id].UTF8String << ") connected: true"sv; if (!display_name.empty() && std::atoi(display_name.c_str()) == [display_id unsignedIntValue]) { display->display_id = [display_id unsignedIntValue]; } @@ -192,8 +188,7 @@ return display; } - std::vector - display_names(mem_type_e hwdevice_type) { + std::vector display_names(mem_type_e hwdevice_type) { __block std::vector display_names; auto display_array = [AVVideo displayNames]; @@ -211,8 +206,7 @@ * @brief Returns if GPUs/drivers have changed since the last call to this function. * @return `true` if a change has occurred or if it is unknown whether a change occurred. */ - bool - needs_encoder_reenumeration() { + bool needs_encoder_reenumeration() { // We don't track GPU state, so we will always reenumerate. Fortunately, it is fast on macOS. return true; } diff --git a/src/platform/macos/input.cpp b/src/platform/macos/input.cpp index 25482d9a425..29168026ba6 100644 --- a/src/platform/macos/input.cpp +++ b/src/platform/macos/input.cpp @@ -225,8 +225,8 @@ const KeyCodeMap kKeyCodesMap[] = { const KeyCodeMap *temp_map = std::lower_bound(kKeyCodesMap, kKeyCodesMap + sizeof(kKeyCodesMap) / sizeof(kKeyCodesMap[0]), key_map); - if (temp_map >= kKeyCodesMap + sizeof(kKeyCodesMap) / sizeof(kKeyCodesMap[0]) || - temp_map->win_keycode != keycode || temp_map->mac_keycode == -1) { + if (temp_map >= kKeyCodesMap + sizeof(kKeyCodesMap) / sizeof(kKeyCodesMap[0]) || temp_map->win_keycode != keycode + || temp_map->mac_keycode == -1) { return -1; } @@ -246,7 +246,8 @@ const KeyCodeMap kKeyCodesMap[] = { auto macos_input = ((macos_input_t *) input.get()); auto event = macos_input->kb_event; - if (key == kVK_Shift || key == kVK_RightShift || key == kVK_Command || key == kVK_RightCommand || key == kVK_Option || key == kVK_RightOption || key == kVK_Control || key == kVK_RightControl) { + if (key == kVK_Shift || key == kVK_RightShift || key == kVK_Command || key == kVK_RightCommand || key == kVK_Option + || key == kVK_RightOption || key == kVK_Control || key == kVK_RightControl) { CGEventFlags mask; switch (key) { diff --git a/src/platform/macos/microphone.mm b/src/platform/macos/microphone.mm index 836f134a482..861a0917728 100644 --- a/src/platform/macos/microphone.mm +++ b/src/platform/macos/microphone.mm @@ -18,8 +18,7 @@ [av_audio_capture release]; } - capture_e - sample(std::vector &sample_in) override { + capture_e sample(std::vector &sample_in) override { auto sample_size = sample_in.size(); uint32_t length = 0; @@ -45,14 +44,14 @@ AVCaptureDevice *audio_capture_device {}; public: - int - set_sink(const std::string &sink) override { + int set_sink(const std::string &sink) override { BOOST_LOG(warning) << "audio_control_t::set_sink() unimplemented: "sv << sink; return 0; } std::unique_ptr - microphone(const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) override { + microphone(const std::uint8_t *mapping, int channels, std::uint32_t sample_rate, std::uint32_t frame_size) + override { auto mic = std::make_unique(); const char *audio_sink = ""; @@ -61,7 +60,8 @@ } if ((audio_capture_device = [AVAudio findMicrophone:[NSString stringWithUTF8String:audio_sink]]) == nullptr) { - BOOST_LOG(error) << "opening microphone '"sv << audio_sink << "' failed. Please set a valid input source in the Sunshine config."sv; + BOOST_LOG(error) << "opening microphone '"sv << audio_sink + << "' failed. Please set a valid input source in the Sunshine config."sv; BOOST_LOG(error) << "Available inputs:"sv; for (NSString *name in [AVAudio microphoneNames]) { @@ -73,7 +73,10 @@ mic->av_audio_capture = [[AVAudio alloc] init]; - if ([mic->av_audio_capture setupMicrophone:audio_capture_device sampleRate:sample_rate frameSize:frame_size channels:channels]) { + if ([mic->av_audio_capture setupMicrophone:audio_capture_device + sampleRate:sample_rate + frameSize:frame_size + channels:channels]) { BOOST_LOG(error) << "Failed to setup microphone."sv; return nullptr; } @@ -81,16 +84,14 @@ return mic; } - std::optional - sink_info() override { + std::optional sink_info() override { sink_t sink; return sink; } }; - std::unique_ptr - audio_control() { + std::unique_ptr audio_control() { return std::make_unique(); } } // namespace platf diff --git a/src/platform/macos/misc.mm b/src/platform/macos/misc.mm index 20c2247e049..2555b821d40 100644 --- a/src/platform/macos/misc.mm +++ b/src/platform/macos/misc.mm @@ -36,14 +36,11 @@ #if __MAC_OS_X_VERSION_MAX_ALLOWED < 110000 // __MAC_11_0 // If they're not in the SDK then we can use our own function definitions. // Need to use weak import so that this will link in macOS 10.14 and earlier - extern "C" bool - CGPreflightScreenCaptureAccess(void) __attribute__((weak_import)); - extern "C" bool - CGRequestScreenCaptureAccess(void) __attribute__((weak_import)); + extern "C" bool CGPreflightScreenCaptureAccess(void) __attribute__((weak_import)); + extern "C" bool CGRequestScreenCaptureAccess(void) __attribute__((weak_import)); #endif - std::unique_ptr - init() { + std::unique_ptr init() { // This will generate a warning about CGPreflightScreenCaptureAccess and // CGRequestScreenCaptureAccess being unavailable before macOS 10.15, but // we have a guard to prevent it from being called on those earlier systems. @@ -60,8 +57,8 @@ #pragma clang diagnostic ignored "-Wtautological-pointer-compare" if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:((NSOperatingSystemVersion) { 10, 15, 0 })] && // Double check that these weakly-linked symbols have been loaded: - CGPreflightScreenCaptureAccess != nullptr && CGRequestScreenCaptureAccess != nullptr && - !CGPreflightScreenCaptureAccess()) { + CGPreflightScreenCaptureAccess != nullptr && CGRequestScreenCaptureAccess != nullptr + && !CGPreflightScreenCaptureAccess()) { BOOST_LOG(error) << "No screen capture permission!"sv; BOOST_LOG(error) << "Please activate it in 'System Preferences' -> 'Privacy' -> 'Screen Recording'"sv; CGRequestScreenCaptureAccess(); @@ -71,8 +68,7 @@ return std::make_unique(); } - fs::path - appdata() { + fs::path appdata() { const char *homedir; if ((homedir = getenv("HOME")) == nullptr) { homedir = getpwuid(geteuid())->pw_dir; @@ -83,8 +79,7 @@ using ifaddr_t = util::safe_ptr; - ifaddr_t - get_ifaddrs() { + ifaddr_t get_ifaddrs() { ifaddrs *p { nullptr }; getifaddrs(&p); @@ -92,45 +87,38 @@ return ifaddr_t { p }; } - std::string - from_sockaddr(const sockaddr *const ip_addr) { + std::string from_sockaddr(const sockaddr *const ip_addr) { char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; if (family == AF_INET6) { - inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, - INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); } else if (family == AF_INET) { - inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, - INET_ADDRSTRLEN); + inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); } return std::string { data }; } - std::pair - from_sockaddr_ex(const sockaddr *const ip_addr) { + std::pair from_sockaddr_ex(const sockaddr *const ip_addr) { char data[INET6_ADDRSTRLEN] = {}; auto family = ip_addr->sa_family; std::uint16_t port = 0; if (family == AF_INET6) { - inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, - INET6_ADDRSTRLEN); + inet_ntop(AF_INET6, &((sockaddr_in6 *) ip_addr)->sin6_addr, data, INET6_ADDRSTRLEN); port = ((sockaddr_in6 *) ip_addr)->sin6_port; } else if (family == AF_INET) { - inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, - INET_ADDRSTRLEN); + inet_ntop(AF_INET, &((sockaddr_in *) ip_addr)->sin_addr, data, INET_ADDRSTRLEN); port = ((sockaddr_in *) ip_addr)->sin_port; } return { port, std::string { data } }; } - std::string - get_mac_address(const std::string_view &address) { + std::string get_mac_address(const std::string_view &address) { auto ifaddrs = get_ifaddrs(); for (auto pos = ifaddrs.get(); pos != nullptr; pos = pos->ifa_next) { @@ -147,8 +135,17 @@ ptr = (unsigned char *) LLADDR((struct sockaddr_dl *) (ifaptr)->ifa_addr); char buff[100]; - snprintf(buff, sizeof(buff), "%02x:%02x:%02x:%02x:%02x:%02x", - *ptr, *(ptr + 1), *(ptr + 2), *(ptr + 3), *(ptr + 4), *(ptr + 5)); + snprintf( + buff, + sizeof(buff), + "%02x:%02x:%02x:%02x:%02x:%02x", + *ptr, + *(ptr + 1), + *(ptr + 2), + *(ptr + 3), + *(ptr + 4), + *(ptr + 5) + ); mac_address = buff; break; } @@ -168,8 +165,16 @@ return "00:00:00:00:00:00"s; } - bp::child - run_command(bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const bp::environment &env, FILE *file, std::error_code &ec, bp::group *group) { + bp::child run_command( + bool elevated, + bool interactive, + const std::string &cmd, + boost::filesystem::path &working_dir, + const bp::environment &env, + FILE *file, + std::error_code &ec, + bp::group *group + ) { if (!group) { if (!file) { return bp::child(cmd, env, bp::start_dir(working_dir), bp::std_out > bp::null, bp::std_err > bp::null, ec); @@ -180,7 +185,15 @@ } else { if (!file) { - return bp::child(cmd, env, bp::start_dir(working_dir), bp::std_out > bp::null, bp::std_err > bp::null, ec, *group); + return bp::child( + cmd, + env, + bp::start_dir(working_dir), + bp::std_out > bp::null, + bp::std_err > bp::null, + ec, + *group + ); } else { return bp::child(cmd, env, bp::start_dir(working_dir), bp::std_out > file, bp::std_err > file, ec, *group); @@ -192,8 +205,7 @@ * @brief Open a url in the default web browser. * @param url The url to open. */ - void - open_url(const std::string &url) { + void open_url(const std::string &url) { boost::filesystem::path working_dir; std::string cmd = R"(open ")" + url + R"(")"; @@ -209,23 +221,19 @@ } } - void - adjust_thread_priority(thread_priority_e priority) { + void adjust_thread_priority(thread_priority_e priority) { // Unimplemented } - void - streaming_will_start() { + void streaming_will_start() { // Nothing to do } - void - streaming_will_stop() { + void streaming_will_stop() { // Nothing to do } - void - restart_on_exit() { + void restart_on_exit() { char executable[2048]; uint32_t size = sizeof(executable); if (_NSGetExecutablePath(executable, &size) < 0) { @@ -246,8 +254,7 @@ } } - void - restart() { + void restart() { // Gracefully clean up and restart ourselves instead of exiting atexit(restart_on_exit); lifetime::exit_sunshine(0, true); @@ -258,8 +265,7 @@ * @param native_handle The process group ID. * @return true if termination was successfully requested. */ - bool - request_process_group_exit(std::uintptr_t native_handle) { + bool request_process_group_exit(std::uintptr_t native_handle) { if (killpg((pid_t) native_handle, SIGTERM) == 0 || errno == ESRCH) { BOOST_LOG(debug) << "Successfully sent SIGTERM to process group: "sv << native_handle; return true; @@ -275,13 +281,11 @@ * @param native_handle The process group ID. * @return true if processes are still running. */ - bool - process_group_running(std::uintptr_t native_handle) { + bool process_group_running(std::uintptr_t native_handle) { return waitpid(-((pid_t) native_handle), nullptr, WNOHANG) >= 0; } - struct sockaddr_in - to_sockaddr(boost::asio::ip::address_v4 address, uint16_t port) { + struct sockaddr_in to_sockaddr(boost::asio::ip::address_v4 address, uint16_t port) { struct sockaddr_in saddr_v4 = {}; saddr_v4.sin_family = AF_INET; @@ -293,8 +297,7 @@ return saddr_v4; } - struct sockaddr_in6 - to_sockaddr(boost::asio::ip::address_v6 address, uint16_t port) { + struct sockaddr_in6 to_sockaddr(boost::asio::ip::address_v6 address, uint16_t port) { struct sockaddr_in6 saddr_v6 = {}; saddr_v6.sin6_family = AF_INET6; @@ -307,14 +310,12 @@ return saddr_v6; } - bool - send_batch(batched_send_info_t &send_info) { + bool send_batch(batched_send_info_t &send_info) { // Fall back to unbatched send calls return false; } - bool - send(send_info_t &send_info) { + bool send(send_info_t &send_info) { auto sockfd = (int) send_info.native_socket; struct msghdr msg = {}; @@ -415,8 +416,7 @@ class qos_t: public deinit_t { public: - qos_t(int sockfd, std::vector> options): - sockfd(sockfd), options(options) { + qos_t(int sockfd, std::vector> options): sockfd(sockfd), options(options) { qos_ref_count++; } @@ -444,8 +444,13 @@ * @param data_type The type of traffic sent on this socket. * @param dscp_tagging Specifies whether to enable DSCP tagging on outgoing traffic. */ - std::unique_ptr - enable_socket_qos(uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type, bool dscp_tagging) { + std::unique_ptr enable_socket_qos( + uintptr_t native_socket, + boost::asio::ip::address &address, + uint16_t port, + qos_data_type_e data_type, + bool dscp_tagging + ) { int sockfd = (int) native_socket; std::vector> reset_options; @@ -520,8 +525,7 @@ } // namespace platf namespace dyn { - void * - handle(const std::vector &libs) { + void *handle(const std::vector &libs) { void *handle; for (auto lib : libs) { @@ -544,8 +548,7 @@ return nullptr; } - int - load(void *handle, const std::vector> &funcs, bool strict) { + int load(void *handle, const std::vector> &funcs, bool strict) { int err = 0; for (auto &func : funcs) { TUPLE_2D_REF(fn, name, func); diff --git a/src/platform/windows/audio.cpp b/src/platform/windows/audio.cpp index 1653e225ff1..9955a864ba2 100644 --- a/src/platform/windows/audio.cpp +++ b/src/platform/windows/audio.cpp @@ -881,9 +881,8 @@ namespace platf::audio { auto device_description = no_null((LPWSTR) device_desc.prop.pszVal); // Match the user-specified name against any of the user-visible strings - if (std::wcscmp(wstring_name.c_str(), adapter_name) == 0 || - std::wcscmp(wstring_name.c_str(), device_name) == 0 || - std::wcscmp(wstring_name.c_str(), device_description) == 0) { + if (std::wcscmp(wstring_name.c_str(), adapter_name) == 0 || std::wcscmp(wstring_name.c_str(), device_name) == 0 + || std::wcscmp(wstring_name.c_str(), device_description) == 0) { return std::make_optional(std::wstring { wstring_id.get() }); } } diff --git a/src/platform/windows/display_base.cpp b/src/platform/windows/display_base.cpp index 5d57e197513..3b110eea306 100644 --- a/src/platform/windows/display_base.cpp +++ b/src/platform/windows/display_base.cpp @@ -134,7 +134,8 @@ namespace platf::dxgi { // ProtectedContentMaskedOut seems to semi-randomly be TRUE or FALSE even when protected content // is on screen the whole time, so we can't just print when it changes. Instead we'll keep track // of the last time we printed the warning and print another if we haven't printed one recently. - if (frame_info.ProtectedContentMaskedOut && std::chrono::steady_clock::now() > last_protected_content_warning_time + 10s) { + if (frame_info.ProtectedContentMaskedOut + && std::chrono::steady_clock::now() > last_protected_content_warning_time + 10s) { BOOST_LOG(warning) << "Windows is currently blocking DRM-protected content from capture. You may see black regions where this content would be."sv; last_protected_content_warning_time = std::chrono::steady_clock::now(); @@ -678,7 +679,8 @@ namespace platf::dxgi { HANDLE token; LUID val; - if (OpenProcessToken(GetCurrentProcess(), flags, &token) && !!LookupPrivilegeValue(NULL, SE_INC_BASE_PRIORITY_NAME, &val)) { + if (OpenProcessToken(GetCurrentProcess(), flags, &token) + && !!LookupPrivilegeValue(NULL, SE_INC_BASE_PRIORITY_NAME, &val)) { tp.PrivilegeCount = 1; tp.Privileges[0].Luid = val; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; diff --git a/src/platform/windows/display_vram.cpp b/src/platform/windows/display_vram.cpp index 20aef95b0d1..bc319cb0b4f 100644 --- a/src/platform/windows/display_vram.cpp +++ b/src/platform/windows/display_vram.cpp @@ -1048,8 +1048,8 @@ namespace platf::dxgi { auto alpha_cursor_img = make_cursor_alpha_image(img_data, shape_info); auto xor_cursor_img = make_cursor_xor_image(img_data, shape_info); - if (!set_cursor_texture(device.get(), cursor_alpha, std::move(alpha_cursor_img), shape_info) || - !set_cursor_texture(device.get(), cursor_xor, std::move(xor_cursor_img), shape_info)) { + if (!set_cursor_texture(device.get(), cursor_alpha, std::move(alpha_cursor_img), shape_info) + || !set_cursor_texture(device.get(), cursor_xor, std::move(xor_cursor_img), shape_info)) { return capture_e::error; } } diff --git a/src/platform/windows/display_wgc.cpp b/src/platform/windows/display_wgc.cpp index 3c9dec680d9..7f4cc6b09c1 100644 --- a/src/platform/windows/display_wgc.cpp +++ b/src/platform/windows/display_wgc.cpp @@ -34,7 +34,7 @@ namespace winrt { #if WINRT_IMPL_HAS_DECLSPEC_UUID __declspec(uuid("A9B3D012-3DF2-4EE3-B8D1-8695F457D3C1")) #endif - IDirect3DDxgiInterfaceAccess: ::IUnknown { + IDirect3DDxgiInterfaceAccess: ::IUnknown { virtual HRESULT __stdcall GetInterface(REFIID id, void **object) = 0; }; } // namespace winrt @@ -102,7 +102,14 @@ namespace platf::dxgi { display->output->GetDesc(&output_desc); auto monitor_factory = winrt::get_activation_factory(); - if (monitor_factory == nullptr || FAILED(status = monitor_factory->CreateForMonitor(output_desc.Monitor, winrt::guid_of(), winrt::put_abi(item)))) { + if (monitor_factory == nullptr + || FAILED( + status = monitor_factory->CreateForMonitor( + output_desc.Monitor, + winrt::guid_of(), + winrt::put_abi(item) + ) + )) { BOOST_LOG(error) << "Screen capture is not supported on this device for this release of Windows: failed to acquire display: [0x"sv << util::hex(status).to_string_view() << ']'; @@ -187,7 +194,8 @@ namespace platf::dxgi { release_frame(); AcquireSRWLockExclusive(&frame_lock); - if (produced_frame == nullptr && SleepConditionVariableSRW(&frame_present_cv, &frame_lock, timeout.count(), 0) == 0) { + if (produced_frame == nullptr + && SleepConditionVariableSRW(&frame_present_cv, &frame_lock, timeout.count(), 0) == 0) { ReleaseSRWLockExclusive(&frame_lock); if (GetLastError() == ERROR_TIMEOUT) return capture_e::timeout; diff --git a/src/platform/windows/input.cpp b/src/platform/windows/input.cpp index ab1872bb1cf..ea5ce5f04b0 100644 --- a/src/platform/windows/input.cpp +++ b/src/platform/windows/input.cpp @@ -335,8 +335,8 @@ namespace platf { uint16_t normalizedSmallMotor = smallMotor << 8; // Don't resend duplicate rumble data - if (normalizedSmallMotor != gamepad.last_rumble.data.rumble.highfreq || - normalizedLargeMotor != gamepad.last_rumble.data.rumble.lowfreq) { + if (normalizedSmallMotor != gamepad.last_rumble.data.rumble.highfreq + || normalizedLargeMotor != gamepad.last_rumble.data.rumble.lowfreq) { // We have to use the client-relative index when communicating back to the client gamepad_feedback_msg_t msg = gamepad_feedback_msg_t::make_rumble( gamepad.client_relative_index, @@ -364,9 +364,8 @@ namespace platf { if (gamepad.gp.get() == target) { // Don't resend duplicate RGB data - if (r != gamepad.last_rgb_led.data.rgb_led.r || - g != gamepad.last_rgb_led.data.rgb_led.g || - b != gamepad.last_rgb_led.data.rgb_led.b) { + if (r != gamepad.last_rgb_led.data.rgb_led.r || g != gamepad.last_rgb_led.data.rgb_led.g + || b != gamepad.last_rgb_led.data.rgb_led.b) { // We have to use the client-relative index when communicating back to the client gamepad_feedback_msg_t msg = gamepad_feedback_msg_t::make_rgb_led(gamepad.client_relative_index, r, g, b); gamepad.feedback_queue->raise(msg); @@ -738,8 +737,10 @@ namespace platf { // Try to find a matching pointer ID for (UINT32 i = 0; i < ARRAYSIZE(raw->touchInfo); i++) { - if (raw->touchInfo[i].touchInfo.pointerInfo.pointerId == pointerId && raw->touchInfo[i].touchInfo.pointerInfo.pointerFlags != POINTER_FLAG_NONE) { - if (eventType == LI_TOUCH_EVENT_DOWN && (raw->touchInfo[i].touchInfo.pointerInfo.pointerFlags & POINTER_FLAG_INCONTACT)) { + if (raw->touchInfo[i].touchInfo.pointerInfo.pointerId == pointerId + && raw->touchInfo[i].touchInfo.pointerInfo.pointerFlags != POINTER_FLAG_NONE) { + if (eventType == LI_TOUCH_EVENT_DOWN + && (raw->touchInfo[i].touchInfo.pointerInfo.pointerFlags & POINTER_FLAG_INCONTACT)) { BOOST_LOG(warning) << "Pointer "sv << pointerId << " already down. Did the client drop an up/cancel event?"sv; } @@ -912,7 +913,8 @@ namespace platf { auto raw = (client_input_raw_t *) input; // Bail if we're not running on an OS that supports virtual touch input - if (!raw->global->fnCreateSyntheticPointerDevice || !raw->global->fnInjectSyntheticPointerInput || !raw->global->fnDestroySyntheticPointerDevice) { + if (!raw->global->fnCreateSyntheticPointerDevice || !raw->global->fnInjectSyntheticPointerInput + || !raw->global->fnDestroySyntheticPointerDevice) { BOOST_LOG(warning) << "Touch input requires Windows 10 1809 or later"sv; return; } @@ -1053,7 +1055,8 @@ namespace platf { auto raw = (client_input_raw_t *) input; // Bail if we're not running on an OS that supports virtual pen input - if (!raw->global->fnCreateSyntheticPointerDevice || !raw->global->fnInjectSyntheticPointerInput || !raw->global->fnDestroySyntheticPointerDevice) { + if (!raw->global->fnCreateSyntheticPointerDevice || !raw->global->fnInjectSyntheticPointerInput + || !raw->global->fnDestroySyntheticPointerDevice) { BOOST_LOG(warning) << "Pen input requires Windows 10 1809 or later"sv; return; } @@ -1434,7 +1437,8 @@ namespace platf { buttons |= DS4_SPECIAL_BUTTON_TOUCHPAD; // Manual DS4 emulation: check if BACK button should also trigger DS4 touchpad click - if (config::input.gamepad == "ds4"sv && config::input.ds4_back_as_touchpad_click && (gamepad_state.buttonFlags & BACK)) + if (config::input.gamepad == "ds4"sv && config::input.ds4_back_as_touchpad_click + && (gamepad_state.buttonFlags & BACK)) buttons |= DS4_SPECIAL_BUTTON_TOUCHPAD; return (DS4_SPECIAL_BUTTONS) buttons; diff --git a/src/platform/windows/misc.cpp b/src/platform/windows/misc.cpp index 50f11eefa80..054d6428fb6 100644 --- a/src/platform/windows/misc.cpp +++ b/src/platform/windows/misc.cpp @@ -1140,7 +1140,8 @@ namespace platf { fn_WlanEnumInterfaces = (decltype(fn_WlanEnumInterfaces)) GetProcAddress(wlanapi, "WlanEnumInterfaces"); fn_WlanSetInterface = (decltype(fn_WlanSetInterface)) GetProcAddress(wlanapi, "WlanSetInterface"); - if (!fn_WlanOpenHandle || !fn_WlanCloseHandle || !fn_WlanFreeMemory || !fn_WlanEnumInterfaces || !fn_WlanSetInterface) { + if (!fn_WlanOpenHandle || !fn_WlanCloseHandle || !fn_WlanFreeMemory || !fn_WlanEnumInterfaces + || !fn_WlanSetInterface) { BOOST_LOG(error) << "wlanapi.dll is missing exports?"sv; fn_WlanOpenHandle = nullptr; diff --git a/src/platform/windows/nvprefs/driver_settings.cpp b/src/platform/windows/nvprefs/driver_settings.cpp index 7bb8083bd0d..02ebbe0d2a0 100644 --- a/src/platform/windows/nvprefs/driver_settings.cpp +++ b/src/platform/windows/nvprefs/driver_settings.cpp @@ -107,7 +107,8 @@ namespace nvprefs { setting.version = NVDRS_SETTING_VER; status = NvAPI_DRS_GetSetting(session_handle, profile_handle, OGL_CPL_PREFER_DXPRESENT_ID, &setting); - if (status == NVAPI_OK && setting.settingLocation == NVDRS_CURRENT_PROFILE_LOCATION && setting.u32CurrentValue == swapchain_data->our_value) { + if (status == NVAPI_OK && setting.settingLocation == NVDRS_CURRENT_PROFILE_LOCATION + && setting.u32CurrentValue == swapchain_data->our_value) { if (swapchain_data->undo_value) { setting = {}; setting.version = NVDRS_SETTING_VER1; @@ -173,7 +174,8 @@ namespace nvprefs { status = NvAPI_DRS_GetSetting(session_handle, profile_handle, OGL_CPL_PREFER_DXPRESENT_ID, &setting); // Remember current OpenGL/Vulkan DXGI swapchain setting and change it if needed - if (status == NVAPI_SETTING_NOT_FOUND || (status == NVAPI_OK && setting.u32CurrentValue != OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED)) { + if (status == NVAPI_SETTING_NOT_FOUND + || (status == NVAPI_OK && setting.u32CurrentValue != OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED)) { undo_data = undo_data_t(); if (status == NVAPI_OK) { undo_data->set_opengl_swapchain(OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED, setting.u32CurrentValue); @@ -278,7 +280,8 @@ namespace nvprefs { info_message(std::wstring(L"Removed PREFERRED_PSTATE for ") + sunshine_application_path); } } - else if (status != NVAPI_OK || setting.settingLocation != NVDRS_CURRENT_PROFILE_LOCATION || setting.u32CurrentValue != PREFERRED_PSTATE_PREFER_MAX) { + else if (status != NVAPI_OK || setting.settingLocation != NVDRS_CURRENT_PROFILE_LOCATION + || setting.u32CurrentValue != PREFERRED_PSTATE_PREFER_MAX) { // Set power setting if needed setting = {}; setting.version = NVDRS_SETTING_VER1; diff --git a/src/platform/windows/nvprefs/nvprefs_interface.cpp b/src/platform/windows/nvprefs/nvprefs_interface.cpp index 3ad01737d69..a195ecad577 100644 --- a/src/platform/windows/nvprefs/nvprefs_interface.cpp +++ b/src/platform/windows/nvprefs/nvprefs_interface.cpp @@ -73,7 +73,8 @@ namespace nvprefs { // Try to restore from the undo file info_message("Opened undo file from previous improper termination"); if (auto undo_data = undo_file->read_undo_data()) { - if (pimpl->driver_settings.restore_global_profile_to_undo(*undo_data) && pimpl->driver_settings.save_settings()) { + if (pimpl->driver_settings.restore_global_profile_to_undo(*undo_data) + && pimpl->driver_settings.save_settings()) { info_message("Restored global profile settings from undo file - deleting the file"); } else { @@ -200,7 +201,8 @@ namespace nvprefs { return false; // Restore global profile settings with undo data - if (pimpl->driver_settings.restore_global_profile_to_undo(*pimpl->undo_data) && pimpl->driver_settings.save_settings()) { + if (pimpl->driver_settings.restore_global_profile_to_undo(*pimpl->undo_data) + && pimpl->driver_settings.save_settings()) { // Global profile settings sucessfully restored, can delete undo file if (!pimpl->undo_file->delete_file()) { error_message("Couldn't delete undo file"); diff --git a/src/platform/windows/nvprefs/undo_file.cpp b/src/platform/windows/nvprefs/undo_file.cpp index 331f9ee8480..4d0682b8a86 100644 --- a/src/platform/windows/nvprefs/undo_file.cpp +++ b/src/platform/windows/nvprefs/undo_file.cpp @@ -150,7 +150,8 @@ namespace nvprefs { } DWORD bytes_written = 0; - if (!WriteFile(file_handle.get(), buffer.data(), buffer.size(), &bytes_written, nullptr) || bytes_written != buffer.size()) { + if (!WriteFile(file_handle.get(), buffer.data(), buffer.size(), &bytes_written, nullptr) + || bytes_written != buffer.size()) { error_message("Couldn't write undo file"); return false; } @@ -179,7 +180,8 @@ namespace nvprefs { std::vector buffer(file_size.QuadPart); DWORD bytes_read = 0; - if (!ReadFile(file_handle.get(), buffer.data(), buffer.size(), &bytes_read, nullptr) || bytes_read != buffer.size()) { + if (!ReadFile(file_handle.get(), buffer.data(), buffer.size(), &bytes_read, nullptr) + || bytes_read != buffer.size()) { error_message("Couldn't read undo file"); return std::nullopt; } diff --git a/src/process.cpp b/src/process.cpp index 12d157894c2..ab94904e5c0 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -280,7 +280,8 @@ namespace proc { if (placebo) { return _app_id; } - else if (_app.wait_all && _process_group && platf::process_group_running((std::uintptr_t) _process_group.native_handle())) { + else if (_app.wait_all && _process_group + && platf::process_group_running((std::uintptr_t) _process_group.native_handle())) { // The app is still running if any process in the group is still running return _app_id; } @@ -288,7 +289,8 @@ namespace proc { // The app is still running only if the initial process launched is still running return _app_id; } - else if (_app.auto_detach && _process.native_exit_code() == 0 && std::chrono::steady_clock::now() - _app_launch_time < 5s) { + else if (_app.auto_detach && _process.native_exit_code() == 0 + && std::chrono::steady_clock::now() - _app_launch_time < 5s) { BOOST_LOG(info) << "App exited gracefully within 5 seconds of launch. Treating the app as a detached command."sv; BOOST_LOG(info) << "Adjust this behavior in the Applications tab or apps.json if this is not what you want."sv; placebo = true; diff --git a/src/server/confighttp.cpp b/src/server/confighttp.cpp index e134f4cdd8c..3948137c337 100644 --- a/src/server/confighttp.cpp +++ b/src/server/confighttp.cpp @@ -641,7 +641,8 @@ namespace confighttp { } else { auto hash = util::hex(crypto::hash(password + config::sunshine.salt)).to_string(); - if (config::sunshine.username.empty() || (boost::iequals(username, config::sunshine.username) && hash == config::sunshine.password)) { + if (config::sunshine.username.empty() + || (boost::iequals(username, config::sunshine.username) && hash == config::sunshine.password)) { if (newPassword.empty() || newPassword != confirmPassword) { outputTree.put("status", false); outputTree.put("error", "Password Mismatch"); diff --git a/src/server/crypto.cpp b/src/server/crypto.cpp index 40e8e39c8a9..d9c04dcd257 100644 --- a/src/server/crypto.cpp +++ b/src/server/crypto.cpp @@ -155,11 +155,19 @@ namespace crypto { int update_outlen, final_outlen; - if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), cipher.size()) != 1) { + if (EVP_DecryptUpdate( + decrypt_ctx.get(), + plaintext.data(), + &update_outlen, + (const std::uint8_t *) cipher.data(), + cipher.size() + ) + != 1) { return -1; } - if (EVP_CIPHER_CTX_ctrl(decrypt_ctx.get(), EVP_CTRL_GCM_SET_TAG, tag.size(), const_cast(tag.data())) != 1) { + if (EVP_CIPHER_CTX_ctrl(decrypt_ctx.get(), EVP_CTRL_GCM_SET_TAG, tag.size(), const_cast(tag.data())) + != 1) { return -1; } @@ -188,7 +196,14 @@ namespace crypto { int update_outlen, final_outlen; // Encrypt into the caller's buffer - if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) { + if (EVP_EncryptUpdate( + encrypt_ctx.get(), + cipher, + &update_outlen, + (const std::uint8_t *) plaintext.data(), + plaintext.size() + ) + != 1) { return -1; } @@ -219,7 +234,14 @@ namespace crypto { int update_outlen, final_outlen; - if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), cipher.size()) != 1) { + if (EVP_DecryptUpdate( + decrypt_ctx.get(), + plaintext.data(), + &update_outlen, + (const std::uint8_t *) cipher.data(), + cipher.size() + ) + != 1) { return -1; } @@ -247,7 +269,14 @@ namespace crypto { int update_outlen, final_outlen; // Encrypt into the caller's buffer - if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher.data(), &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) { + if (EVP_EncryptUpdate( + encrypt_ctx.get(), + cipher.data(), + &update_outlen, + (const std::uint8_t *) plaintext.data(), + plaintext.size() + ) + != 1) { return -1; } @@ -273,7 +302,14 @@ namespace crypto { int update_outlen, final_outlen; // Encrypt into the caller's buffer - if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) { + if (EVP_EncryptUpdate( + encrypt_ctx.get(), + cipher, + &update_outlen, + (const std::uint8_t *) plaintext.data(), + plaintext.size() + ) + != 1) { return -1; } diff --git a/src/server/nvhttp.cpp b/src/server/nvhttp.cpp index fc1dad31091..db8b6564e0e 100644 --- a/src/server/nvhttp.cpp +++ b/src/server/nvhttp.cpp @@ -465,7 +465,8 @@ namespace nvhttp { auto hash = crypto::hash(data); // if hash not correct, probably MITM - if (!std::memcmp(hash.data(), sess.clienthash.data(), hash.size()) && crypto::verify256(crypto::x509(client.cert), secret, sign)) { + if (!std::memcmp(hash.data(), sess.clienthash.data(), hash.size()) + && crypto::verify256(crypto::x509(client.cert), secret, sign)) { tree.put("root.paired", 1); add_cert->raise(crypto::x509(client.cert)); @@ -851,7 +852,8 @@ namespace nvhttp { } auto args = request->parse_query_string(); - if (args.find("rikey"s) == std::end(args) || args.find("rikeyid"s) == std::end(args) || args.find("localAudioPlayMode"s) == std::end(args) || args.find("appid"s) == std::end(args)) { + if (args.find("rikey"s) == std::end(args) || args.find("rikeyid"s) == std::end(args) + || args.find("localAudioPlayMode"s) == std::end(args) || args.find("appid"s) == std::end(args)) { tree.put("root.resume", 0); tree.put("root..status_code", 400); tree.put("root..status_message", "Missing a required launch parameter"); diff --git a/src/server/rtsp.cpp b/src/server/rtsp.cpp index 9a4c995f27c..5cb1fc043ba 100644 --- a/src/server/rtsp.cpp +++ b/src/server/rtsp.cpp @@ -102,7 +102,8 @@ namespace rtsp_stream { * @brief Queues an asynchronous read to begin the next message. */ void read() { - if (begin == std::end(msg_buf) || (session->rtsp_cipher && begin + sizeof(encrypted_rtsp_header_t) >= std::end(msg_buf))) { + if (begin == std::end(msg_buf) + || (session->rtsp_cipher && begin + sizeof(encrypted_rtsp_header_t) >= std::end(msg_buf))) { BOOST_LOG(error) << "RTSP: read(): Exceeded maximum rtsp packet size: "sv << msg_buf.size(); respond(sock, *session, nullptr, 400, "BAD REQUEST", 0, {}); @@ -328,7 +329,8 @@ namespace rtsp_stream { auto end = socket->begin + bytes; msg_t req { new msg_t::element_type {} }; - if (auto status = parseRtspMessage(req.get(), socket->msg_buf.data(), (std::size_t)(end - socket->msg_buf.data()))) { + if (auto status + = parseRtspMessage(req.get(), socket->msg_buf.data(), (std::size_t)(end - socket->msg_buf.data()))) { BOOST_LOG(error) << "Malformed RTSP message: ["sv << status << ']'; respond(socket->sock, *socket->session, nullptr, 400, "BAD REQUEST", 0, {}); @@ -1139,7 +1141,8 @@ namespace rtsp_stream { // Check that any required encryption is enabled auto encryption_mode = net::encryption_mode_for_address(sock.remote_endpoint().address()); - if (encryption_mode == config::ENCRYPTION_MODE_MANDATORY && (config.encryptionFlagsEnabled & (SS_ENC_VIDEO | SS_ENC_AUDIO)) != (SS_ENC_VIDEO | SS_ENC_AUDIO)) { + if (encryption_mode == config::ENCRYPTION_MODE_MANDATORY + && (config.encryptionFlagsEnabled & (SS_ENC_VIDEO | SS_ENC_AUDIO)) != (SS_ENC_VIDEO | SS_ENC_AUDIO)) { BOOST_LOG(error) << "Rejecting client that cannot comply with mandatory encryption requirement"sv; respond(sock, session, &option, 403, "Forbidden", req->sequenceNumber, {}); diff --git a/src/video.cpp b/src/video.cpp index 978a3240b44..b1f62e08454 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -2647,13 +2647,15 @@ namespace video { } // Skip it if it doesn't support the specified codec at all - if ((active_hevc_mode >= 2 && !encoder->hevc[encoder_t::PASSED]) || (active_av1_mode >= 2 && !encoder->av1[encoder_t::PASSED])) { + if ((active_hevc_mode >= 2 && !encoder->hevc[encoder_t::PASSED]) + || (active_av1_mode >= 2 && !encoder->av1[encoder_t::PASSED])) { pos++; continue; } // Skip it if it doesn't support HDR on the specified codec - if ((active_hevc_mode == 3 && !encoder->hevc[encoder_t::DYNAMIC_RANGE]) || (active_av1_mode == 3 && !encoder->av1[encoder_t::DYNAMIC_RANGE])) { + if ((active_hevc_mode == 3 && !encoder->hevc[encoder_t::DYNAMIC_RANGE]) + || (active_av1_mode == 3 && !encoder->av1[encoder_t::DYNAMIC_RANGE])) { pos++; continue; } diff --git a/third-party/nvfbc/NvFBC.h b/third-party/nvfbc/NvFBC.h index e230555381d..4e31253d600 100644 --- a/third-party/nvfbc/NvFBC.h +++ b/third-party/nvfbc/NvFBC.h @@ -270,8 +270,7 @@ extern "C" { /*! * Creates a version number for structure parameters. */ -#define NVFBC_STRUCT_VERSION(typeName, ver) \ - (uint32_t)(sizeof(typeName) | ((ver) << 16) | (NVFBC_VERSION << 24)) +#define NVFBC_STRUCT_VERSION(typeName, ver) (uint32_t)(sizeof(typeName) | ((ver) << 16) | (NVFBC_VERSION << 24)) /*! * Defines error codes. @@ -1525,8 +1524,7 @@ typedef struct _NVFBC_TOGL_GRAB_FRAME_PARAMS { * A NULL terminated error message, or an empty string. Its maximum length * is NVFBC_ERROR_STR_LEN. */ -const char *NVFBCAPI -NvFBCGetLastErrorStr(const NVFBC_SESSION_HANDLE sessionHandle); +const char *NVFBCAPI NvFBCGetLastErrorStr(const NVFBC_SESSION_HANDLE sessionHandle); /*! * \brief Allocates a new handle for an NvFBC client. @@ -1552,8 +1550,7 @@ NvFBCGetLastErrorStr(const NVFBC_SESSION_HANDLE sessionHandle); * ::NVFBC_ERR_GL * */ -NVFBCSTATUS NVFBCAPI -NvFBCCreateHandle(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCCreateHandle(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams); /*! * \brief Destroys the handle of an NvFBC client. @@ -1579,8 +1576,7 @@ NvFBCCreateHandle(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARA * ::NVFBC_ERR_CONTEXT \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCDestroyHandle(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDLE_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCDestroyHandle(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDLE_PARAMS *pParams); /*! * \brief Gets the current status of the display driver. @@ -1599,8 +1595,7 @@ NvFBCDestroyHandle(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDL * ::NVFBC_ERR_INTERNAL \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCGetStatus(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCGetStatus(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams); /*! * \brief Binds the FBC context to the calling thread. @@ -1634,8 +1629,7 @@ NvFBCGetStatus(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS * ::NVFBC_ERR_INTERNAL \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCBindContext(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCBindContext(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams); /*! * \brief Releases the FBC context from the calling thread. @@ -1750,8 +1744,7 @@ NvFBCDestroyCaptureSession(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTR * ::NVFBC_ERR_OUT_OF_MEMORY \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCToSysSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCToSysSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams); /*! * \brief Captures a frame to a buffer in system memory. @@ -1819,8 +1812,7 @@ NvFBCToSysGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_GRAB_F * ::NVFBC_ERR_GL \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCToCudaSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCToCudaSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams); /*! * \brief Captures a frame to a CUDA device in video memory. @@ -1877,8 +1869,7 @@ NvFBCToCudaGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_GRAB * ::NVFBC_ERR_GL \n * ::NVFBC_ERR_X */ -NVFBCSTATUS NVFBCAPI -NvFBCToGLSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams); +NVFBCSTATUS NVFBCAPI NvFBCToGLSetUp(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams); /*! * \brief Captures a frame to an OpenGL buffer in video memory. @@ -1915,19 +1906,46 @@ NvFBCToGLGrabFrame(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_GRAB_FRA * Defines API function pointers */ typedef const char *(NVFBCAPI *PNVFBCGETLASTERRORSTR)(const NVFBC_SESSION_HANDLE sessionHandle); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCCREATEHANDLE)(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCDESTROYHANDLE)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_HANDLE_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCBINDCONTEXT)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCRELEASECONTEXT)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_RELEASE_CONTEXT_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCGETSTATUS)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCCREATECAPTURESESSION)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_CREATE_CAPTURE_SESSION_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCDESTROYCAPTURESESSION)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_DESTROY_CAPTURE_SESSION_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOSYSSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOSYSGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_GRAB_FRAME_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOCUDASETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOCUDAGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_GRAB_FRAME_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOGLSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams); -typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOGLGRABFRAME)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_GRAB_FRAME_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCCREATEHANDLE)(NVFBC_SESSION_HANDLE *pSessionHandle, NVFBC_CREATE_HANDLE_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCDESTROYHANDLE)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_DESTROY_HANDLE_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCBINDCONTEXT)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_BIND_CONTEXT_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCRELEASECONTEXT)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_RELEASE_CONTEXT_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCGETSTATUS)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_GET_STATUS_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCCREATECAPTURESESSION)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_CREATE_CAPTURE_SESSION_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCDESTROYCAPTURESESSION)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_DESTROY_CAPTURE_SESSION_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCTOSYSSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOSYS_SETUP_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOSYSGRABFRAME)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_TOSYS_GRAB_FRAME_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCTOCUDASETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOCUDA_SETUP_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOCUDAGRABFRAME)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_TOCUDA_GRAB_FRAME_PARAMS *pParams +); +typedef NVFBCSTATUS(NVFBCAPI + *PNVFBCTOGLSETUP)(const NVFBC_SESSION_HANDLE sessionHandle, NVFBC_TOGL_SETUP_PARAMS *pParams); +typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOGLGRABFRAME)( + const NVFBC_SESSION_HANDLE sessionHandle, + NVFBC_TOGL_GRAB_FRAME_PARAMS *pParams +); /// \endcond @@ -1938,8 +1956,7 @@ typedef NVFBCSTATUS(NVFBCAPI *PNVFBCTOGLGRABFRAME)(const NVFBC_SESSION_HANDLE se * * Structure populated with API function pointers. */ -typedef struct -{ +typedef struct { uint32_t dwVersion; //!< [in] Must be set to NVFBC_VERSION. PNVFBCGETLASTERRORSTR nvFBCGetLastErrorStr; //!< [out] Pointer to ::NvFBCGetLastErrorStr(). PNVFBCCREATEHANDLE nvFBCCreateHandle; //!< [out] Pointer to ::NvFBCCreateHandle(). @@ -1980,8 +1997,7 @@ typedef struct * ::NVFBC_ERR_INVALID_PTR \n * ::NVFBC_ERR_API_VERSION */ -NVFBCSTATUS NVFBCAPI -NvFBCCreateInstance(NVFBC_API_FUNCTION_LIST *pFunctionList); +NVFBCSTATUS NVFBCAPI NvFBCCreateInstance(NVFBC_API_FUNCTION_LIST *pFunctionList); /*! * \ingroup FBC_FUNC * diff --git a/third-party/nvfbc/helper_math.h b/third-party/nvfbc/helper_math.h index aaebf4aa36c..bf434a3fbb0 100644 --- a/third-party/nvfbc/helper_math.h +++ b/third-party/nvfbc/helper_math.h @@ -55,28 +55,23 @@ typedef unsigned short ushort; // host implementations of CUDA functions //////////////////////////////////////////////////////////////////////////////// -inline float -fminf(float a, float b) { +inline float fminf(float a, float b) { return a < b ? a : b; } -inline float -fmaxf(float a, float b) { +inline float fmaxf(float a, float b) { return a > b ? a : b; } -inline int -max(int a, int b) { +inline int max(int a, int b) { return a > b ? a : b; } -inline int -min(int a, int b) { +inline int min(int a, int b) { return a < b ? a : b; } -inline float -rsqrtf(float x) { +inline float rsqrtf(float x) { return 1.0f / sqrtf(x); } #endif @@ -85,176 +80,135 @@ rsqrtf(float x) { // constructors //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -make_float2(float s) { +inline __host__ __device__ float2 make_float2(float s) { return make_float2(s, s); } -inline __host__ __device__ float2 -make_float2(float3 a) { +inline __host__ __device__ float2 make_float2(float3 a) { return make_float2(a.x, a.y); } -inline __host__ __device__ float2 -make_float2(int2 a) { +inline __host__ __device__ float2 make_float2(int2 a) { return make_float2(float(a.x), float(a.y)); } -inline __host__ __device__ float2 -make_float2(uint2 a) { +inline __host__ __device__ float2 make_float2(uint2 a) { return make_float2(float(a.x), float(a.y)); } -inline __host__ __device__ int2 -make_int2(int s) { +inline __host__ __device__ int2 make_int2(int s) { return make_int2(s, s); } -inline __host__ __device__ int2 -make_int2(int3 a) { +inline __host__ __device__ int2 make_int2(int3 a) { return make_int2(a.x, a.y); } -inline __host__ __device__ int2 -make_int2(uint2 a) { +inline __host__ __device__ int2 make_int2(uint2 a) { return make_int2(int(a.x), int(a.y)); } -inline __host__ __device__ int2 -make_int2(float2 a) { +inline __host__ __device__ int2 make_int2(float2 a) { return make_int2(int(a.x), int(a.y)); } -inline __host__ __device__ uint2 -make_uint2(uint s) { +inline __host__ __device__ uint2 make_uint2(uint s) { return make_uint2(s, s); } -inline __host__ __device__ uint2 -make_uint2(uint3 a) { +inline __host__ __device__ uint2 make_uint2(uint3 a) { return make_uint2(a.x, a.y); } -inline __host__ __device__ uint2 -make_uint2(int2 a) { +inline __host__ __device__ uint2 make_uint2(int2 a) { return make_uint2(uint(a.x), uint(a.y)); } -inline __host__ __device__ float3 -make_float3(float s) { +inline __host__ __device__ float3 make_float3(float s) { return make_float3(s, s, s); } -inline __host__ __device__ float3 -make_float3(float2 a) { +inline __host__ __device__ float3 make_float3(float2 a) { return make_float3(a.x, a.y, 0.0f); } -inline __host__ __device__ float3 -make_float3(float2 a, float s) { +inline __host__ __device__ float3 make_float3(float2 a, float s) { return make_float3(a.x, a.y, s); } -inline __host__ __device__ float3 -make_float3(float4 a) { +inline __host__ __device__ float3 make_float3(float4 a) { return make_float3(a.x, a.y, a.z); } -inline __host__ __device__ float3 -make_float3(int3 a) { +inline __host__ __device__ float3 make_float3(int3 a) { return make_float3(float(a.x), float(a.y), float(a.z)); } -inline __host__ __device__ float3 -make_float3(uint3 a) { +inline __host__ __device__ float3 make_float3(uint3 a) { return make_float3(float(a.x), float(a.y), float(a.z)); } -inline __host__ __device__ int3 -make_int3(int s) { +inline __host__ __device__ int3 make_int3(int s) { return make_int3(s, s, s); } -inline __host__ __device__ int3 -make_int3(int2 a) { +inline __host__ __device__ int3 make_int3(int2 a) { return make_int3(a.x, a.y, 0); } -inline __host__ __device__ int3 -make_int3(int2 a, int s) { +inline __host__ __device__ int3 make_int3(int2 a, int s) { return make_int3(a.x, a.y, s); } -inline __host__ __device__ int3 -make_int3(uint3 a) { +inline __host__ __device__ int3 make_int3(uint3 a) { return make_int3(int(a.x), int(a.y), int(a.z)); } -inline __host__ __device__ int3 -make_int3(float3 a) { +inline __host__ __device__ int3 make_int3(float3 a) { return make_int3(int(a.x), int(a.y), int(a.z)); } -inline __host__ __device__ uint3 -make_uint3(uint s) { +inline __host__ __device__ uint3 make_uint3(uint s) { return make_uint3(s, s, s); } -inline __host__ __device__ uint3 -make_uint3(uint2 a) { +inline __host__ __device__ uint3 make_uint3(uint2 a) { return make_uint3(a.x, a.y, 0); } -inline __host__ __device__ uint3 -make_uint3(uint2 a, uint s) { +inline __host__ __device__ uint3 make_uint3(uint2 a, uint s) { return make_uint3(a.x, a.y, s); } -inline __host__ __device__ uint3 -make_uint3(uint4 a) { +inline __host__ __device__ uint3 make_uint3(uint4 a) { return make_uint3(a.x, a.y, a.z); } -inline __host__ __device__ uint3 -make_uint3(int3 a) { +inline __host__ __device__ uint3 make_uint3(int3 a) { return make_uint3(uint(a.x), uint(a.y), uint(a.z)); } -inline __host__ __device__ float4 -make_float4(float s) { +inline __host__ __device__ float4 make_float4(float s) { return make_float4(s, s, s, s); } -inline __host__ __device__ float4 -make_float4(float3 a) { +inline __host__ __device__ float4 make_float4(float3 a) { return make_float4(a.x, a.y, a.z, 0.0f); } -inline __host__ __device__ float4 -make_float4(float3 a, float w) { +inline __host__ __device__ float4 make_float4(float3 a, float w) { return make_float4(a.x, a.y, a.z, w); } -inline __host__ __device__ float4 -make_float4(int4 a) { +inline __host__ __device__ float4 make_float4(int4 a) { return make_float4(float(a.x), float(a.y), float(a.z), float(a.w)); } -inline __host__ __device__ float4 -make_float4(uint4 a) { +inline __host__ __device__ float4 make_float4(uint4 a) { return make_float4(float(a.x), float(a.y), float(a.z), float(a.w)); } -inline __host__ __device__ int4 -make_int4(int s) { +inline __host__ __device__ int4 make_int4(int s) { return make_int4(s, s, s, s); } -inline __host__ __device__ int4 -make_int4(int3 a) { +inline __host__ __device__ int4 make_int4(int3 a) { return make_int4(a.x, a.y, a.z, 0); } -inline __host__ __device__ int4 -make_int4(int3 a, int w) { +inline __host__ __device__ int4 make_int4(int3 a, int w) { return make_int4(a.x, a.y, a.z, w); } -inline __host__ __device__ int4 -make_int4(uint4 a) { +inline __host__ __device__ int4 make_int4(uint4 a) { return make_int4(int(a.x), int(a.y), int(a.z), int(a.w)); } -inline __host__ __device__ int4 -make_int4(float4 a) { +inline __host__ __device__ int4 make_int4(float4 a) { return make_int4(int(a.x), int(a.y), int(a.z), int(a.w)); } -inline __host__ __device__ uint4 -make_uint4(uint s) { +inline __host__ __device__ uint4 make_uint4(uint s) { return make_uint4(s, s, s, s); } -inline __host__ __device__ uint4 -make_uint4(uint3 a) { +inline __host__ __device__ uint4 make_uint4(uint3 a) { return make_uint4(a.x, a.y, a.z, 0); } -inline __host__ __device__ uint4 -make_uint4(uint3 a, uint w) { +inline __host__ __device__ uint4 make_uint4(uint3 a, uint w) { return make_uint4(a.x, a.y, a.z, w); } -inline __host__ __device__ uint4 -make_uint4(int4 a) { +inline __host__ __device__ uint4 make_uint4(int4 a) { return make_uint4(uint(a.x), uint(a.y), uint(a.z), uint(a.w)); } @@ -262,28 +216,22 @@ make_uint4(int4 a) { // negate //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -operator-(float2 &a) { +inline __host__ __device__ float2 operator-(float2 &a) { return make_float2(-a.x, -a.y); } -inline __host__ __device__ int2 -operator-(int2 &a) { +inline __host__ __device__ int2 operator-(int2 &a) { return make_int2(-a.x, -a.y); } -inline __host__ __device__ float3 -operator-(float3 &a) { +inline __host__ __device__ float3 operator-(float3 &a) { return make_float3(-a.x, -a.y, -a.z); } -inline __host__ __device__ int3 -operator-(int3 &a) { +inline __host__ __device__ int3 operator-(int3 &a) { return make_int3(-a.x, -a.y, -a.z); } -inline __host__ __device__ float4 -operator-(float4 &a) { +inline __host__ __device__ float4 operator-(float4 &a) { return make_float4(-a.x, -a.y, -a.z, -a.w); } -inline __host__ __device__ int4 -operator-(int4 &a) { +inline __host__ __device__ int4 operator-(int4 &a) { return make_int4(-a.x, -a.y, -a.z, -a.w); } @@ -291,226 +239,181 @@ operator-(int4 &a) { // addition //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -operator+(float2 a, float2 b) { +inline __host__ __device__ float2 operator+(float2 a, float2 b) { return make_float2(a.x + b.x, a.y + b.y); } -inline __host__ __device__ void -operator+=(float2 &a, float2 b) { +inline __host__ __device__ void operator+=(float2 &a, float2 b) { a.x += b.x; a.y += b.y; } -inline __host__ __device__ float2 -operator+(float2 a, float b) { +inline __host__ __device__ float2 operator+(float2 a, float b) { return make_float2(a.x + b, a.y + b); } -inline __host__ __device__ float2 -operator+(float b, float2 a) { +inline __host__ __device__ float2 operator+(float b, float2 a) { return make_float2(a.x + b, a.y + b); } -inline __host__ __device__ void -operator+=(float2 &a, float b) { +inline __host__ __device__ void operator+=(float2 &a, float b) { a.x += b; a.y += b; } -inline __host__ __device__ int2 -operator+(int2 a, int2 b) { +inline __host__ __device__ int2 operator+(int2 a, int2 b) { return make_int2(a.x + b.x, a.y + b.y); } -inline __host__ __device__ void -operator+=(int2 &a, int2 b) { +inline __host__ __device__ void operator+=(int2 &a, int2 b) { a.x += b.x; a.y += b.y; } -inline __host__ __device__ int2 -operator+(int2 a, int b) { +inline __host__ __device__ int2 operator+(int2 a, int b) { return make_int2(a.x + b, a.y + b); } -inline __host__ __device__ int2 -operator+(int b, int2 a) { +inline __host__ __device__ int2 operator+(int b, int2 a) { return make_int2(a.x + b, a.y + b); } -inline __host__ __device__ void -operator+=(int2 &a, int b) { +inline __host__ __device__ void operator+=(int2 &a, int b) { a.x += b; a.y += b; } -inline __host__ __device__ uint2 -operator+(uint2 a, uint2 b) { +inline __host__ __device__ uint2 operator+(uint2 a, uint2 b) { return make_uint2(a.x + b.x, a.y + b.y); } -inline __host__ __device__ void -operator+=(uint2 &a, uint2 b) { +inline __host__ __device__ void operator+=(uint2 &a, uint2 b) { a.x += b.x; a.y += b.y; } -inline __host__ __device__ uint2 -operator+(uint2 a, uint b) { +inline __host__ __device__ uint2 operator+(uint2 a, uint b) { return make_uint2(a.x + b, a.y + b); } -inline __host__ __device__ uint2 -operator+(uint b, uint2 a) { +inline __host__ __device__ uint2 operator+(uint b, uint2 a) { return make_uint2(a.x + b, a.y + b); } -inline __host__ __device__ void -operator+=(uint2 &a, uint b) { +inline __host__ __device__ void operator+=(uint2 &a, uint b) { a.x += b; a.y += b; } -inline __host__ __device__ float3 -operator+(float3 a, float3 b) { +inline __host__ __device__ float3 operator+(float3 a, float3 b) { return make_float3(a.x + b.x, a.y + b.y, a.z + b.z); } -inline __host__ __device__ void -operator+=(float3 &a, float3 b) { +inline __host__ __device__ void operator+=(float3 &a, float3 b) { a.x += b.x; a.y += b.y; a.z += b.z; } -inline __host__ __device__ float3 -operator+(float3 a, float b) { +inline __host__ __device__ float3 operator+(float3 a, float b) { return make_float3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ void -operator+=(float3 &a, float b) { +inline __host__ __device__ void operator+=(float3 &a, float b) { a.x += b; a.y += b; a.z += b; } -inline __host__ __device__ int3 -operator+(int3 a, int3 b) { +inline __host__ __device__ int3 operator+(int3 a, int3 b) { return make_int3(a.x + b.x, a.y + b.y, a.z + b.z); } -inline __host__ __device__ void -operator+=(int3 &a, int3 b) { +inline __host__ __device__ void operator+=(int3 &a, int3 b) { a.x += b.x; a.y += b.y; a.z += b.z; } -inline __host__ __device__ int3 -operator+(int3 a, int b) { +inline __host__ __device__ int3 operator+(int3 a, int b) { return make_int3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ void -operator+=(int3 &a, int b) { +inline __host__ __device__ void operator+=(int3 &a, int b) { a.x += b; a.y += b; a.z += b; } -inline __host__ __device__ uint3 -operator+(uint3 a, uint3 b) { +inline __host__ __device__ uint3 operator+(uint3 a, uint3 b) { return make_uint3(a.x + b.x, a.y + b.y, a.z + b.z); } -inline __host__ __device__ void -operator+=(uint3 &a, uint3 b) { +inline __host__ __device__ void operator+=(uint3 &a, uint3 b) { a.x += b.x; a.y += b.y; a.z += b.z; } -inline __host__ __device__ uint3 -operator+(uint3 a, uint b) { +inline __host__ __device__ uint3 operator+(uint3 a, uint b) { return make_uint3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ void -operator+=(uint3 &a, uint b) { +inline __host__ __device__ void operator+=(uint3 &a, uint b) { a.x += b; a.y += b; a.z += b; } -inline __host__ __device__ int3 -operator+(int b, int3 a) { +inline __host__ __device__ int3 operator+(int b, int3 a) { return make_int3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ uint3 -operator+(uint b, uint3 a) { +inline __host__ __device__ uint3 operator+(uint b, uint3 a) { return make_uint3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ float3 -operator+(float b, float3 a) { +inline __host__ __device__ float3 operator+(float b, float3 a) { return make_float3(a.x + b, a.y + b, a.z + b); } -inline __host__ __device__ float4 -operator+(float4 a, float4 b) { +inline __host__ __device__ float4 operator+(float4 a, float4 b) { return make_float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } -inline __host__ __device__ void -operator+=(float4 &a, float4 b) { +inline __host__ __device__ void operator+=(float4 &a, float4 b) { a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w; } -inline __host__ __device__ float4 -operator+(float4 a, float b) { +inline __host__ __device__ float4 operator+(float4 a, float b) { return make_float4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ float4 -operator+(float b, float4 a) { +inline __host__ __device__ float4 operator+(float b, float4 a) { return make_float4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ void -operator+=(float4 &a, float b) { +inline __host__ __device__ void operator+=(float4 &a, float b) { a.x += b; a.y += b; a.z += b; a.w += b; } -inline __host__ __device__ int4 -operator+(int4 a, int4 b) { +inline __host__ __device__ int4 operator+(int4 a, int4 b) { return make_int4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } -inline __host__ __device__ void -operator+=(int4 &a, int4 b) { +inline __host__ __device__ void operator+=(int4 &a, int4 b) { a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w; } -inline __host__ __device__ int4 -operator+(int4 a, int b) { +inline __host__ __device__ int4 operator+(int4 a, int b) { return make_int4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ int4 -operator+(int b, int4 a) { +inline __host__ __device__ int4 operator+(int b, int4 a) { return make_int4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ void -operator+=(int4 &a, int b) { +inline __host__ __device__ void operator+=(int4 &a, int b) { a.x += b; a.y += b; a.z += b; a.w += b; } -inline __host__ __device__ uint4 -operator+(uint4 a, uint4 b) { +inline __host__ __device__ uint4 operator+(uint4 a, uint4 b) { return make_uint4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); } -inline __host__ __device__ void -operator+=(uint4 &a, uint4 b) { +inline __host__ __device__ void operator+=(uint4 &a, uint4 b) { a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w; } -inline __host__ __device__ uint4 -operator+(uint4 a, uint b) { +inline __host__ __device__ uint4 operator+(uint4 a, uint b) { return make_uint4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ uint4 -operator+(uint b, uint4 a) { +inline __host__ __device__ uint4 operator+(uint b, uint4 a) { return make_uint4(a.x + b, a.y + b, a.z + b, a.w + b); } -inline __host__ __device__ void -operator+=(uint4 &a, uint b) { +inline __host__ __device__ void operator+=(uint4 &a, uint b) { a.x += b; a.y += b; a.z += b; @@ -521,221 +424,177 @@ operator+=(uint4 &a, uint b) { // subtract //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -operator-(float2 a, float2 b) { +inline __host__ __device__ float2 operator-(float2 a, float2 b) { return make_float2(a.x - b.x, a.y - b.y); } -inline __host__ __device__ void -operator-=(float2 &a, float2 b) { +inline __host__ __device__ void operator-=(float2 &a, float2 b) { a.x -= b.x; a.y -= b.y; } -inline __host__ __device__ float2 -operator-(float2 a, float b) { +inline __host__ __device__ float2 operator-(float2 a, float b) { return make_float2(a.x - b, a.y - b); } -inline __host__ __device__ float2 -operator-(float b, float2 a) { +inline __host__ __device__ float2 operator-(float b, float2 a) { return make_float2(b - a.x, b - a.y); } -inline __host__ __device__ void -operator-=(float2 &a, float b) { +inline __host__ __device__ void operator-=(float2 &a, float b) { a.x -= b; a.y -= b; } -inline __host__ __device__ int2 -operator-(int2 a, int2 b) { +inline __host__ __device__ int2 operator-(int2 a, int2 b) { return make_int2(a.x - b.x, a.y - b.y); } -inline __host__ __device__ void -operator-=(int2 &a, int2 b) { +inline __host__ __device__ void operator-=(int2 &a, int2 b) { a.x -= b.x; a.y -= b.y; } -inline __host__ __device__ int2 -operator-(int2 a, int b) { +inline __host__ __device__ int2 operator-(int2 a, int b) { return make_int2(a.x - b, a.y - b); } -inline __host__ __device__ int2 -operator-(int b, int2 a) { +inline __host__ __device__ int2 operator-(int b, int2 a) { return make_int2(b - a.x, b - a.y); } -inline __host__ __device__ void -operator-=(int2 &a, int b) { +inline __host__ __device__ void operator-=(int2 &a, int b) { a.x -= b; a.y -= b; } -inline __host__ __device__ uint2 -operator-(uint2 a, uint2 b) { +inline __host__ __device__ uint2 operator-(uint2 a, uint2 b) { return make_uint2(a.x - b.x, a.y - b.y); } -inline __host__ __device__ void -operator-=(uint2 &a, uint2 b) { +inline __host__ __device__ void operator-=(uint2 &a, uint2 b) { a.x -= b.x; a.y -= b.y; } -inline __host__ __device__ uint2 -operator-(uint2 a, uint b) { +inline __host__ __device__ uint2 operator-(uint2 a, uint b) { return make_uint2(a.x - b, a.y - b); } -inline __host__ __device__ uint2 -operator-(uint b, uint2 a) { +inline __host__ __device__ uint2 operator-(uint b, uint2 a) { return make_uint2(b - a.x, b - a.y); } -inline __host__ __device__ void -operator-=(uint2 &a, uint b) { +inline __host__ __device__ void operator-=(uint2 &a, uint b) { a.x -= b; a.y -= b; } -inline __host__ __device__ float3 -operator-(float3 a, float3 b) { +inline __host__ __device__ float3 operator-(float3 a, float3 b) { return make_float3(a.x - b.x, a.y - b.y, a.z - b.z); } -inline __host__ __device__ void -operator-=(float3 &a, float3 b) { +inline __host__ __device__ void operator-=(float3 &a, float3 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; } -inline __host__ __device__ float3 -operator-(float3 a, float b) { +inline __host__ __device__ float3 operator-(float3 a, float b) { return make_float3(a.x - b, a.y - b, a.z - b); } -inline __host__ __device__ float3 -operator-(float b, float3 a) { +inline __host__ __device__ float3 operator-(float b, float3 a) { return make_float3(b - a.x, b - a.y, b - a.z); } -inline __host__ __device__ void -operator-=(float3 &a, float b) { +inline __host__ __device__ void operator-=(float3 &a, float b) { a.x -= b; a.y -= b; a.z -= b; } -inline __host__ __device__ int3 -operator-(int3 a, int3 b) { +inline __host__ __device__ int3 operator-(int3 a, int3 b) { return make_int3(a.x - b.x, a.y - b.y, a.z - b.z); } -inline __host__ __device__ void -operator-=(int3 &a, int3 b) { +inline __host__ __device__ void operator-=(int3 &a, int3 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; } -inline __host__ __device__ int3 -operator-(int3 a, int b) { +inline __host__ __device__ int3 operator-(int3 a, int b) { return make_int3(a.x - b, a.y - b, a.z - b); } -inline __host__ __device__ int3 -operator-(int b, int3 a) { +inline __host__ __device__ int3 operator-(int b, int3 a) { return make_int3(b - a.x, b - a.y, b - a.z); } -inline __host__ __device__ void -operator-=(int3 &a, int b) { +inline __host__ __device__ void operator-=(int3 &a, int b) { a.x -= b; a.y -= b; a.z -= b; } -inline __host__ __device__ uint3 -operator-(uint3 a, uint3 b) { +inline __host__ __device__ uint3 operator-(uint3 a, uint3 b) { return make_uint3(a.x - b.x, a.y - b.y, a.z - b.z); } -inline __host__ __device__ void -operator-=(uint3 &a, uint3 b) { +inline __host__ __device__ void operator-=(uint3 &a, uint3 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; } -inline __host__ __device__ uint3 -operator-(uint3 a, uint b) { +inline __host__ __device__ uint3 operator-(uint3 a, uint b) { return make_uint3(a.x - b, a.y - b, a.z - b); } -inline __host__ __device__ uint3 -operator-(uint b, uint3 a) { +inline __host__ __device__ uint3 operator-(uint b, uint3 a) { return make_uint3(b - a.x, b - a.y, b - a.z); } -inline __host__ __device__ void -operator-=(uint3 &a, uint b) { +inline __host__ __device__ void operator-=(uint3 &a, uint b) { a.x -= b; a.y -= b; a.z -= b; } -inline __host__ __device__ float4 -operator-(float4 a, float4 b) { +inline __host__ __device__ float4 operator-(float4 a, float4 b) { return make_float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } -inline __host__ __device__ void -operator-=(float4 &a, float4 b) { +inline __host__ __device__ void operator-=(float4 &a, float4 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w; } -inline __host__ __device__ float4 -operator-(float4 a, float b) { +inline __host__ __device__ float4 operator-(float4 a, float b) { return make_float4(a.x - b, a.y - b, a.z - b, a.w - b); } -inline __host__ __device__ void -operator-=(float4 &a, float b) { +inline __host__ __device__ void operator-=(float4 &a, float b) { a.x -= b; a.y -= b; a.z -= b; a.w -= b; } -inline __host__ __device__ int4 -operator-(int4 a, int4 b) { +inline __host__ __device__ int4 operator-(int4 a, int4 b) { return make_int4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } -inline __host__ __device__ void -operator-=(int4 &a, int4 b) { +inline __host__ __device__ void operator-=(int4 &a, int4 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w; } -inline __host__ __device__ int4 -operator-(int4 a, int b) { +inline __host__ __device__ int4 operator-(int4 a, int b) { return make_int4(a.x - b, a.y - b, a.z - b, a.w - b); } -inline __host__ __device__ int4 -operator-(int b, int4 a) { +inline __host__ __device__ int4 operator-(int b, int4 a) { return make_int4(b - a.x, b - a.y, b - a.z, b - a.w); } -inline __host__ __device__ void -operator-=(int4 &a, int b) { +inline __host__ __device__ void operator-=(int4 &a, int b) { a.x -= b; a.y -= b; a.z -= b; a.w -= b; } -inline __host__ __device__ uint4 -operator-(uint4 a, uint4 b) { +inline __host__ __device__ uint4 operator-(uint4 a, uint4 b) { return make_uint4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); } -inline __host__ __device__ void -operator-=(uint4 &a, uint4 b) { +inline __host__ __device__ void operator-=(uint4 &a, uint4 b) { a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w; } -inline __host__ __device__ uint4 -operator-(uint4 a, uint b) { +inline __host__ __device__ uint4 operator-(uint4 a, uint b) { return make_uint4(a.x - b, a.y - b, a.z - b, a.w - b); } -inline __host__ __device__ uint4 -operator-(uint b, uint4 a) { +inline __host__ __device__ uint4 operator-(uint b, uint4 a) { return make_uint4(b - a.x, b - a.y, b - a.z, b - a.w); } -inline __host__ __device__ void -operator-=(uint4 &a, uint b) { +inline __host__ __device__ void operator-=(uint4 &a, uint b) { a.x -= b; a.y -= b; a.z -= b; @@ -746,225 +605,180 @@ operator-=(uint4 &a, uint b) { // multiply //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -operator*(float2 a, float2 b) { +inline __host__ __device__ float2 operator*(float2 a, float2 b) { return make_float2(a.x * b.x, a.y * b.y); } -inline __host__ __device__ void -operator*=(float2 &a, float2 b) { +inline __host__ __device__ void operator*=(float2 &a, float2 b) { a.x *= b.x; a.y *= b.y; } -inline __host__ __device__ float2 -operator*(float2 a, float b) { +inline __host__ __device__ float2 operator*(float2 a, float b) { return make_float2(a.x * b, a.y * b); } -inline __host__ __device__ float2 -operator*(float b, float2 a) { +inline __host__ __device__ float2 operator*(float b, float2 a) { return make_float2(b * a.x, b * a.y); } -inline __host__ __device__ void -operator*=(float2 &a, float b) { +inline __host__ __device__ void operator*=(float2 &a, float b) { a.x *= b; a.y *= b; } -inline __host__ __device__ int2 -operator*(int2 a, int2 b) { +inline __host__ __device__ int2 operator*(int2 a, int2 b) { return make_int2(a.x * b.x, a.y * b.y); } -inline __host__ __device__ void -operator*=(int2 &a, int2 b) { +inline __host__ __device__ void operator*=(int2 &a, int2 b) { a.x *= b.x; a.y *= b.y; } -inline __host__ __device__ int2 -operator*(int2 a, int b) { +inline __host__ __device__ int2 operator*(int2 a, int b) { return make_int2(a.x * b, a.y * b); } -inline __host__ __device__ int2 -operator*(int b, int2 a) { +inline __host__ __device__ int2 operator*(int b, int2 a) { return make_int2(b * a.x, b * a.y); } -inline __host__ __device__ void -operator*=(int2 &a, int b) { +inline __host__ __device__ void operator*=(int2 &a, int b) { a.x *= b; a.y *= b; } -inline __host__ __device__ uint2 -operator*(uint2 a, uint2 b) { +inline __host__ __device__ uint2 operator*(uint2 a, uint2 b) { return make_uint2(a.x * b.x, a.y * b.y); } -inline __host__ __device__ void -operator*=(uint2 &a, uint2 b) { +inline __host__ __device__ void operator*=(uint2 &a, uint2 b) { a.x *= b.x; a.y *= b.y; } -inline __host__ __device__ uint2 -operator*(uint2 a, uint b) { +inline __host__ __device__ uint2 operator*(uint2 a, uint b) { return make_uint2(a.x * b, a.y * b); } -inline __host__ __device__ uint2 -operator*(uint b, uint2 a) { +inline __host__ __device__ uint2 operator*(uint b, uint2 a) { return make_uint2(b * a.x, b * a.y); } -inline __host__ __device__ void -operator*=(uint2 &a, uint b) { +inline __host__ __device__ void operator*=(uint2 &a, uint b) { a.x *= b; a.y *= b; } -inline __host__ __device__ float3 -operator*(float3 a, float3 b) { +inline __host__ __device__ float3 operator*(float3 a, float3 b) { return make_float3(a.x * b.x, a.y * b.y, a.z * b.z); } -inline __host__ __device__ void -operator*=(float3 &a, float3 b) { +inline __host__ __device__ void operator*=(float3 &a, float3 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; } -inline __host__ __device__ float3 -operator*(float3 a, float b) { +inline __host__ __device__ float3 operator*(float3 a, float b) { return make_float3(a.x * b, a.y * b, a.z * b); } -inline __host__ __device__ float3 -operator*(float b, float3 a) { +inline __host__ __device__ float3 operator*(float b, float3 a) { return make_float3(b * a.x, b * a.y, b * a.z); } -inline __host__ __device__ void -operator*=(float3 &a, float b) { +inline __host__ __device__ void operator*=(float3 &a, float b) { a.x *= b; a.y *= b; a.z *= b; } -inline __host__ __device__ int3 -operator*(int3 a, int3 b) { +inline __host__ __device__ int3 operator*(int3 a, int3 b) { return make_int3(a.x * b.x, a.y * b.y, a.z * b.z); } -inline __host__ __device__ void -operator*=(int3 &a, int3 b) { +inline __host__ __device__ void operator*=(int3 &a, int3 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; } -inline __host__ __device__ int3 -operator*(int3 a, int b) { +inline __host__ __device__ int3 operator*(int3 a, int b) { return make_int3(a.x * b, a.y * b, a.z * b); } -inline __host__ __device__ int3 -operator*(int b, int3 a) { +inline __host__ __device__ int3 operator*(int b, int3 a) { return make_int3(b * a.x, b * a.y, b * a.z); } -inline __host__ __device__ void -operator*=(int3 &a, int b) { +inline __host__ __device__ void operator*=(int3 &a, int b) { a.x *= b; a.y *= b; a.z *= b; } -inline __host__ __device__ uint3 -operator*(uint3 a, uint3 b) { +inline __host__ __device__ uint3 operator*(uint3 a, uint3 b) { return make_uint3(a.x * b.x, a.y * b.y, a.z * b.z); } -inline __host__ __device__ void -operator*=(uint3 &a, uint3 b) { +inline __host__ __device__ void operator*=(uint3 &a, uint3 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; } -inline __host__ __device__ uint3 -operator*(uint3 a, uint b) { +inline __host__ __device__ uint3 operator*(uint3 a, uint b) { return make_uint3(a.x * b, a.y * b, a.z * b); } -inline __host__ __device__ uint3 -operator*(uint b, uint3 a) { +inline __host__ __device__ uint3 operator*(uint b, uint3 a) { return make_uint3(b * a.x, b * a.y, b * a.z); } -inline __host__ __device__ void -operator*=(uint3 &a, uint b) { +inline __host__ __device__ void operator*=(uint3 &a, uint b) { a.x *= b; a.y *= b; a.z *= b; } -inline __host__ __device__ float4 -operator*(float4 a, float4 b) { +inline __host__ __device__ float4 operator*(float4 a, float4 b) { return make_float4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } -inline __host__ __device__ void -operator*=(float4 &a, float4 b) { +inline __host__ __device__ void operator*=(float4 &a, float4 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; a.w *= b.w; } -inline __host__ __device__ float4 -operator*(float4 a, float b) { +inline __host__ __device__ float4 operator*(float4 a, float b) { return make_float4(a.x * b, a.y * b, a.z * b, a.w * b); } -inline __host__ __device__ float4 -operator*(float b, float4 a) { +inline __host__ __device__ float4 operator*(float b, float4 a) { return make_float4(b * a.x, b * a.y, b * a.z, b * a.w); } -inline __host__ __device__ void -operator*=(float4 &a, float b) { +inline __host__ __device__ void operator*=(float4 &a, float b) { a.x *= b; a.y *= b; a.z *= b; a.w *= b; } -inline __host__ __device__ int4 -operator*(int4 a, int4 b) { +inline __host__ __device__ int4 operator*(int4 a, int4 b) { return make_int4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } -inline __host__ __device__ void -operator*=(int4 &a, int4 b) { +inline __host__ __device__ void operator*=(int4 &a, int4 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; a.w *= b.w; } -inline __host__ __device__ int4 -operator*(int4 a, int b) { +inline __host__ __device__ int4 operator*(int4 a, int b) { return make_int4(a.x * b, a.y * b, a.z * b, a.w * b); } -inline __host__ __device__ int4 -operator*(int b, int4 a) { +inline __host__ __device__ int4 operator*(int b, int4 a) { return make_int4(b * a.x, b * a.y, b * a.z, b * a.w); } -inline __host__ __device__ void -operator*=(int4 &a, int b) { +inline __host__ __device__ void operator*=(int4 &a, int b) { a.x *= b; a.y *= b; a.z *= b; a.w *= b; } -inline __host__ __device__ uint4 -operator*(uint4 a, uint4 b) { +inline __host__ __device__ uint4 operator*(uint4 a, uint4 b) { return make_uint4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w); } -inline __host__ __device__ void -operator*=(uint4 &a, uint4 b) { +inline __host__ __device__ void operator*=(uint4 &a, uint4 b) { a.x *= b.x; a.y *= b.y; a.z *= b.z; a.w *= b.w; } -inline __host__ __device__ uint4 -operator*(uint4 a, uint b) { +inline __host__ __device__ uint4 operator*(uint4 a, uint b) { return make_uint4(a.x * b, a.y * b, a.z * b, a.w * b); } -inline __host__ __device__ uint4 -operator*(uint b, uint4 a) { +inline __host__ __device__ uint4 operator*(uint b, uint4 a) { return make_uint4(b * a.x, b * a.y, b * a.z, b * a.w); } -inline __host__ __device__ void -operator*=(uint4 &a, uint b) { +inline __host__ __device__ void operator*=(uint4 &a, uint b) { a.x *= b; a.y *= b; a.z *= b; @@ -975,78 +789,63 @@ operator*=(uint4 &a, uint b) { // divide //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -operator/(float2 a, float2 b) { +inline __host__ __device__ float2 operator/(float2 a, float2 b) { return make_float2(a.x / b.x, a.y / b.y); } -inline __host__ __device__ void -operator/=(float2 &a, float2 b) { +inline __host__ __device__ void operator/=(float2 &a, float2 b) { a.x /= b.x; a.y /= b.y; } -inline __host__ __device__ float2 -operator/(float2 a, float b) { +inline __host__ __device__ float2 operator/(float2 a, float b) { return make_float2(a.x / b, a.y / b); } -inline __host__ __device__ void -operator/=(float2 &a, float b) { +inline __host__ __device__ void operator/=(float2 &a, float b) { a.x /= b; a.y /= b; } -inline __host__ __device__ float2 -operator/(float b, float2 a) { +inline __host__ __device__ float2 operator/(float b, float2 a) { return make_float2(b / a.x, b / a.y); } -inline __host__ __device__ float3 -operator/(float3 a, float3 b) { +inline __host__ __device__ float3 operator/(float3 a, float3 b) { return make_float3(a.x / b.x, a.y / b.y, a.z / b.z); } -inline __host__ __device__ void -operator/=(float3 &a, float3 b) { +inline __host__ __device__ void operator/=(float3 &a, float3 b) { a.x /= b.x; a.y /= b.y; a.z /= b.z; } -inline __host__ __device__ float3 -operator/(float3 a, float b) { +inline __host__ __device__ float3 operator/(float3 a, float b) { return make_float3(a.x / b, a.y / b, a.z / b); } -inline __host__ __device__ void -operator/=(float3 &a, float b) { +inline __host__ __device__ void operator/=(float3 &a, float b) { a.x /= b; a.y /= b; a.z /= b; } -inline __host__ __device__ float3 -operator/(float b, float3 a) { +inline __host__ __device__ float3 operator/(float b, float3 a) { return make_float3(b / a.x, b / a.y, b / a.z); } -inline __host__ __device__ float4 -operator/(float4 a, float4 b) { +inline __host__ __device__ float4 operator/(float4 a, float4 b) { return make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w); } -inline __host__ __device__ void -operator/=(float4 &a, float4 b) { +inline __host__ __device__ void operator/=(float4 &a, float4 b) { a.x /= b.x; a.y /= b.y; a.z /= b.z; a.w /= b.w; } -inline __host__ __device__ float4 -operator/(float4 a, float b) { +inline __host__ __device__ float4 operator/(float4 a, float b) { return make_float4(a.x / b, a.y / b, a.z / b, a.w / b); } -inline __host__ __device__ void -operator/=(float4 &a, float b) { +inline __host__ __device__ void operator/=(float4 &a, float b) { a.x /= b; a.y /= b; a.z /= b; a.w /= b; } -inline __host__ __device__ float4 -operator/(float b, float4 a) { +inline __host__ __device__ float4 operator/(float b, float4 a) { return make_float4(b / a.x, b / a.y, b / a.z, b / a.w); } @@ -1054,42 +853,33 @@ operator/(float b, float4 a) { // min //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -fminf(float2 a, float2 b) { +inline __host__ __device__ float2 fminf(float2 a, float2 b) { return make_float2(fminf(a.x, b.x), fminf(a.y, b.y)); } -inline __host__ __device__ float3 -fminf(float3 a, float3 b) { +inline __host__ __device__ float3 fminf(float3 a, float3 b) { return make_float3(fminf(a.x, b.x), fminf(a.y, b.y), fminf(a.z, b.z)); } -inline __host__ __device__ float4 -fminf(float4 a, float4 b) { +inline __host__ __device__ float4 fminf(float4 a, float4 b) { return make_float4(fminf(a.x, b.x), fminf(a.y, b.y), fminf(a.z, b.z), fminf(a.w, b.w)); } -inline __host__ __device__ int2 -min(int2 a, int2 b) { +inline __host__ __device__ int2 min(int2 a, int2 b) { return make_int2(min(a.x, b.x), min(a.y, b.y)); } -inline __host__ __device__ int3 -min(int3 a, int3 b) { +inline __host__ __device__ int3 min(int3 a, int3 b) { return make_int3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); } -inline __host__ __device__ int4 -min(int4 a, int4 b) { +inline __host__ __device__ int4 min(int4 a, int4 b) { return make_int4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); } -inline __host__ __device__ uint2 -min(uint2 a, uint2 b) { +inline __host__ __device__ uint2 min(uint2 a, uint2 b) { return make_uint2(min(a.x, b.x), min(a.y, b.y)); } -inline __host__ __device__ uint3 -min(uint3 a, uint3 b) { +inline __host__ __device__ uint3 min(uint3 a, uint3 b) { return make_uint3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z)); } -inline __host__ __device__ uint4 -min(uint4 a, uint4 b) { +inline __host__ __device__ uint4 min(uint4 a, uint4 b) { return make_uint4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w)); } @@ -1097,42 +887,33 @@ min(uint4 a, uint4 b) { // max //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -fmaxf(float2 a, float2 b) { +inline __host__ __device__ float2 fmaxf(float2 a, float2 b) { return make_float2(fmaxf(a.x, b.x), fmaxf(a.y, b.y)); } -inline __host__ __device__ float3 -fmaxf(float3 a, float3 b) { +inline __host__ __device__ float3 fmaxf(float3 a, float3 b) { return make_float3(fmaxf(a.x, b.x), fmaxf(a.y, b.y), fmaxf(a.z, b.z)); } -inline __host__ __device__ float4 -fmaxf(float4 a, float4 b) { +inline __host__ __device__ float4 fmaxf(float4 a, float4 b) { return make_float4(fmaxf(a.x, b.x), fmaxf(a.y, b.y), fmaxf(a.z, b.z), fmaxf(a.w, b.w)); } -inline __host__ __device__ int2 -max(int2 a, int2 b) { +inline __host__ __device__ int2 max(int2 a, int2 b) { return make_int2(max(a.x, b.x), max(a.y, b.y)); } -inline __host__ __device__ int3 -max(int3 a, int3 b) { +inline __host__ __device__ int3 max(int3 a, int3 b) { return make_int3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); } -inline __host__ __device__ int4 -max(int4 a, int4 b) { +inline __host__ __device__ int4 max(int4 a, int4 b) { return make_int4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); } -inline __host__ __device__ uint2 -max(uint2 a, uint2 b) { +inline __host__ __device__ uint2 max(uint2 a, uint2 b) { return make_uint2(max(a.x, b.x), max(a.y, b.y)); } -inline __host__ __device__ uint3 -max(uint3 a, uint3 b) { +inline __host__ __device__ uint3 max(uint3 a, uint3 b) { return make_uint3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z)); } -inline __host__ __device__ uint4 -max(uint4 a, uint4 b) { +inline __host__ __device__ uint4 max(uint4 a, uint4 b) { return make_uint4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w)); } @@ -1141,20 +922,16 @@ max(uint4 a, uint4 b) { // - linear interpolation between a and b, based on value t in [0, 1] range //////////////////////////////////////////////////////////////////////////////// -inline __device__ __host__ float -lerp(float a, float b, float t) { +inline __device__ __host__ float lerp(float a, float b, float t) { return a + t * (b - a); } -inline __device__ __host__ float2 -lerp(float2 a, float2 b, float t) { +inline __device__ __host__ float2 lerp(float2 a, float2 b, float t) { return a + t * (b - a); } -inline __device__ __host__ float3 -lerp(float3 a, float3 b, float t) { +inline __device__ __host__ float3 lerp(float3 a, float3 b, float t) { return a + t * (b - a); } -inline __device__ __host__ float4 -lerp(float4 a, float4 b, float t) { +inline __device__ __host__ float4 lerp(float4 a, float4 b, float t) { return a + t * (b - a); } @@ -1163,91 +940,70 @@ lerp(float4 a, float4 b, float t) { // - clamp the value v to be in the range [a, b] //////////////////////////////////////////////////////////////////////////////// -inline __device__ __host__ float -clamp(float f, float a, float b) { +inline __device__ __host__ float clamp(float f, float a, float b) { return fmaxf(a, fminf(f, b)); } -inline __device__ __host__ int -clamp(int f, int a, int b) { +inline __device__ __host__ int clamp(int f, int a, int b) { return max(a, min(f, b)); } -inline __device__ __host__ uint -clamp(uint f, uint a, uint b) { +inline __device__ __host__ uint clamp(uint f, uint a, uint b) { return max(a, min(f, b)); } -inline __device__ __host__ float2 -clamp(float2 v, float a, float b) { +inline __device__ __host__ float2 clamp(float2 v, float a, float b) { return make_float2(clamp(v.x, a, b), clamp(v.y, a, b)); } -inline __device__ __host__ float2 -clamp(float2 v, float2 a, float2 b) { +inline __device__ __host__ float2 clamp(float2 v, float2 a, float2 b) { return make_float2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y)); } -inline __device__ __host__ float3 -clamp(float3 v, float a, float b) { +inline __device__ __host__ float3 clamp(float3 v, float a, float b) { return make_float3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b)); } -inline __device__ __host__ float3 -clamp(float3 v, float3 a, float3 b) { +inline __device__ __host__ float3 clamp(float3 v, float3 a, float3 b) { return make_float3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z)); } -inline __device__ __host__ float4 -clamp(float4 v, float a, float b) { +inline __device__ __host__ float4 clamp(float4 v, float a, float b) { return make_float4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b)); } -inline __device__ __host__ float4 -clamp(float4 v, float4 a, float4 b) { +inline __device__ __host__ float4 clamp(float4 v, float4 a, float4 b) { return make_float4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w)); } -inline __device__ __host__ int2 -clamp(int2 v, int a, int b) { +inline __device__ __host__ int2 clamp(int2 v, int a, int b) { return make_int2(clamp(v.x, a, b), clamp(v.y, a, b)); } -inline __device__ __host__ int2 -clamp(int2 v, int2 a, int2 b) { +inline __device__ __host__ int2 clamp(int2 v, int2 a, int2 b) { return make_int2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y)); } -inline __device__ __host__ int3 -clamp(int3 v, int a, int b) { +inline __device__ __host__ int3 clamp(int3 v, int a, int b) { return make_int3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b)); } -inline __device__ __host__ int3 -clamp(int3 v, int3 a, int3 b) { +inline __device__ __host__ int3 clamp(int3 v, int3 a, int3 b) { return make_int3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z)); } -inline __device__ __host__ int4 -clamp(int4 v, int a, int b) { +inline __device__ __host__ int4 clamp(int4 v, int a, int b) { return make_int4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b)); } -inline __device__ __host__ int4 -clamp(int4 v, int4 a, int4 b) { +inline __device__ __host__ int4 clamp(int4 v, int4 a, int4 b) { return make_int4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w)); } -inline __device__ __host__ uint2 -clamp(uint2 v, uint a, uint b) { +inline __device__ __host__ uint2 clamp(uint2 v, uint a, uint b) { return make_uint2(clamp(v.x, a, b), clamp(v.y, a, b)); } -inline __device__ __host__ uint2 -clamp(uint2 v, uint2 a, uint2 b) { +inline __device__ __host__ uint2 clamp(uint2 v, uint2 a, uint2 b) { return make_uint2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y)); } -inline __device__ __host__ uint3 -clamp(uint3 v, uint a, uint b) { +inline __device__ __host__ uint3 clamp(uint3 v, uint a, uint b) { return make_uint3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b)); } -inline __device__ __host__ uint3 -clamp(uint3 v, uint3 a, uint3 b) { +inline __device__ __host__ uint3 clamp(uint3 v, uint3 a, uint3 b) { return make_uint3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z)); } -inline __device__ __host__ uint4 -clamp(uint4 v, uint a, uint b) { +inline __device__ __host__ uint4 clamp(uint4 v, uint a, uint b) { return make_uint4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b)); } -inline __device__ __host__ uint4 -clamp(uint4 v, uint4 a, uint4 b) { +inline __device__ __host__ uint4 clamp(uint4 v, uint4 a, uint4 b) { return make_uint4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w)); } @@ -1255,42 +1011,33 @@ clamp(uint4 v, uint4 a, uint4 b) { // dot product //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float -dot(float2 a, float2 b) { +inline __host__ __device__ float dot(float2 a, float2 b) { return a.x * b.x + a.y * b.y; } -inline __host__ __device__ float -dot(float3 a, float3 b) { +inline __host__ __device__ float dot(float3 a, float3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } -inline __host__ __device__ float -dot(float4 a, float4 b) { +inline __host__ __device__ float dot(float4 a, float4 b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } -inline __host__ __device__ int -dot(int2 a, int2 b) { +inline __host__ __device__ int dot(int2 a, int2 b) { return a.x * b.x + a.y * b.y; } -inline __host__ __device__ int -dot(int3 a, int3 b) { +inline __host__ __device__ int dot(int3 a, int3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } -inline __host__ __device__ int -dot(int4 a, int4 b) { +inline __host__ __device__ int dot(int4 a, int4 b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } -inline __host__ __device__ uint -dot(uint2 a, uint2 b) { +inline __host__ __device__ uint dot(uint2 a, uint2 b) { return a.x * b.x + a.y * b.y; } -inline __host__ __device__ uint -dot(uint3 a, uint3 b) { +inline __host__ __device__ uint dot(uint3 a, uint3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; } -inline __host__ __device__ uint -dot(uint4 a, uint4 b) { +inline __host__ __device__ uint dot(uint4 a, uint4 b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } @@ -1298,16 +1045,13 @@ dot(uint4 a, uint4 b) { // length //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float -length(float2 v) { +inline __host__ __device__ float length(float2 v) { return sqrtf(dot(v, v)); } -inline __host__ __device__ float -length(float3 v) { +inline __host__ __device__ float length(float3 v) { return sqrtf(dot(v, v)); } -inline __host__ __device__ float -length(float4 v) { +inline __host__ __device__ float length(float4 v) { return sqrtf(dot(v, v)); } @@ -1315,18 +1059,15 @@ length(float4 v) { // normalize //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -normalize(float2 v) { +inline __host__ __device__ float2 normalize(float2 v) { float invLen = rsqrtf(dot(v, v)); return v * invLen; } -inline __host__ __device__ float3 -normalize(float3 v) { +inline __host__ __device__ float3 normalize(float3 v) { float invLen = rsqrtf(dot(v, v)); return v * invLen; } -inline __host__ __device__ float4 -normalize(float4 v) { +inline __host__ __device__ float4 normalize(float4 v) { float invLen = rsqrtf(dot(v, v)); return v * invLen; } @@ -1335,16 +1076,13 @@ normalize(float4 v) { // floor //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -floorf(float2 v) { +inline __host__ __device__ float2 floorf(float2 v) { return make_float2(floorf(v.x), floorf(v.y)); } -inline __host__ __device__ float3 -floorf(float3 v) { +inline __host__ __device__ float3 floorf(float3 v) { return make_float3(floorf(v.x), floorf(v.y), floorf(v.z)); } -inline __host__ __device__ float4 -floorf(float4 v) { +inline __host__ __device__ float4 floorf(float4 v) { return make_float4(floorf(v.x), floorf(v.y), floorf(v.z), floorf(v.w)); } @@ -1352,20 +1090,16 @@ floorf(float4 v) { // frac - returns the fractional portion of a scalar or each vector component //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float -fracf(float v) { +inline __host__ __device__ float fracf(float v) { return v - floorf(v); } -inline __host__ __device__ float2 -fracf(float2 v) { +inline __host__ __device__ float2 fracf(float2 v) { return make_float2(fracf(v.x), fracf(v.y)); } -inline __host__ __device__ float3 -fracf(float3 v) { +inline __host__ __device__ float3 fracf(float3 v) { return make_float3(fracf(v.x), fracf(v.y), fracf(v.z)); } -inline __host__ __device__ float4 -fracf(float4 v) { +inline __host__ __device__ float4 fracf(float4 v) { return make_float4(fracf(v.x), fracf(v.y), fracf(v.z), fracf(v.w)); } @@ -1373,16 +1107,13 @@ fracf(float4 v) { // fmod //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -fmodf(float2 a, float2 b) { +inline __host__ __device__ float2 fmodf(float2 a, float2 b) { return make_float2(fmodf(a.x, b.x), fmodf(a.y, b.y)); } -inline __host__ __device__ float3 -fmodf(float3 a, float3 b) { +inline __host__ __device__ float3 fmodf(float3 a, float3 b) { return make_float3(fmodf(a.x, b.x), fmodf(a.y, b.y), fmodf(a.z, b.z)); } -inline __host__ __device__ float4 -fmodf(float4 a, float4 b) { +inline __host__ __device__ float4 fmodf(float4 a, float4 b) { return make_float4(fmodf(a.x, b.x), fmodf(a.y, b.y), fmodf(a.z, b.z), fmodf(a.w, b.w)); } @@ -1390,29 +1121,23 @@ fmodf(float4 a, float4 b) { // absolute value //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float2 -fabs(float2 v) { +inline __host__ __device__ float2 fabs(float2 v) { return make_float2(fabs(v.x), fabs(v.y)); } -inline __host__ __device__ float3 -fabs(float3 v) { +inline __host__ __device__ float3 fabs(float3 v) { return make_float3(fabs(v.x), fabs(v.y), fabs(v.z)); } -inline __host__ __device__ float4 -fabs(float4 v) { +inline __host__ __device__ float4 fabs(float4 v) { return make_float4(fabs(v.x), fabs(v.y), fabs(v.z), fabs(v.w)); } -inline __host__ __device__ int2 -abs(int2 v) { +inline __host__ __device__ int2 abs(int2 v) { return make_int2(abs(v.x), abs(v.y)); } -inline __host__ __device__ int3 -abs(int3 v) { +inline __host__ __device__ int3 abs(int3 v) { return make_int3(abs(v.x), abs(v.y), abs(v.z)); } -inline __host__ __device__ int4 -abs(int4 v) { +inline __host__ __device__ int4 abs(int4 v) { return make_int4(abs(v.x), abs(v.y), abs(v.z), abs(v.w)); } @@ -1422,8 +1147,7 @@ abs(int4 v) { // - N should be normalized, reflected vector's length is equal to length of I //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float3 -reflect(float3 i, float3 n) { +inline __host__ __device__ float3 reflect(float3 i, float3 n) { return i - 2.0f * n * dot(n, i); } @@ -1431,8 +1155,7 @@ reflect(float3 i, float3 n) { // cross product //////////////////////////////////////////////////////////////////////////////// -inline __host__ __device__ float3 -cross(float3 a, float3 b) { +inline __host__ __device__ float3 cross(float3 a, float3 b) { return make_float3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } @@ -1443,23 +1166,19 @@ cross(float3 a, float3 b) { // - otherwise returns smooth interpolation between 0 and 1 based on x //////////////////////////////////////////////////////////////////////////////// -inline __device__ __host__ float -smoothstep(float a, float b, float x) { +inline __device__ __host__ float smoothstep(float a, float b, float x) { float y = clamp((x - a) / (b - a), 0.0f, 1.0f); return (y * y * (3.0f - (2.0f * y))); } -inline __device__ __host__ float2 -smoothstep(float2 a, float2 b, float2 x) { +inline __device__ __host__ float2 smoothstep(float2 a, float2 b, float2 x) { float2 y = clamp((x - a) / (b - a), 0.0f, 1.0f); return (y * y * (make_float2(3.0f) - (make_float2(2.0f) * y))); } -inline __device__ __host__ float3 -smoothstep(float3 a, float3 b, float3 x) { +inline __device__ __host__ float3 smoothstep(float3 a, float3 b, float3 x) { float3 y = clamp((x - a) / (b - a), 0.0f, 1.0f); return (y * y * (make_float3(3.0f) - (make_float3(2.0f) * y))); } -inline __device__ __host__ float4 -smoothstep(float4 a, float4 b, float4 x) { +inline __device__ __host__ float4 smoothstep(float4 a, float4 b, float4 x) { float4 y = clamp((x - a) / (b - a), 0.0f, 1.0f); return (y * y * (make_float4(3.0f) - (make_float4(2.0f) * y))); } diff --git a/tools/sunshinesvc.cpp b/tools/sunshinesvc.cpp index f6a80f1c4dc..a4bc3e8be65 100644 --- a/tools/sunshinesvc.cpp +++ b/tools/sunshinesvc.cpp @@ -334,7 +334,8 @@ VOID WINAPI ServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) { case WAIT_OBJECT_0: // The service is shutting down, so try to gracefully terminate Sunshine.exe. // If it doesn't terminate in 20 seconds, we will forcefully terminate it. - if (!RunTerminationHelper(console_token, process_info.dwProcessId) || WaitForSingleObject(process_info.hProcess, 20000) != WAIT_OBJECT_0) { + if (!RunTerminationHelper(console_token, process_info.dwProcessId) + || WaitForSingleObject(process_info.hProcess, 20000) != WAIT_OBJECT_0) { // If it won't terminate gracefully, kill it now TerminateProcess(process_info.hProcess, ERROR_PROCESS_ABORTED); }