hexsha
stringlengths
40
40
size
int64
7
1.05M
ext
stringclasses
13 values
lang
stringclasses
1 value
max_stars_repo_path
stringlengths
4
269
max_stars_repo_name
stringlengths
5
109
max_stars_repo_head_hexsha
stringlengths
40
40
max_stars_repo_licenses
listlengths
1
9
max_stars_count
int64
1
191k
max_stars_repo_stars_event_min_datetime
stringlengths
24
24
max_stars_repo_stars_event_max_datetime
stringlengths
24
24
max_issues_repo_path
stringlengths
4
269
max_issues_repo_name
stringlengths
5
116
max_issues_repo_head_hexsha
stringlengths
40
40
max_issues_repo_licenses
listlengths
1
9
max_issues_count
int64
1
48.5k
max_issues_repo_issues_event_min_datetime
stringlengths
24
24
max_issues_repo_issues_event_max_datetime
stringlengths
24
24
max_forks_repo_path
stringlengths
4
269
max_forks_repo_name
stringlengths
5
116
max_forks_repo_head_hexsha
stringlengths
40
40
max_forks_repo_licenses
listlengths
1
9
max_forks_count
int64
1
105k
max_forks_repo_forks_event_min_datetime
stringlengths
24
24
max_forks_repo_forks_event_max_datetime
stringlengths
24
24
content
stringlengths
7
1.05M
avg_line_length
float64
1.21
330k
max_line_length
int64
6
990k
alphanum_fraction
float64
0.01
0.99
author_id
stringlengths
2
40
d99259c7aed9cf5a3cab45f52f29942bb24d3f0d
987
hpp
C++
library/ATF/GUILD_BATTLE__CGuildBattleRewardItem.hpp
lemkova/Yorozuya
f445d800078d9aba5de28f122cedfa03f26a38e4
[ "MIT" ]
29
2017-07-01T23:08:31.000Z
2022-02-19T10:22:45.000Z
library/ATF/GUILD_BATTLE__CGuildBattleRewardItem.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
90
2017-10-18T21:24:51.000Z
2019-06-06T02:30:33.000Z
library/ATF/GUILD_BATTLE__CGuildBattleRewardItem.hpp
kotopes/Yorozuya
605c97d3a627a8f6545cc09f2a1b0a8afdedd33a
[ "MIT" ]
44
2017-12-19T08:02:59.000Z
2022-02-24T23:15:01.000Z
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> #include <CPlayer.hpp> #include <_base_fld.hpp> START_ATF_NAMESPACE namespace GUILD_BATTLE { #pragma pack(push, 8) struct CGuildBattleRewardItem { char m_ucD; char m_ucTableCode; _base_fld *m_pFld; public: CGuildBattleRewardItem(); void ctor_CGuildBattleRewardItem(); char GetAmount(); char* GetItemCode(); struct CGuildBattleRewardItem* Give(struct CPlayer* pkPlayer); bool Init(uint16_t usInx); bool IsNull(); bool SetItem(char* szItemCode); }; #pragma pack(pop) static_assert(ATF::checkSize<GUILD_BATTLE::CGuildBattleRewardItem, 16>(), "GUILD_BATTLE::CGuildBattleRewardItem"); }; // end namespace GUILD_BATTLE END_ATF_NAMESPACE
30.84375
122
0.628166
lemkova
d993329a5cea357b30f8b41f680a090dc4745805
2,078
hpp
C++
nes_py/nes/include/mappers/mapper_NROM.hpp
lucasschoenhold/nes-py
7de04f48e928cf96ba0976ee61def5958aaa759d
[ "MIT" ]
128
2018-07-22T03:31:42.000Z
2022-03-28T13:17:04.000Z
nes_py/nes/include/mappers/mapper_NROM.hpp
lucasschoenhold/nes-py
7de04f48e928cf96ba0976ee61def5958aaa759d
[ "MIT" ]
35
2018-07-20T16:37:23.000Z
2022-02-04T00:37:23.000Z
nes_py/nes/include/mappers/mapper_NROM.hpp
lucasschoenhold/nes-py
7de04f48e928cf96ba0976ee61def5958aaa759d
[ "MIT" ]
31
2019-02-19T10:56:22.000Z
2022-01-15T19:32:52.000Z
// Program: nes-py // File: mapper_NROM.hpp // Description: An implementation of the NROM mapper // // Copyright (c) 2019 Christian Kauten. All rights reserved. // #ifndef MAPPERNROM_HPP #define MAPPERNROM_HPP #include <vector> #include "common.hpp" #include "mapper.hpp" namespace NES { class MapperNROM : public Mapper { private: /// whether there are 1 or 2 banks bool is_one_bank; /// whether this mapper uses character RAM bool has_character_ram; /// the character RAM on the mapper std::vector<NES_Byte> character_ram; public: /// Create a new mapper with a cartridge. /// /// @param cart a reference to a cartridge for the mapper to access /// explicit MapperNROM(Cartridge* cart); /// Read a byte from the PRG RAM. /// /// @param address the 16-bit address of the byte to read /// @return the byte located at the given address in PRG RAM /// inline NES_Byte readPRG(NES_Address address) { if (!is_one_bank) return cartridge->getROM()[address - 0x8000]; else // mirrored return cartridge->getROM()[(address - 0x8000) & 0x3fff]; } /// Write a byte to an address in the PRG RAM. /// /// @param address the 16-bit address to write to /// @param value the byte to write to the given address /// void writePRG(NES_Address address, NES_Byte value); /// Read a byte from the CHR RAM. /// /// @param address the 16-bit address of the byte to read /// @return the byte located at the given address in CHR RAM /// inline NES_Byte readCHR(NES_Address address) { if (has_character_ram) return character_ram[address]; else return cartridge->getVROM()[address]; } /// Write a byte to an address in the CHR RAM. /// /// @param address the 16-bit address to write to /// @param value the byte to write to the given address /// void writeCHR(NES_Address address, NES_Byte value); }; } // namespace NES #endif // MAPPERNROM_HPP
27.706667
71
0.637151
lucasschoenhold
d997ee70695ea7a074225cf474de6e0e77787952
8,297
cpp
C++
wbsModels/Climatic/VaporPressureDeficit.cpp
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
6
2017-05-26T21:19:41.000Z
2021-09-03T14:17:29.000Z
wbsModels/Climatic/VaporPressureDeficit.cpp
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
5
2016-02-18T12:39:58.000Z
2016-03-13T12:57:45.000Z
wbsModels/Climatic/VaporPressureDeficit.cpp
RNCan/WeatherBasedSimulationFramework
19df207d11b1dddf414d78e52bece77f31d45df8
[ "MIT" ]
1
2019-06-16T02:49:20.000Z
2019-06-16T02:49:20.000Z
//********************************************************************** // 11/09/2018 1.1.1 Rémi Saint-Amant Bug correction in units. return VPD in [hPa] // 20/09/2016 1.1.0 Rémi Saint-Amant Change Tair and Trng by Tmin and Tmax // 21/01/2016 1.0.0 Rémi Saint-Amant Using Weather-based simulation framework (WBSF) //********************************************************************** #include <iostream> #include "Basic/UtilTime.h" #include "Basic/UtilMath.h" #include "ModelBase/EntryPoint.h" #include "VaporPressureDeficit.h" using namespace std; using namespace WBSF::HOURLY_DATA; namespace WBSF { //this line link this model with the EntryPoint of the DLL static const bool bRegistred = CModelFactory::RegisterModel(CVPDModel::CreateObject); //Saturation vapor pressure at daylight temperature static double GetDaylightVaporPressureDeficit(const CWeatherYear& weather); static double GetDaylightVaporPressureDeficit(const CWeatherMonth& weather); static double GetDaylightVaporPressureDeficit(const CWeatherDay& weather); static double GetVPD(const CWeatherYear& weather); static double GetVPD(const CWeatherMonth& weather); static double GetVPD(const CWeatherDay& weather); enum TAnnualStat{ O_DAYLIGHT_VPD, O_MEAN_VPD, NB_OUTPUTS }; //Contructor CVPDModel::CVPDModel() { //specify the number of input parameter NB_INPUT_PARAMETER = 0; VERSION = "1.1.1 (2018)"; } CVPDModel::~CVPDModel() {} //This method is call to load your parameter in your variable ERMsg CVPDModel::ProcessParameters(const CParameterVector& parameters) { ERMsg msg; return msg; } ERMsg CVPDModel::OnExecuteAnnual() { ERMsg msg; CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::ANNUAL)); m_output.Init(p, NB_OUTPUTS, -9999); for (size_t y = 0; y < m_weather.GetNbYears(); y++) { double daylightVPD = GetDaylightVaporPressureDeficit(m_weather[y]); //[kPa] double VPD = m_weather[y][H_VPD][MEAN]; //[kPa] m_output[y][O_DAYLIGHT_VPD] = daylightVPD*10;//kPa --> hPa m_output[y][O_MEAN_VPD] = VPD*10;//kPa --> hPa } return msg; } ERMsg CVPDModel::OnExecuteMonthly() { ERMsg msg; CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::MONTHLY)); m_output.Init(p, NB_OUTPUTS, -9999); for (size_t y = 0; y<m_weather.GetNbYears(); y++) { for (size_t m = 0; m<12; m++) { double daylightVPD = GetDaylightVaporPressureDeficit(m_weather[y][m]); //[kPa] double VPD = GetVPD(m_weather[y][m]); //[kPa] m_output[y * 12 + m][O_DAYLIGHT_VPD] = daylightVPD*10;//kPa --> hPa m_output[y * 12 + m][O_MEAN_VPD] = VPD*10;//kPa --> hPa } } return msg; } ERMsg CVPDModel::OnExecuteDaily() { ERMsg msg; CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::DAILY)); m_output.Init(p, NB_OUTPUTS, -9999); for (size_t y = 0; y<m_weather.size(); y++) { for (size_t m = 0; m<m_weather[y].size(); m++) { for (size_t d = 0; d<m_weather[y][m].size(); d++) { const CWeatherDay& wDay = m_weather[y][m][d]; double daylightVPD = GetDaylightVaporPressureDeficit(wDay); //[kPa] double VPD = GetVPD(wDay);//[kPa] CTRef ref = m_weather[y][m][d].GetTRef(); m_output[ref][O_DAYLIGHT_VPD] = daylightVPD*10;//kPa --> hPa m_output[ref][O_MEAN_VPD] = VPD*10;//kPa --> hPa } } } return msg; } ERMsg CVPDModel::OnExecuteHourly() { ERMsg msg; if (!m_weather.IsHourly()) m_weather.ComputeHourlyVariables(); CTPeriod p = m_weather.GetEntireTPeriod(CTM::HOURLY); m_output.Init(p, NB_OUTPUTS, -9999); CSun sun(m_weather.m_lat, m_weather.m_lon); for (size_t y = 0; y<m_weather.size(); y++) { for (size_t m = 0; m<m_weather[y].size(); m++) { for (size_t d = 0; d<m_weather[y][m].size(); d++) { for (size_t h = 0; h < m_weather[y][m][d].size(); h++) { const CHourlyData& wHour = m_weather[y][m][d][h]; double VPD = max(0.0f, wHour[H_ES] - wHour[H_EA] )*10;//kPa --> hPa CTRef ref = m_weather[y][m][d][h].GetTRef(); size_t sunrise = Round(sun.GetSunrise(ref)); size_t sunset = min(23ll, Round(sun.GetSunset(ref))); double daylightVPD = (h >= sunrise && h <= sunset) ? VPD : -9999; m_output[ref][O_DAYLIGHT_VPD] = daylightVPD;//hPa m_output[ref][O_MEAN_VPD] = VPD;//hPa } } } } return msg; } //Saturation vapor pressure at daylight temperature [kPa] double GetDaylightVaporPressureDeficit(const CWeatherYear& weather) { CStatistic stat; for (size_t m = 0; m < weather.size(); m++) stat += GetDaylightVaporPressureDeficit(weather[m]); return stat[MEAN]; } //Saturation vapor pressure at daylight temperature [kPa] double GetDaylightVaporPressureDeficit(const CWeatherMonth& weather) { CStatistic stat; for (size_t d = 0; d < weather.size(); d++) stat += GetDaylightVaporPressureDeficit(weather[d]); return stat[MEAN]; } //Saturation vapor pressure at daylight temperature [kPa] double GetDaylightVaporPressureDeficit(const CWeatherDay& weather) { CStatistic VPD; if (weather.IsHourly()) { CSun sun(weather.GetLocation().m_lat, weather.GetLocation().m_lon); size_t sunrise = Round(sun.GetSunrise(weather.GetTRef())); size_t sunset = min(23ll, Round(sun.GetSunset(weather.GetTRef()))); for (size_t h = sunrise; h <= sunset; h++) VPD += max(0.0f, weather[h][H_ES] - weather[h][H_EA]); } else { double daylightT = weather.GetTdaylight(); double daylightEs = eᵒ(daylightT);//kPa // *1000; //by RSA 11-09-2018 kPa instead of Pa VPD += max(0.0, daylightEs - weather[H_EA][MEAN]); //double Dmax = eᵒ(weather[H_TMAX]) - eᵒ(weather[H_TMIN]); //VPD += 2.0 / 3.0*Dmax; //VPD += max(0.0, weather[H_ES][MEAN] - weather[H_EA][MEAN]); } return VPD[MEAN]; } //return vapor pressure deficit [kPa] static double GetVPD(const CWeatherYear& weather) { CStatistic stat; for (size_t m = 0; m < weather.size(); m++) stat += GetVPD(weather[m]); return stat[MEAN]; } //return vapor pressure deficit [kPa] static double GetVPD(const CWeatherMonth& weather) { CStatistic stat; for (size_t d = 0; d < weather.size(); d++) stat += GetVPD(weather[d]); return stat[MEAN]; } /*double ʃ(double Tᴰ, double Tᴸ, double Tᴴ ) { ASSERT(Tᴰ <= Tᴸ); ASSERT(Tᴸ <= Tᴴ); double sum=0; for (size_t i = 0; i <= 100; i++) { double T = Tᴸ + i*(Tᴴ - Tᴸ) / 100.0; sum += eᵒ(T) - eᵒ(Tᴰ); } return sum; }*/ double ʃ(double Tᴰ, double T) { ASSERT(Tᴰ <= T); return eᵒ(T) - eᵒ(Tᴰ); } // Function to evalute the value of integral double trapezoidal(double Tᴰ, double Tᴸ, double Tᴴ, int n = 100) { // Grid spacing double h = (Tᴴ - Tᴸ) / n; // Computing sum of first and last terms // in above formula double s = ʃ(Tᴰ, Tᴸ) + ʃ(Tᴰ, Tᴴ); // Adding middle terms in above formula for (int i = 1; i < n; i++) s += 2 * ʃ(Tᴰ, Tᴸ + i * h); // h/2 indicates (b-a)/2n. Multiplying h/2 // with s. return (h / 2)*s; } //return vapor pressure deficit [kPa] static double GetVPD(const CWeatherDay& weather) { CStatistic stat; if (weather.IsHourly()) { for (size_t h = 0; h < 24; h++) stat += max(0.0f, weather[h][H_ES] - weather[h][H_EA]); } else { stat += max(0.0, weather[H_ES][MEAN] - weather[H_EA][MEAN]); //test from Castellvi(1996) /* double Tᴰ = eᵒ(weather[H_TDEW][MEAN]); double Tn = eᵒ(weather[H_TMIN][MEAN]); double Tx = eᵒ(weather[H_TMAX][MEAN]); double Ta = (Tn+Tx)/2; if (Tᴰ < Tn && Tn < Tx) { double a = trapezoidal(Tᴰ, Tn, Ta); double b = trapezoidal(Tᴰ, Tn, Tx); ASSERT(a/b > 0 && a/b<=1); while (abs(0.5 - a/b)> 0.001) { Ta += (0.5-a/b)*(Tx-Tn); ASSERT(Ta >= Tn && Ta <= Tx); a = trapezoidal(Tᴰ, Tn, Ta); ASSERT(a / b >= 0 && a / b <= 1); } } double h = std::max(1.0, std::min(100.0, weather[H_RELH][MEAN])); stat += eᵒ(Ta)*(1- h /100.0); */ } return stat[MEAN]; } }
25.45092
91
0.60082
RNCan
d99e0fc329d535d7938e7ddc4049be67845d0a17
18,085
hpp
C++
inc/state/thrdcmdpool.hpp
nicoboss/vuda
9e0e254dd6a37d418292e1e949fdf33262f008e9
[ "MIT" ]
422
2018-10-08T04:58:20.000Z
2022-03-23T10:31:25.000Z
inc/state/thrdcmdpool.hpp
nicoboss/vuda
9e0e254dd6a37d418292e1e949fdf33262f008e9
[ "MIT" ]
18
2018-10-10T20:45:43.000Z
2021-11-28T08:36:37.000Z
inc/state/thrdcmdpool.hpp
nicoboss/vuda
9e0e254dd6a37d418292e1e949fdf33262f008e9
[ "MIT" ]
24
2018-10-08T11:11:49.000Z
2022-02-18T01:07:42.000Z
#pragma once namespace vuda { namespace detail { class thrdcmdpool { //friend class logical_device; public: /* For each thread that sets/uses the device a single command pool is created - this pool have m_queueComputeCount command buffers allocated. This way, - VkCommandBuffers are allocated from a "parent" VkCommandPool - VkCommandBuffers written to in different threads must come from different pools ======================================================= command buffers \ threads : 0 1 2 3 4 ... #n 0 1 . . . m_queueComputeCount ======================================================= */ thrdcmdpool(const vk::UniqueDevice& device, const uint32_t queueFamilyIndex, const uint32_t queueComputeCount) : m_commandPool(device->createCommandPoolUnique(vk::CommandPoolCreateInfo(vk::CommandPoolCreateFlags(vk::CommandPoolCreateFlagBits::eResetCommandBuffer), queueFamilyIndex))), m_commandBuffers(device->allocateCommandBuffersUnique(vk::CommandBufferAllocateInfo(m_commandPool.get(), vk::CommandBufferLevel::ePrimary, queueComputeCount))), m_commandBufferState(queueComputeCount, cbReset), m_queryPool(device->createQueryPoolUnique(vk::QueryPoolCreateInfo(vk::QueryPoolCreateFlags(), vk::QueryType::eTimestamp, VUDA_MAX_QUERY_COUNT, vk::QueryPipelineStatisticFlags()))), m_queryIndex(0) { // // create unique mutexes /*m_mtxCommandBuffers.resize(queueComputeCount); for(unsigned int i = 0; i < queueComputeCount; ++i) m_mtxCommandBuffers[i] = std::make_unique<std::mutex>();*/ // // create fences m_ufences.reserve(queueComputeCount); for(unsigned int i = 0; i < queueComputeCount; ++i) m_ufences.push_back(device->createFenceUnique(vk::FenceCreateFlags())); } /* public synchronized interface */ void SetEvent(const vk::UniqueDevice& device, const event_t event, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); // // CheckStateAndBeginCommandBuffer(device, stream); // // m_commandBuffers[stream]->setEvent(event, vk::PipelineStageFlagBits::eBottomOfPipe); } uint32_t GetQueryID(void) const { assert(m_queryIndex != VUDA_MAX_QUERY_COUNT); return m_queryIndex++; } void WriteTimeStamp(const vk::UniqueDevice& device, const uint32_t queryID, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); // // submit write time stamp command CheckStateAndBeginCommandBuffer(device, stream); // reset m_commandBuffers[stream]->resetQueryPool(m_queryPool.get(), queryID, 1); // write m_commandBuffers[stream]->writeTimestamp(vk::PipelineStageFlagBits::eBottomOfPipe, m_queryPool.get(), queryID); } uint64_t GetQueryPoolResults(const vk::UniqueDevice& device, const uint32_t queryID) const { // vkGetQueryPoolResults(sync) // vkCmdCopyQueryPoolResults(async) const uint32_t numQueries = 1; // VUDA_MAX_QUERY_COUNT; uint64_t result[numQueries]; size_t stride = sizeof(uint64_t); size_t size = numQueries * stride; // // vkGetQueryPoolResults will wait for the results to be available when VK_QUERY_RESULT_WAIT_BIT is specified vk::Result res = device->getQueryPoolResults(m_queryPool.get(), queryID, numQueries, size, &result[0], stride, vk::QueryResultFlagBits::e64 | vk::QueryResultFlagBits::eWait); assert(res == vk::Result::eSuccess); return result[0]; } /*void ResetQueryPool(const vk::UniqueDevice& device, const uint32_t queryID, const stream_t stream) const { // // lock access to the streams commandbuffer std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); // // reset query CheckStateAndBeginCommandBuffer(device, stream); m_commandBuffers[stream]->resetQueryPool(m_queryPool.get(), queryID, 1); }*/ void memcpyDevice(const vk::UniqueDevice& device, const vk::Buffer& bufferDst, const vk::DeviceSize dstOffset, const vk::Buffer& bufferSrc, const vk::DeviceSize srcOffset, const vk::DeviceSize size, const vk::Queue& queue, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); /*// // hello std::ostringstream ostr; ostr << "thrd: " << std::this_thread::get_id() << ", pooladrr: " << this << ", locked and modifying command buffer: " << stream << std::endl; std::cout << ostr.str(); ostr.str("");*/ // // check state of command buffer and see if we should call begin CheckStateAndBeginCommandBuffer(device, stream); // // submit copy buffer call to command buffer vk::BufferCopy copyRegion = vk::BufferCopy() .setSrcOffset(srcOffset) .setDstOffset(dstOffset) .setSize(size); // // the order of src and dst is interchanged compared to memcpy m_commandBuffers[stream]->copyBuffer(bufferSrc, bufferDst, copyRegion); // // hello there /*std::ostringstream ostr; ostr << std::this_thread::get_id() << ", commandbuffer: " << &m_commandBuffers[stream] << ", src: " << bufferSrc << ", dst: " << bufferDst << ", copy region: srcOffset: " << copyRegion.srcOffset << ", dstOffset: " << copyRegion.dstOffset << ", size: " << copyRegion.size << std::endl; std::cout << ostr.str();*/ // // insert pipeline barrier? /*vk::BufferMemoryBarrier bmb(vk::AccessFlagBits::eTransferRead, vk::AccessFlagBits::eTransferWrite, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, bufferDst, dstOffset, size); m_commandBuffers[stream]->pipelineBarrier( vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eBottomOfPipe, vk::DependencyFlagBits::eByRegion, 0, nullptr, 1, &bmb, 0, nullptr);*/ // // execute the command buffer ExecuteQueue(device, queue, stream); //ostr << "thrd: " << std::this_thread::get_id() << ", pooladrr: " << this << ", unlocking command buffer: " << stream << std::endl; //std::cout << ostr.str(); } template <size_t specializationByteSize, typename... specialTypes, size_t bindingSize> void UpdateDescriptorAndCommandBuffer(const vk::UniqueDevice& device, const kernelprogram<specializationByteSize>& kernel, const specialization<specialTypes...>& specials, const std::array<vk::DescriptorBufferInfo, bindingSize>& bufferDescriptors, const dim3 blocks, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); // // check state of command buffer and see if we should call begin CheckStateAndBeginCommandBuffer(device, stream); // // record command buffer kernel.UpdateDescriptorAndCommandBuffer(device, m_commandBuffers[stream], bufferDescriptors, specials, blocks); // // insert (buffer) memory barrier // [ memory barriers are created for each resource, it would be better to apply the barriers based on readonly, writeonly information ] const uint32_t numbuf = (uint32_t)bufferDescriptors.size(); std::vector<vk::BufferMemoryBarrier> bmb(numbuf); for(uint32_t i=0; i<numbuf; ++i) { bmb[i] = vk::BufferMemoryBarrier( vk::AccessFlagBits::eShaderWrite, vk::AccessFlagBits::eShaderRead, VK_QUEUE_FAMILY_IGNORED, VK_QUEUE_FAMILY_IGNORED, bufferDescriptors[i].buffer, bufferDescriptors[i].offset, bufferDescriptors[i].range); } m_commandBuffers[stream]->pipelineBarrier( vk::PipelineStageFlagBits::eComputeShader, vk::PipelineStageFlagBits::eComputeShader, vk::DependencyFlagBits::eByRegion, 0, nullptr, numbuf, bmb.data(), 0, nullptr); // // statistics /*std::ostringstream ostr; ostr << "tid: " << std::this_thread::get_id() << ", stream_id: " << stream << ", command buffer addr: " << &m_commandBuffers[stream] << std::endl; std::cout << ostr.str();*/ /*// // if the recording failed, it is solely due to the limited amount of descriptor sets if(ret == false) { // // if we are doing a new recording no need to end and execute if(newRecording == false) { std::ostringstream ostr; std::thread::id tid = std::this_thread::get_id(); ostr << tid << ": ran out of descriptors! Got to execute now and retry!" << std::endl; std::cout << ostr.str(); // end recording/execute, wait, begin recording ExecuteQueue(device, queueFamilyIndex, stream); WaitAndReset(device, stream); BeginRecordingCommandBuffer(stream); } // // record ret = kernel.UpdateDescriptorAndCommandBuffer(device, m_commandBuffers[stream], bufferDescriptors); assert(ret == true); }*/ } void Execute(const vk::UniqueDevice& device, const vk::Queue& queue, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); ExecuteQueue(device, queue, stream); } /*void Wait(const vk::UniqueDevice& device, const vk::Queue& queue, const stream_t stream) const { // // lock access to the streams commandbuffer std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); WaitAndReset(device, stream); }*/ void ExecuteAndWait(const vk::UniqueDevice& device, const vk::Queue& queue, const stream_t stream) const { // // lock access to the streams commandbuffer //std::lock_guard<std::mutex> lck(*m_mtxCommandBuffers[stream]); ExecuteQueue(device, queue, stream); WaitAndReset(device, stream); } private: /* private non-synchronized implementation - assumes m_mtxCommandBuffers[stream] is locked */ void CheckStateAndBeginCommandBuffer(const vk::UniqueDevice& device, const stream_t stream) const { // // assumes m_mtxCommandBuffers[stream] is locked commandBufferStateFlags state = m_commandBufferState[stream]; if(state == cbReset) { // we can begin a new recording BeginRecordingCommandBuffer(stream); } else if(state == cbSubmitted) { // wait on completion and start new recording WaitAndReset(device, stream); BeginRecordingCommandBuffer(stream); } else { // this is a continued recording call //newRecording = false; } } void BeginRecordingCommandBuffer(const stream_t stream) const { // // assumes m_mtxCommandBuffers[stream] is locked vk::CommandBufferBeginInfo commandBufferBeginInfo = vk::CommandBufferBeginInfo() .setFlags(vk::CommandBufferUsageFlagBits::eOneTimeSubmit) .setPInheritanceInfo(nullptr); m_commandBuffers[stream]->begin(commandBufferBeginInfo); m_commandBufferState[stream] = cbRecording; } void ExecuteQueue(const vk::UniqueDevice& device, const vk::Queue& queue, const stream_t stream) const { // // assumes m_mtxCommandBuffers[stream] is locked if(m_commandBufferState[stream] == cbRecording) { // // end recording and submit m_commandBuffers[stream]->end(); // // submit command buffer to compute queue /* https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkQueueSubmit.html Each element of the pCommandBuffers member of each element of pSubmits must have been allocated from a VkCommandPool that was created for the same queue family queue belongs to. */ queue.submit(vk::SubmitInfo(0, nullptr, nullptr, 1, &m_commandBuffers[stream].get(), 0, nullptr), m_ufences[stream].get()); m_commandBufferState[stream] = cbSubmitted; } } void WaitAndReset(const vk::UniqueDevice& device, const stream_t stream) const { // // assumes m_mtxCommandBuffers[stream] is locked if(m_commandBufferState[stream] == cbSubmitted) { // // for now just wait for the queue to become idle vk::Result res = device->waitForFences(1, &m_ufences[stream].get(), VK_FALSE, (std::numeric_limits<uint64_t>::max)()); assert(res == vk::Result::eSuccess); device->resetFences(1, &m_ufences[stream].get()); // // reset command buffer m_commandBuffers[stream]->reset(vk::CommandBufferResetFlags()); m_commandBufferState[stream] = cbReset; } } /*std::vector<uint32_t> GetStreamList(const void* src) { std::lock_guard<std::mutex> lck(*m_mtxResourceDependency); std::vector<uint32_t> list = m_src2stream[src]; m_src2stream.erase(src); return list; }*/ private: //std::vector<std::unique_ptr<std::mutex>> m_mtxCommandBuffers; std::vector<vk::UniqueFence> m_ufences; vk::UniqueCommandPool m_commandPool; std::vector<vk::UniqueCommandBuffer> m_commandBuffers; mutable std::vector<commandBufferStateFlags> m_commandBufferState; // // time stamp queries vk::UniqueQueryPool m_queryPool; mutable std::atomic<uint32_t> m_queryIndex; //mutable std::array<std::atomic<uint32_t>, VUDA_MAX_QUERY_COUNT> m_querytostream; // // resource management //std::unique_ptr<std::mutex> m_mtxResourceDependency; //std::unordered_map<const void*, std::vector<uint32_t>> m_src2stream; }; } //namespace detail } //namespace vuda
44.32598
308
0.509594
nicoboss
d99e19814707922f174edf275686564c9d081b8c
1,018
cpp
C++
source/Ch18/orai_anyag/vector004.cpp
Vada200/UDProg-Introduction
c424b2676d6e5bfc4d53d61c5d0deded566c1c84
[ "CC0-1.0" ]
null
null
null
source/Ch18/orai_anyag/vector004.cpp
Vada200/UDProg-Introduction
c424b2676d6e5bfc4d53d61c5d0deded566c1c84
[ "CC0-1.0" ]
null
null
null
source/Ch18/orai_anyag/vector004.cpp
Vada200/UDProg-Introduction
c424b2676d6e5bfc4d53d61c5d0deded566c1c84
[ "CC0-1.0" ]
null
null
null
#include "std_lib_facilities.h" class My_vector { //priv long unsigned int sz; //size / előjel nélküli long típusú int double* elem; //elem pointer public: My_vector(int s) : sz(s), elem{new double[s]} // int s értéke bemásolódik sz-be, elem néven lefoglalódik a memóriában a double vector { for (int i = 0; i < s; i++) elem[i] = 0; //ki 0-zuk a memória területet } My_vector(initializer_list<double> lst) :sz{lst.size()}, elem{new double[sz]} //listát várja { copy(lst.begin(), lst.end(), elem); //mettől, meddig, hova } ~My_vector() { delete[] elem; } //destructor futás végén lefut double get(int n) const { return elem[n]; } void set(int n, double val) {elem[n] = val;} int size() const { return sz; } }; //osztály def után ; kell int main() { My_vector my(10); cout << my.size() << endl; //pointernél -> van My_vector v2 {12.2, 13.3, 14.4 }; for(int i = 0; i < v2.size(); i++) cout << v2.get(i) << endl; return 0; }
26.102564
135
0.59725
Vada200
d263de79c1bc78cf6370bf66123136b8155de065
124,838
cpp
C++
403_407_408_411_Ray_Tracer/src/ui.cpp
amritphuyal/Computer-Graphics-074-BEX
ee77526a6e2ce53d696b802650917f5a0438af14
[ "MIT" ]
5
2020-03-06T10:01:28.000Z
2020-05-06T07:57:20.000Z
403_407_408_411_Ray_Tracer/src/ui.cpp
amritphuyal/Computer-Graphics-074-BEX
ee77526a6e2ce53d696b802650917f5a0438af14
[ "MIT" ]
1
2020-03-06T02:51:50.000Z
2020-03-06T04:33:30.000Z
403_407_408_411_Ray_Tracer/src/ui.cpp
amritphuyal/Computer-Graphics-074-BEX
ee77526a6e2ce53d696b802650917f5a0438af14
[ "MIT" ]
29
2020-03-05T15:15:24.000Z
2021-07-21T07:05:00.000Z
#define OS_LINUX_CPP #define HANDMADE_MATH_IMPLEMENTATION #include <stdio.h> #include <cstdlib> #include "imgui.h" #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" #include <glad/glad.h> #include <GLFW/glfw3.h> #include "common.h" #include <cassert> #include <cmath> #define STB_IMAGE_IMPLEMENTATION #include <stb_image.h> #include "HandmadeMath.h" #include "ui_primitives.h" #include "ui_objects.h" #include "ray_data.h" #include "prng.h" typedef GLuint guint; #define SCREEN_WIDTH 800 #define SCREEN_HEIGHT 600 static uint ScreenWidth = 1366; static uint ScreenHeight = 768; #define HMM_MAT4_PTR(x) ( &( x ).Elements[0][0] ) #define HMM_MAT4P_PTR(x) (&( ( x )->Elements[0][0] )) #define ENABLE_GL_DEBUG_PRINT 1 #define MS_TO_SEC(x) ( (x) * 1.0e-3f ) static uint *Quad_elem_indices; static uint quad_elem_buffer_index; static uint *Line_elem_indices; static float CubeVertices[] = { // front 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, //back 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, // right 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, //left -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, // top 0.5f, 0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, // bottom 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, }; static float CubeNormals[] = { // front 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, // back 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, // right 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, // left -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, // top 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, // bottom 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, }; static float CubeTexCoords[] = { 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; static v3 *SphereVertices; static v3 *SphereNormals; static v2 *SphereTextureCoords; static v3 *SphereColorBuff; static uint *SphereIndices; static uint sphere_element_buffer; static Rectangle CubeRects[6]; void generate_sphere_vertices( ){ SphereVertices = array_allocate( v3, 10000 ); SphereNormals = array_allocate( v3, 10000 ); SphereTextureCoords = array_allocate( v2, 10000 ); SphereIndices = array_allocate( uint, 10000 ); SphereColorBuff = array_allocate( v3, 10000 ); uint pitch_count = 50; uint yaw_count = 50; f32 pitch_step = 2 * HMM_PI32 / pitch_count; f32 yaw_step = HMM_PI32 / yaw_count; f32 pitch = 0.0f; f32 yaw = HMM_PI32/2; const f32 r = 1.0f; for ( uint i = 0; i <= yaw_count ; i++ ){ pitch = 0.0f; f32 z = r * HMM_SinF( yaw ); f32 xy = r * HMM_CosF( yaw ); for ( uint j = 0; j <= pitch_count ; j++ ){ f32 x = xy * r * HMM_CosF( pitch ); f32 y = xy * r * HMM_SinF( pitch ); array_push( SphereVertices, v3{x,y,z} ); array_push( SphereNormals, v3{ x,y,z } ); array_push( SphereTextureCoords, v2{ (f32)i/pitch_count, (f32)j/yaw_count } ); pitch += pitch_step; } yaw -= yaw_step; } for( uint i = 0; i < yaw_count; ++i){ uint k1 = i * (pitch_count + 1); uint k2 = k1 + pitch_count + 1; for( uint j = 0; j < pitch_count; ++j, ++k1, ++k2){ if(i != 0) { array_push(SphereIndices,k1); array_push(SphereIndices,k2); array_push(SphereIndices,k1 + 1); } if(i != (yaw_count-1)){ array_push( SphereIndices,k1 + 1); array_push( SphereIndices,k2); array_push( SphereIndices,k2 + 1); } } } return; } void generate_cube_rects( Rectangle *rects, f32 len ){ Rectangle front, back, left, right, top, bot; f32 half_len = len / 2.0f; front.p0 = { -half_len, -half_len, half_len }; back.p0 = { -half_len, -half_len, -half_len }; right.p0 = { half_len, -half_len, -half_len }; left.p0 = { -half_len, -half_len, -half_len }; top.p0 = { -half_len, half_len, -half_len }; bot.p0 = { -half_len, -half_len, -half_len }; front.s1 = { 1.0f,0.0f,0.0f }; front.s2 = { 0.0f, 1.0f, 0.0f }; back.s1 = { 1.0f,0.0f,0.0f }; back.s2 = { 0.0f, 1.0f, 0.0f }; right.s1 = { 0.0f,0.0f,1.0f }; right.s2 = { 0.0f, 1.0f, 0.0f }; left.s1 = { 0.0f,0.0f,1.0f }; left.s2 = { 0.0f, 1.0f, 0.0f }; top.s1 = { 1.0f,0.0f,0.0f }; top.s2 = { 0.0f, 0.0f, 1.0f }; bot.s1 = { 1.0f,0.0f,0.0f }; bot.s2 = { 0.0f, 0.0f, 1.0f }; front.n = { 0.0f, 0.0f, 1.0f }; back.n = { 0.0f, 0.0f, -1.0f }; right.n = { 1.0f, 0.0f, 0.0f }; left.n = { -1.0f, 0.0f, 0.0f }; top.n = { 0.0f, 1.0f, 0.0f }; bot.n = { 0.0f, -1.0f, 0.0f }; front.l1 = front.l2 = len; back.l1 = back.l2 = len; right.l1 = right.l2 = len; left.l1 = left.l2 = len; top.l1 = top.l2 = len; bot.l1 = bot.l2 = len; rects[ 0 ] = front; rects[ 1 ] = back; rects[ 2 ] = right; rects[ 3 ] = left; rects[ 4 ] = top; rects[ 5 ] = bot; } struct Camera { union { struct { v3 S, U, F; }; v3 basis[3]; }; v3 P; enum CameraState { ANIMATING = 1, STATIC }; bool should_rotate; bool should_move; CameraState state; f32 duration; f32 elapsed; int dim; f32 dist_to_move; f32 dist_moved; f32 speed; f32 pitch; f32 yaw; f32 max_pitch; f32 max_yaw; Plane plane; Camera ():max_pitch(80.0f),max_yaw(80.0f){} Camera ( const Camera & ); Camera ( const v3& Eye, const v3& Center, const v3& Up ): should_rotate(false),should_move( true ), pitch(0.0f),yaw(0.0f), max_pitch(80.0f), max_yaw(80.0f) { state = STATIC; F = HMM_NormalizeVec3(HMM_SubtractVec3(Center, Eye)); S = HMM_NormalizeVec3(HMM_Cross(F, Up)); U = HMM_Cross(S, F); P = Eye; } inline void rotate( f32 p, f32 y ){ if ( !should_rotate ) return; pitch += p; yaw += y; yaw = CLAMP( yaw, -max_yaw, max_yaw ); f32 cpitch = cos( HMM_RADIANS( pitch ) ); f32 spitch = sin( HMM_RADIANS( pitch ) ); f32 cyaw = cos( HMM_RADIANS( yaw ) ); f32 syaw = sin( HMM_RADIANS( yaw ) ); F.X = -cpitch * cyaw; F.Y = -syaw; F.Z = -spitch * cyaw ; v3 Up = { 0.0f, 1.0f, 0.0f }; S = HMM_NormalizeVec3(HMM_Cross(F, Up)); U = HMM_Cross(S, F); } m4 transform( ) const { m4 Result; Result.Elements[0][0] = S.X; Result.Elements[0][1] = U.X; Result.Elements[0][2] = -F.X; Result.Elements[0][3] = 0.0f; Result.Elements[1][0] = S.Y; Result.Elements[1][1] = U.Y; Result.Elements[1][2] = -F.Y; Result.Elements[1][3] = 0.0f; Result.Elements[2][0] = S.Z; Result.Elements[2][1] = U.Z; Result.Elements[2][2] = -F.Z; Result.Elements[2][3] = 0.0f; Result.Elements[3][0] = -HMM_DotVec3(S, P); Result.Elements[3][1] = -HMM_DotVec3(U, P); Result.Elements[3][2] = HMM_DotVec3(F, P); Result.Elements[3][3] = 1.0f; return (Result); } void move_towards( float t ){ if ( should_move ) P = P + t * F; } void move_right( float t ){ if ( should_move ) P = P + t * S; } void move_up( float t ){ if ( should_move ) P = P + t * U; } void update( float dt ){ switch ( state ){ case ANIMATING: { #if 0 float dist = dt * (float)dist_to_move/duration; P += dist * direction; elapsed += dt; if ( elapsed >= duration ) state = STATIC; #else float dist = dt * speed; P += dist * basis[dim]; #endif break; } default: break; } } inline void start_animate( int dir,f32 dist, f32 time ){ if ( !should_move ) { state = STATIC; return; } state = ANIMATING; elapsed = 0; dim = dir; dist_to_move = 1.0f; dist_moved = 0.0f; speed = dist/MS_TO_SEC( time ); } inline void toggle_move( ){ should_move = !should_move; } inline void toggle_rotate(){ should_rotate = !should_rotate; } void print( ){ fprintf( stdout, "Camera Info::\nFront: " ); print_v3( F ); fprintf( stdout, "\nRight: " ); print_v3( S ); fprintf( stdout, "\nUp: " ); print_v3( U ); fprintf( stdout, "\nPoint: " ); print_v3( P ); fprintf( stdout, "\n" ); } bool hit_plane( const Ray &ray, v3 &point ) { float d = HMM_DotVec3( ray.direction, F ); if ( abs( d ) < TOLERANCE ) return false; v3 temp = P - ray.start; float t = HMM_DotVec3( temp, F )/d ; point = ray.point_at( t ); return true; } }; enum Keys { KB_KEY_A = 0, KB_KEY_B, KB_KEY_C, KB_KEY_D, KB_KEY_E, KB_KEY_F, KB_KEY_G, KB_KEY_H, KB_KEY_I, KB_KEY_J, KB_KEY_K, KB_KEY_L, KB_KEY_M, KB_KEY_N, KB_KEY_O, KB_KEY_P, KB_KEY_Q, KB_KEY_R, KB_KEY_S, KB_KEY_T, KB_KEY_U, KB_KEY_V, KB_KEY_W, KB_KEY_X, KB_KEY_Y, KB_KEY_Z, KB_KEY_ESCAPE }; enum EventType { MOUSE_RBUTTON_CLICK = 1, MOUSE_LBUTTON_CLICK, MOUSE_MOVE, KB_PRESS_A, KB_PRESS_B, KB_PRESS_C, KB_PRESS_D, KB_PRESS_E, KB_PRESS_F, KB_PRESS_G, KB_PRESS_H, KB_PRESS_I, KB_PRESS_J, KB_PRESS_K, KB_PRESS_L, KB_PRESS_M, KB_PRESS_N, KB_PRESS_O, KB_PRESS_P, KB_PRESS_Q, KB_PRESS_R, KB_PRESS_S, KB_PRESS_T, KB_PRESS_U, KB_PRESS_V, KB_PRESS_W, KB_PRESS_X, KB_PRESS_Y, KB_PRESS_Z, KB_REPEAT_A, KB_REPEAT_B, KB_REPEAT_C, KB_REPEAT_D, KB_REPEAT_E, KB_REPEAT_F, KB_REPEAT_G, KB_REPEAT_H, KB_REPEAT_I, KB_REPEAT_J, KB_REPEAT_K, KB_REPEAT_L, KB_REPEAT_M, KB_REPEAT_N, KB_REPEAT_O, KB_REPEAT_P, KB_REPEAT_Q, KB_REPEAT_R, KB_REPEAT_S, KB_REPEAT_T, KB_REPEAT_U, KB_REPEAT_V, KB_REPEAT_W, KB_REPEAT_X, KB_REPEAT_Y, KB_REPEAT_Z, KB_RELEASE_A, KB_RELEASE_B, KB_RELEASE_C, KB_RELEASE_D, KB_RELEASE_E, KB_RELEASE_F, KB_RELEASE_G, KB_RELEASE_H, KB_RELEASE_I, KB_RELEASE_J, KB_RELEASE_K, KB_RELEASE_L, KB_RELEASE_M, KB_RELEASE_N, KB_RELEASE_O, KB_RELEASE_P, KB_RELEASE_Q, KB_RELEASE_R, KB_RELEASE_S, KB_RELEASE_T, KB_RELEASE_U, KB_RELEASE_V, KB_RELEASE_W, KB_RELEASE_X, KB_RELEASE_Y, KB_RELEASE_Z, KB_PRESS_ESCAPE, KB_RELEASE_ESCAPE, KB_REPEAT_ESCAPE }; struct Event { EventType type; int mods; union { struct { int button; }; struct { int scancode; }; struct { f32 xp,yp; }; }; }; inline Event create_mouse_event( EventType t, int m ){ Event e; e.type = t; e.mods = m; return e; } inline Event create_mouse_event( EventType t,f32 xp, f32 yp ){ Event e; e.type = t; e.xp = xp; e.yp = yp; return e; } inline Event create_keyboard_event( EventType t, int s, int m ){ Event e; e.type = t; e.scancode = s; e.mods = m; return e; } #define MAX_EVENTS 100 static Event Event_Queue[ MAX_EVENTS ]; static uint Event_Count = 0; // Probably want to mutex it void event_push_back( Event e ){ Event_Queue[ Event_Count++ ] = e; } static void APIENTRY glDebugOutput( GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei msgLength, const GLchar* message, const void* userParam) { // ignore non-significant error/warning codes if(id == 131169 || id == 131185 || id == 131218 || id == 131204) return; print_error("---------------"); print_error("Debug message (%d): %s ",id,message); switch (source) { case GL_DEBUG_SOURCE_API: print_error( "Source: API"); break; case GL_DEBUG_SOURCE_WINDOW_SYSTEM: print_error( "Source: Window System"); break; case GL_DEBUG_SOURCE_SHADER_COMPILER: print_error( "Source: Shader Compiler"); break; case GL_DEBUG_SOURCE_THIRD_PARTY: print_error( "Source: Third Party"); break; case GL_DEBUG_SOURCE_APPLICATION: print_error( "Source: Application"); break; case GL_DEBUG_SOURCE_OTHER: print_error( "Source: Other"); break; } switch (type) { case GL_DEBUG_TYPE_ERROR: print_error( "Type: Error"); break; case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: print_error( "Type: Deprecated Behaviour"); break; case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: print_error( "Type: Undefined Behaviour"); break; case GL_DEBUG_TYPE_PORTABILITY: print_error( "Type: Portability"); break; case GL_DEBUG_TYPE_PERFORMANCE: print_error( "Type: Performance"); break; case GL_DEBUG_TYPE_MARKER: print_error( "Type: Marker"); break; case GL_DEBUG_TYPE_PUSH_GROUP: print_error( "Type: Push Group"); break; case GL_DEBUG_TYPE_POP_GROUP: print_error( "Type: Pop Group"); break; case GL_DEBUG_TYPE_OTHER: print_error( "Type: Other"); break; } switch (severity) { case GL_DEBUG_SEVERITY_HIGH: print_error( "Severity: high"); break; case GL_DEBUG_SEVERITY_MEDIUM: print_error( "Severity: medium"); break; case GL_DEBUG_SEVERITY_LOW: print_error( "Severity: low"); break; case GL_DEBUG_SEVERITY_NOTIFICATION: print_error( "Severity: notification"); break; } fprintf(stderr,"\n"); } void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { EventType t ; #define KEY_PRESS_CASE(x) \ case GLFW_KEY_##x: t = KB_PRESS_##x; break; #define KEY_REPEAT_CASE(x) \ case GLFW_KEY_##x: t = KB_REPEAT_##x; break; #define KEY_RELEASE_CASE(x) \ case GLFW_KEY_##x: t = KB_RELEASE_##x; break; if ( action == GLFW_PRESS ){ switch ( key ){ KEY_PRESS_CASE(A) KEY_PRESS_CASE(B) KEY_PRESS_CASE(C) KEY_PRESS_CASE(D) KEY_PRESS_CASE(E) KEY_PRESS_CASE(F) KEY_PRESS_CASE(G) KEY_PRESS_CASE(H) KEY_PRESS_CASE(I) KEY_PRESS_CASE(J) KEY_PRESS_CASE(K) KEY_PRESS_CASE(L) KEY_PRESS_CASE(M) KEY_PRESS_CASE(N) KEY_PRESS_CASE(O) KEY_PRESS_CASE(P) KEY_PRESS_CASE(Q) KEY_PRESS_CASE(R) KEY_PRESS_CASE(S) KEY_PRESS_CASE(T) KEY_PRESS_CASE(U) KEY_PRESS_CASE(V) KEY_PRESS_CASE(W) KEY_PRESS_CASE(X) KEY_PRESS_CASE(Y) KEY_PRESS_CASE(Z) KEY_PRESS_CASE(ESCAPE) default: break; } } else if ( action == GLFW_REPEAT ){ switch ( key ){ KEY_REPEAT_CASE(A) KEY_REPEAT_CASE(B) KEY_REPEAT_CASE(C) KEY_REPEAT_CASE(D) KEY_REPEAT_CASE(E) KEY_REPEAT_CASE(F) KEY_REPEAT_CASE(G) KEY_REPEAT_CASE(H) KEY_REPEAT_CASE(I) KEY_REPEAT_CASE(J) KEY_REPEAT_CASE(K) KEY_REPEAT_CASE(L) KEY_REPEAT_CASE(M) KEY_REPEAT_CASE(N) KEY_REPEAT_CASE(O) KEY_REPEAT_CASE(P) KEY_REPEAT_CASE(Q) KEY_REPEAT_CASE(R) KEY_REPEAT_CASE(S) KEY_REPEAT_CASE(T) KEY_REPEAT_CASE(U) KEY_REPEAT_CASE(V) KEY_REPEAT_CASE(W) KEY_REPEAT_CASE(X) KEY_REPEAT_CASE(Y) KEY_REPEAT_CASE(Z) KEY_REPEAT_CASE(ESCAPE) default: break; } } else if ( action == GLFW_RELEASE ){ switch ( key ){ KEY_RELEASE_CASE(A) KEY_RELEASE_CASE(B) KEY_RELEASE_CASE(C) KEY_RELEASE_CASE(D) KEY_RELEASE_CASE(E) KEY_RELEASE_CASE(F) KEY_RELEASE_CASE(G) KEY_RELEASE_CASE(H) KEY_RELEASE_CASE(I) KEY_RELEASE_CASE(J) KEY_RELEASE_CASE(K) KEY_RELEASE_CASE(L) KEY_RELEASE_CASE(M) KEY_RELEASE_CASE(N) KEY_RELEASE_CASE(O) KEY_RELEASE_CASE(P) KEY_RELEASE_CASE(Q) KEY_RELEASE_CASE(R) KEY_RELEASE_CASE(S) KEY_RELEASE_CASE(T) KEY_RELEASE_CASE(U) KEY_RELEASE_CASE(V) KEY_RELEASE_CASE(W) KEY_RELEASE_CASE(X) KEY_RELEASE_CASE(Y) KEY_RELEASE_CASE(Z) KEY_RELEASE_CASE(ESCAPE) default: break; } } event_push_back( create_keyboard_event(t, scancode, mods ) ); } void process_keyboard_input( GLFWwindow *window, uint8 *key_map ){ uint8 press = 0; #define GET_KEY_STATE(key) \ press = glfwGetKey( window, GLFW_KEY_##key );\ key_map[KB_KEY_##key] = ( press==GLFW_RELEASE )?0:1; GET_KEY_STATE(A) GET_KEY_STATE(B) GET_KEY_STATE(C) GET_KEY_STATE(D) GET_KEY_STATE(E) GET_KEY_STATE(F) GET_KEY_STATE(G) GET_KEY_STATE(H) GET_KEY_STATE(I) GET_KEY_STATE(J) GET_KEY_STATE(K) GET_KEY_STATE(L) GET_KEY_STATE(M) GET_KEY_STATE(N) GET_KEY_STATE(O) GET_KEY_STATE(P) GET_KEY_STATE(Q) GET_KEY_STATE(R) GET_KEY_STATE(S) GET_KEY_STATE(T) GET_KEY_STATE(U) GET_KEY_STATE(V) GET_KEY_STATE(W) GET_KEY_STATE(X) GET_KEY_STATE(Y) GET_KEY_STATE(Z) GET_KEY_STATE(ESCAPE) } void mouse_callback( GLFWwindow *window, double xpos, double ypos ){ event_push_back( create_mouse_event( MOUSE_MOVE, (f32)xpos,(f32)ypos) ); glfwSetCursorPosCallback( window, NULL ); } void mouse_button_callback( GLFWwindow* window, int button, int action, int mods ) { if ( action == GLFW_PRESS ){ switch ( button ){ case GLFW_MOUSE_BUTTON_RIGHT: event_push_back( create_mouse_event( MOUSE_RBUTTON_CLICK,mods)); break; case GLFW_MOUSE_BUTTON_LEFT: event_push_back( create_mouse_event( MOUSE_LBUTTON_CLICK, mods)); break; default: break; } } #if 0 if ( action == GLFW_PRESS ){ switch (button){ case GLFW_MOUSE_BUTTON_RIGHT: { int viewport[4]; glGetIntegerv( GL_VIEWPORT, viewport); fprintf( stderr, "View port info: %d, %d, %d, %d\n", viewport[0], viewport[1], viewport[2], viewport[3] ); double cp[2]; if ( glfwGetWindowAttrib(window, GLFW_HOVERED ) ){ glfwGetCursorPos( window, &cp[0], &cp[1] ); fprintf( stdout, "%f, %f\n", (f32)cp[0], (f32) cp[1] ); } v3 point = v3{ ( float )cp[0], (float)cp[1], 0.0f }; v3 wp = HMM_UnProject( point, mvp, SCREEN_WIDTH, SCREEN_HEIGHT ); fprintf( stdout, "The point in world coords is: " ); print_v3( wp ); fprintf( stdout, "\n" ); break; } default: break; } } #endif } void resizeCallback(GLFWwindow* window, int width, int height) { glViewport(0, 0, width, height); ScreenHeight = height; ScreenWidth = width; } #define CLEANUP(x) __func__##x int compile_shader( guint *ret, const char *source, GLenum type ){ uint shader = glCreateShader( type ); char *buff; if ( read_text_file_to_buffer( source, &buff ) == -1 ){ goto CLEANUP(1); } glShaderSource( shader, 1, &buff, NULL ); glCompileShader( shader ); int success; glGetShaderiv( shader, GL_COMPILE_STATUS, &success ); if ( success == GL_FALSE ){ char infoLog[512]; glGetShaderInfoLog(shader, 512, NULL, infoLog); print_error("Failed to compile Shader!\n \ Location:\n %s\ \n%s\n", source, infoLog ); goto CLEANUP(2); } *ret = shader; return 0; CLEANUP(2): assert( shader != 0 ); glDeleteShader( shader ); free( buff ); CLEANUP(1): return -1; } int compile_program( guint *program, const char *vsource ,const char *fsource ){ guint vshader, fshader, prog; if ( compile_shader( &vshader, vsource, GL_VERTEX_SHADER ) == -1 ){ goto CLEANUP(1); } if ( compile_shader( &fshader, fsource, GL_FRAGMENT_SHADER) == -1 ){ goto CLEANUP(1); } prog = glCreateProgram(); glAttachShader( prog, vshader ); glAttachShader( prog, fshader ); glLinkProgram( prog ); int success; glGetProgramiv( prog, GL_LINK_STATUS, &success ); if ( success == GL_FALSE ){ char infoLog[512]; glGetProgramInfoLog( prog , 512, NULL, infoLog ); print_error( "Failed to link Shader!\n\ %s", infoLog ); goto CLEANUP( 2 ); } *program = prog; glDeleteShader( vshader ); glDeleteShader( fshader ); return 0; CLEANUP(2): glDeleteShader( vshader ); glDeleteShader( fshader ); CLEANUP(1): *program = 0; return -1; } void flipImage( uint8 *data, int width, int height){ int top = 0, bottom = height - 1; while ( top <= bottom ){ uint8 *topPixel = data + top * width * 4; uint8 *botPixel = data + bottom* width * 4; for ( int i = 0; i < width * 4 ; i++ ){ uint8 tmp = *topPixel; *topPixel++ = *botPixel; *botPixel++ = tmp; } top++; bottom--; } } struct LineVertexBufferData{ v3 p; v3 color; }; struct ColorVertexData{ v3 p; v3 color; v3 n; }; struct QuadVertexData { v3 p0,p1,p2,p3; v3 c0,c1,c2,c3; v3 n0,n1,n2,n3; }; struct RenderContext { ColorVertexData *color_vertex_data_buff = NULL; const uint max_color_vertex_data = 5000; uint num_color_vertex = 0; GLenum *color_vertex_modes = NULL; } Rc; void add_color_vertex( const v3 &p, const v3 &color, GLenum mode ){ ColorVertexData v = { p, color }; Rc.color_vertex_data_buff[ Rc.num_color_vertex ] = v; Rc.color_vertex_modes[ Rc.num_color_vertex ] = mode; Rc.num_color_vertex++; } void draw_color_line( v3 start ,v3 end, v3 color ){ add_color_vertex( start, color, GL_LINES ); add_color_vertex( end, color, GL_LINES ); } void draw_color_vertex( const m4 &mvp ){ } struct GridProgramInfo{ uint id; uint mvp_loc; uint corner_loc; uint width_loc; uint8 pos_id; uint8 direction_id; uint8 color_id; }; struct PointLightLocation{ uint pos_loc; uint color_loc; }; struct SimpleColorShaderProgram { uint id; uint mvp_loc; uint model_loc; uint view_loc; uint view_pos_loc; uint texture0_loc; // Frag. shader PointLightLocation point_light_loc[4]; uint num_lights_loc; uint amb_loc; uint8 pos_id; uint8 color_id; uint8 normal_id; uint8 tex_coords_id; }; struct SimpleNLColorShaderProgram { uint id; uint mvp_loc; uint8 pos_id; uint8 color_id; uint8 normal_id; }; static GridProgramInfo grid_program_info; static SimpleColorShaderProgram simple_color_shader_info; static SimpleNLColorShaderProgram nl_color_shader_info; int create_grid_program( ){ if ( compile_program(&grid_program_info.id, "./shaders/grid_shader.vert", "./shaders/grid_shader.frag" ) == -1 ){ fprintf(stderr,"Unable to compile Program!\n"); return -1; } const int &id = grid_program_info.id; glUseProgram( id ); grid_program_info.mvp_loc = glGetUniformLocation( id,"mvp" ); grid_program_info.corner_loc = glGetUniformLocation( id,"corner_pos" ); grid_program_info.width_loc = glGetUniformLocation( id,"width" ); grid_program_info.pos_id = 0; grid_program_info.direction_id = 1; grid_program_info.color_id = 2; return 0; } int create_simple_color_shader_program( ){ if ( compile_program(&simple_color_shader_info.id, "./shaders/simple-color-shader.vert", "./shaders/simple-color-shader.frag" ) == -1 ){ fprintf(stderr,"Unable to compile Program!\n"); return -1; } const int &id = simple_color_shader_info.id; glUseProgram( id ); simple_color_shader_info.mvp_loc = glGetUniformLocation( id,"mvp" ); char buff[256]; for ( int i = 0; i < 4; i++ ){ snprintf( buff, 256, "point_lights[%d].pos",i ); simple_color_shader_info.point_light_loc[i].pos_loc = glGetUniformLocation( id, buff ); snprintf( buff, 256, "point_lights[%d].color",i ); simple_color_shader_info.point_light_loc[i].color_loc= glGetUniformLocation( id, buff ); } simple_color_shader_info.model_loc = glGetUniformLocation( id, "model"); simple_color_shader_info.view_loc = glGetUniformLocation( id, "view" ); simple_color_shader_info.num_lights_loc = glGetUniformLocation( id, "num_lights" ); simple_color_shader_info.amb_loc = glGetUniformLocation( id, "amb" ); simple_color_shader_info.view_pos_loc=glGetUniformLocation( id, "view_pos" ); simple_color_shader_info.texture0_loc = glGetUniformLocation( id,"texture0"); simple_color_shader_info.pos_id = 0; simple_color_shader_info.color_id = 1; simple_color_shader_info.normal_id = 2; simple_color_shader_info.tex_coords_id = 3; glUseProgram( 0 ); return 0; } int create_nl_color_shader_program( ){ if ( compile_program(&nl_color_shader_info.id, "./shaders/simple-color-shader-nl.vert", "./shaders/simple-color-shader-nl.frag" ) == -1 ){ fprintf(stderr,"Unable to compile Program!\n"); return -1; } const int &id = nl_color_shader_info.id; glUseProgram( id ); nl_color_shader_info.mvp_loc = glGetUniformLocation( id,"mvp" ); nl_color_shader_info.pos_id = 0; nl_color_shader_info.color_id = 1; nl_color_shader_info.normal_id = 2; glUseProgram( 0 ); return 0; } #if 0 void AABB_generate_vertex( const AABB &box, v3 *mem ){ f32 xlen = box.u[0] - box.l[0]; f32 ylen = box.u[1] - box.l[1]; f32 zlen = box.u[2] - box.l[2]; //back v3 a0 = box.l; v3 a1 = box.l + v3{ xlen, 0, 0 }; v3 a2 = box.l + v3{ xlen, ylen, 0 }; v3 a3 = box.l + v3{ 0, ylen, 0 }; //front v3 a0 = box.l + v3{ 0,0,zlen}; v3 a1 = box.l + v3{ xlen, 0, zlen }; v3 a2 = box.l + v3{ xlen, ylen, zlen }; v3 a3 = box.l + v3{ 0, ylen, zlen }; //left v3 a0 = box.l + v3{ 0,0,0}; v3 a1 = box.l + v3{ 0,0,zlen }; v3 a2 = box.l + v3{ 0,ylen,zlen }; v3 a3 = box.l + v3{ 0,ylen,0 }; //right v3 a0 = box.l + v3{ xlen,0,0}; v3 a1 = box.l + v3{ xlen,0,zlen }; v3 a2 = box.l + v3{ xlen,ylen,zlen }; v3 a3 = box.l + v3{ xlen,ylen,0 }; // bottom v3 a0 = box.l + v3{ 0,0,0}; v3 a1 = box.l + v3{ xlen,0,0}; v3 a2 = box.l + v3{ xlen,0,zlen}; v3 a3 = box.l + v3{ 0,0,zlen }; //top v3 a0 = box.l + v3{ 0,ylen,0}; v3 a1 = box.l + v3{ xlen,ylen,0}; v3 a2 = box.l + v3{ xlen,ylen,zlen}; v3 a3 = box.l + v3{ 0,ylen,zlen }; } #endif struct ColorQuad { v3 p0,p1,p2,p3; v3 color; v3 n; }; struct Image { int h,w,channels; uint8 *data; }; struct Light { Object object; v3 color; }; struct Texture { enum TextureType { COLOR = 0, CHECKER, MARBLE, }; TextureType type; union { v3 face_colors[6]; v3 color; }; Image image; }; struct Material { enum MaterialType{ METALLIC = 0, PURE_DIFFUSE, GLASS, }; MaterialType type; Texture texture; f32 diffuse, specular, shine; }; Material create_material_diffuse( Texture t ){ Material m; m.type = Material::PURE_DIFFUSE; m.texture = t; m.diffuse = 1.0f; m.specular = 0.0f; m.shine = 0.0f; return m; } Material create_material_metallic( Texture t ){ Material m; m.type = Material::METALLIC; m.texture = t; m.diffuse = 0.3f; m.specular = 8.0f; m.shine = 64.0f; return m; } Material create_material_glass( ){ Material m; Texture t; t.type = Texture::COLOR; t.color = v3{ 0.0f,0.0f,1.0f }; m.type = Material::GLASS; m.texture = t; return m; } struct World { enum State { STATE_INVALID = 0, STATE_FREE_VIEW = 1, STATE_DETACHED, STATE_ON_HOLD, STATE_SELECTED, STATE_VIEW_CAMERA, }; State state; bool show_imgui; m4 ui_perspective; m4 view_perspective; f32 ui_vfov, ui_near_plane, ui_far_plane; f32 view_vfov, view_near_plane, view_far_plane; m4 perspective; Camera ui_camera; Camera view_camera; Camera *camera; Grid grid; Cube cube; Cube *cubes; Sphere *spheres; Rectangle *rects; Material *cube_materials; Material *sphere_materials; Material *rect_materials; v3 *light_pos; v3 *light_colors; v3 amb_light; v3 *light_cube_color; v3 *light_sphere_color; v3 *light_rect_color; Cube *light_cubes; Sphere *light_spheres; Rectangle *light_rects; uint *light_cubes_vao; uint *light_cubes_vbo; uint *light_spheres_vao; uint *light_spheres_vbo; uint *light_rect_vao; Line *lines; ColorQuad *temp_color_quads; ColorQuad *perm_color_quads; bool is_selected; Object selected_object; GetAABBFunc selected_aabb; TranslateFunc selected_move; RotateFunc selected_rotate; ScaleFunc selected_scale; uint selected_index; void *selected_data; bool is_holding; Object hold_object; int hold_object_id; AABB *boxes; // Dear imgui selection stuff int cube_face_dropdown; v3 cube_face_color; v3 cube_side_length; f32 sel_cube_length; int cube_material_dropdown; int cube_texture_dropdown; v3 sphere_face_color; f32 sel_sphere_radius; int sphere_material_dropdown; int sphere_texture_dropdown; v3 rect_face_color; int rect_flip_normal; f32 sel_rect_l1; f32 sel_rect_l2; int rect_material_dropdown; int rect_texture_dropdown; v3 light_cube_face_color; v3 light_sphere_face_color; v3 light_rect_face_color; int object_select_dropdown; uint grid_vao, grid_vbo, grid_ebo; uint cube_vao, cube_vbo, cube_ebo; uint *cubes_vao; uint *cubes_vbo; uint *spheres_vao; uint *spheres_vbo; v3 *sphere_colors; v3 *rect_colors; m4 *spheres_transform; m4 *model_matrices[_OBJECT_MAX]; uint color_vao, color_vbo, color_ebo; uint rect_vao, rect_vbo, rect_ebo; uint white_texture, checker_texture, marble_texture; v3 *color_vertex_data; uint *color_vertex_indices; uint *index_stack; // Used as stack GLenum *color_vertex_modes; // Used as stack }; void world_config_simple_color_shader_buffer( uint vao, uint vbo, uint ebo, size_t vertex_count ) { glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); size_t offset= sizeof(v3)*vertex_count; glBufferData( GL_ARRAY_BUFFER, 3 * offset + sizeof(v2) * vertex_count, NULL, GL_STREAM_DRAW ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ebo); glEnableVertexAttribArray(simple_color_shader_info.pos_id ); glVertexAttribPointer( simple_color_shader_info.pos_id, 3, GL_FLOAT, GL_FALSE, sizeof( v3 ), (void *)0 ); glEnableVertexAttribArray( simple_color_shader_info.color_id ); glVertexAttribPointer( simple_color_shader_info.color_id, 3, GL_FLOAT, GL_FALSE, sizeof(v3), (void *)(offset) ); glEnableVertexAttribArray( simple_color_shader_info.normal_id ); glVertexAttribPointer( simple_color_shader_info.normal_id, 3, GL_FLOAT, GL_FALSE, sizeof(v3), (void *)( 2 * offset) ); glEnableVertexAttribArray( simple_color_shader_info.tex_coords_id ); glVertexAttribPointer( simple_color_shader_info.tex_coords_id, 2, GL_FLOAT, GL_FALSE, sizeof(v2), (void *)( 3 * offset) ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } void world_config_nl_color_shader_buffer( uint vao, uint vbo, uint ebo, size_t size ) { glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); size_t offset=size; glBufferData( GL_ARRAY_BUFFER, 3 * offset, NULL, GL_STREAM_DRAW ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, ebo); glEnableVertexAttribArray(nl_color_shader_info.pos_id ); glVertexAttribPointer( nl_color_shader_info.pos_id, 3, GL_FLOAT, GL_FALSE, sizeof( v3 ), (void *)0 ); glEnableVertexAttribArray( nl_color_shader_info.color_id ); glVertexAttribPointer( nl_color_shader_info.color_id, 3, GL_FLOAT, GL_FALSE, sizeof(v3), (void *)(offset) ); glEnableVertexAttribArray( nl_color_shader_info.normal_id ); glVertexAttribPointer( nl_color_shader_info.normal_id, 3, GL_FLOAT, GL_FALSE, sizeof(v3), (void *)( 2 * offset) ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } #define GLASS_COLOR v3{0.0f,0.0f,1.0f}; void world_add_cube_vertex_data( const World &w, uint index ){ v3 colors[24]; Material &m = w.cube_materials[index]; if ( m.type == Material::GLASS ){ for ( int i = 0; i < 24; i++ ){ colors[ i ] = GLASS_COLOR; } } else { Texture &tex = m.texture; for ( int i = 0; i < 24; i++ ){ int index = i / 4; colors[ i ] = tex.face_colors[ index ]; } } uint vao = w.cubes_vao[index]; uint vbo = w.cubes_vbo[index]; glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(CubeVertices), CubeVertices ); glBufferSubData( GL_ARRAY_BUFFER, sizeof(CubeVertices), sizeof(colors), colors); glBufferSubData( GL_ARRAY_BUFFER, sizeof(CubeVertices) + sizeof(colors), sizeof(CubeNormals), (void *)CubeNormals); glBufferSubData( GL_ARRAY_BUFFER, 3*sizeof(CubeVertices), sizeof(CubeTexCoords), (void *)CubeTexCoords ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); } void world_generate_cube_data( uint &vao, uint &vbo, Cube &cube ){ glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); world_config_simple_color_shader_buffer( vao, vbo, quad_elem_buffer_index, 24 ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } void world_add_light_cube_vertex_data( const World &w, uint index ) { v3 colors[24]; for ( int i = 0; i < 24; i++ ){ colors[ i ] = w.light_cube_color[index]; } glBindVertexArray( w.light_cubes_vao[index] ); glBindBuffer( GL_ARRAY_BUFFER, w.light_cubes_vbo[index] ); glBufferSubData( GL_ARRAY_BUFFER, 0, sizeof(CubeVertices), CubeVertices ); glBufferSubData( GL_ARRAY_BUFFER, sizeof(CubeVertices), sizeof(colors), colors); glBufferSubData( GL_ARRAY_BUFFER, sizeof(CubeVertices) + sizeof(colors), sizeof(CubeNormals), (void *)CubeNormals); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); } void world_generate_light_cube( uint &vao, uint &vbo, Cube &cube ){ glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); world_config_nl_color_shader_buffer( vao, vbo, quad_elem_buffer_index, sizeof(CubeVertices) ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } void world_add_sphere_vertex_data( const World &w, uint index ) { Material &material = w.sphere_materials[index]; v3 color = w.sphere_materials[index].texture.color; if ( material.type == Material::GLASS ){ color = GLASS_COLOR; } for ( uint i = 0; i < array_length( SphereVertices ); i++ ){ array_push( SphereColorBuff, color ); } size_t data_size = array_length(SphereVertices)*sizeof(*SphereVertices); uint vao = w.spheres_vao[index]; uint vbo = w.spheres_vbo[index]; glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); glBufferSubData( GL_ARRAY_BUFFER, data_size, data_size, SphereColorBuff); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); array_clear( SphereColorBuff ); } void world_add_light_sphere_vertex_data( const World &w, uint index ) { v3 &color = w.light_sphere_color[index]; for ( uint i = 0; i < array_length( SphereVertices ); i++ ){ array_push( SphereColorBuff, color ); } glBindVertexArray( w.light_spheres_vao[index] ); glBindBuffer( GL_ARRAY_BUFFER, w.light_spheres_vbo[index] ); size_t data_size = sizeof(v3) * array_length( SphereVertices ); glBufferSubData( GL_ARRAY_BUFFER, data_size, data_size, SphereColorBuff); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); array_clear( SphereColorBuff ); } void world_add_cube( World &w, Cube *cube, Material m ){ uint vao, vbo; array_push( w.cubes, *cube ); #if 0 m4 model = HMM_Scale( v3{ cube->length, cube->length, cube->length } ) HMM_Translate(cube->pos) ; #else m4 model = HMM_Translate(cube->pos)*HMM_Scale( v3{ cube->length, cube->length, cube->length } ) ; #endif array_push( w.model_matrices[OBJECT_CUBE_INSTANCE],model ); array_push( w.cube_materials, m ); glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); world_config_simple_color_shader_buffer( vao, vbo, quad_elem_buffer_index, 24 ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); array_push( w.cubes_vao, vao ); array_push( w.cubes_vbo, vbo ); world_add_cube_vertex_data(w, array_length(w.cubes)-1 ); } void world_add_light_cube( World &w, Cube *cube, v3 color ){ uint vao, vbo; array_push( w.light_cubes, *cube ); m4 model = HMM_Translate(cube->pos) * HMM_Scale( v3{ cube->length, cube->length, cube->length } ); array_push( w.model_matrices[OBJECT_LIGHT_CUBE_INSTANCE],model ); array_push( w.light_cube_color, color ); glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); world_config_nl_color_shader_buffer( vao, vbo, quad_elem_buffer_index, sizeof(CubeVertices) ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); array_push( w.light_cubes_vao, vao ); array_push( w.light_cubes_vbo, vbo ); world_add_light_cube_vertex_data(w,array_length(w.light_cubes)-1 ); } void world_add_sphere( World &w, const Sphere &s, Material m){ uint vao, vbo; array_push( w.spheres, s ); m4 transform = HMM_Translate( s.c ) * HMM_Scale( v3{ s.r, s.r,s.r }); array_push( w.model_matrices[OBJECT_SPHERE], transform ); //array_push( w.sphere_colors, color ); array_push( w.sphere_materials, m ); glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); world_config_simple_color_shader_buffer( vao, vbo, sphere_element_buffer, array_length(SphereVertices)); glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); size_t data_size = sizeof(v3) * array_length( SphereVertices ); glBufferSubData( GL_ARRAY_BUFFER, 0,data_size , SphereVertices ); glBufferSubData( GL_ARRAY_BUFFER, 2 * data_size, data_size, (void *) SphereNormals ); glBufferSubData( GL_ARRAY_BUFFER, 3*data_size, sizeof(v2) * array_length( SphereTextureCoords ), (void *)SphereTextureCoords ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); array_push( w.spheres_vao, vao ); array_push( w.spheres_vbo, vbo ); world_add_sphere_vertex_data(w,array_length(w.spheres)-1); } void world_add_light_sphere( World &w, const Sphere &s, v3 color ){ uint vao, vbo; array_push( w.light_spheres, s ); m4 transform = HMM_Translate( s.c ) * HMM_Scale( v3{ s.r, s.r,s.r }); array_push( w.model_matrices[OBJECT_LIGHT_SPHERE], transform ); array_push( w.light_sphere_color, color ); glGenVertexArrays( 1, &vao ); glGenBuffers( 1, &vbo ); size_t offset= array_length(SphereVertices)*sizeof(*SphereVertices); world_config_nl_color_shader_buffer( vao, vbo, sphere_element_buffer, offset ); glBindVertexArray( vao ); glBindBuffer( GL_ARRAY_BUFFER, vbo ); size_t data_size = sizeof(v3) * array_length( SphereVertices ); glBufferSubData( GL_ARRAY_BUFFER, 0,data_size , SphereVertices ); glBufferSubData( GL_ARRAY_BUFFER, 2 * data_size, data_size, (void *) SphereNormals ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); array_push( w.light_spheres_vao, vao ); array_push( w.light_spheres_vbo, vbo ); world_add_light_sphere_vertex_data( w, array_length(w.light_spheres)-1 ); } void world_add_rect( World &w, const Rectangle &r,Material m ){ array_push( w.rects, r ); m4 transform = HMM_Mat4d( 1.0f ); array_push( w.rect_materials, m ); array_push( w.model_matrices[OBJECT_RECT], transform ); //array_push( w.rect_colors, color ); } void world_add_light_rect( World &w, const Rectangle &r, v3 color ){ array_push( w.light_rects, r ); m4 transform = HMM_Mat4d( 1.0f ); array_push( w.model_matrices[OBJECT_RECT], transform ); array_push( w.light_rect_color, color ); } void world_generate_grid_data( World &w, Grid &g ){ const v3 &color = g.color; glGenVertexArrays(1,&w.grid_vao); glGenBuffers(1,&w.grid_vbo); f32 len = 100.0f; glBindVertexArray( w.grid_vao ); glBindBuffer( GL_ARRAY_BUFFER, w.grid_vbo ); v3 vertex_data[12]; vertex_data[0] = g.rect.corner + len * g.dir1; vertex_data[1] = g.dir2; vertex_data[2] = color; vertex_data[3] = g.rect.corner; vertex_data[4] = g.dir2; vertex_data[5] = color; vertex_data[6] = g.rect.corner; vertex_data[7] = g.dir1; vertex_data[8] = color; vertex_data[9] = g.rect.corner + len * g.dir2; vertex_data[10] = g.dir1; vertex_data[11] = color; glBufferData( GL_ARRAY_BUFFER, sizeof( vertex_data ), vertex_data, GL_STATIC_DRAW ); GLsizei stride = 3 * sizeof(v3); glEnableVertexAttribArray( grid_program_info.pos_id ); glEnableVertexAttribArray( grid_program_info.direction_id); glEnableVertexAttribArray( grid_program_info.color_id ); glVertexAttribPointer( grid_program_info.pos_id, 3, GL_FLOAT, GL_FALSE, stride, (void *)( 0 ) ); glVertexAttribPointer( grid_program_info.direction_id, 3, GL_FLOAT, GL_FALSE, stride, (void *)( sizeof(v3) ) ); glVertexAttribPointer( grid_program_info.color_id, 3, GL_FLOAT, GL_FALSE, stride, (void *)( 2 * sizeof(v3) ) ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); } void world_draw_AABB( const World &w, const AABB &box, v3 color, uint *elem_index ) { // Sorry for this shit, but its the best i can do for now // TODO: find something better f32 xlen = box.u[0] - box.l[0]; f32 ylen = box.u[1] - box.l[1]; f32 zlen = box.u[2] - box.l[2]; array_push( w.color_vertex_data, box.l); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ xlen, 0, 0 }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ xlen, ylen, 0 }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ 0, ylen, 0 }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); // front array_push( w.color_vertex_data, box.l + v3{ 0,0,zlen}); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ xlen, 0, zlen }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ xlen, ylen, zlen }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_data, box.l + v3{ 0, ylen, zlen }); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); uint value = *elem_index; array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value + 4 ); array_push( w.color_vertex_indices, value + 4 ); array_push( w.color_vertex_indices, value + 5 ); array_push( w.color_vertex_indices, value + 5 ); array_push( w.color_vertex_indices, value + 6 ); array_push( w.color_vertex_indices, value + 6 ); array_push( w.color_vertex_indices, value + 7 ); array_push( w.color_vertex_indices, value + 7 ); array_push( w.color_vertex_indices, value + 4 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value + 7 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 6 ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 5 ); *elem_index = value + 8; return; } void world_draw_grid(uint vao,const Grid &g, const m4 &mvp ){ glUseProgram( grid_program_info.id ); // Generate rectangle vertices with line vertices glUniformMatrix4fv( grid_program_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glUniform3fv( grid_program_info.corner_loc, 1, g.rect.corner.Elements ); glUniform1f( grid_program_info.width_loc, g.w ); glBindVertexArray( vao ); glDrawArraysInstanced( GL_LINES, 0, 12, g.nlines ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); glUseProgram( 0 ); } void world_draw_cube(uint vao, const Cube &cube, const m4 &mvp ){ glUseProgram( simple_color_shader_info.id ); glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glBindVertexArray( vao ); glDrawElements( GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); glUseProgram( 0 ); } void world_draw_sphere( uint vao, const Sphere &s, const m4 &mvp ){ glUseProgram( simple_color_shader_info.id ); glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glBindVertexArray( vao ); glDrawElements( GL_TRIANGLES, array_length(SphereIndices), GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); glUseProgram( 0 ); } void draw_world( const World &w ){ m4 v = w.camera->transform(); m4 vp = w.perspective*v; world_draw_grid( w.grid_vao,w.grid,vp); // draw the non-lighting stuff glUseProgram( nl_color_shader_info.id ); m4 *cube_models = w.model_matrices[ OBJECT_LIGHT_CUBE_INSTANCE ]; for ( uint i = 0; i < array_length( w.light_cubes ); i++ ){ m4 mvp = vp * cube_models[i]; glBindVertexArray( w.light_cubes_vao[i] ); glUniformMatrix4fv( nl_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glDrawElements( GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0 ); array_push( w.light_pos, w.light_cubes[i].pos ); array_push( w.light_colors, w.light_cube_color[i] ); } m4 *sphere_models = w.model_matrices[ OBJECT_LIGHT_SPHERE ]; for ( uint i = 0; i < array_length( w.light_spheres ); i++ ){ m4 mvp = vp * sphere_models[i]; glUniformMatrix4fv( nl_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glBindVertexArray( w.light_spheres_vao[i] ); glDrawElements( GL_TRIANGLES, array_length(SphereIndices), GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); array_push( w.light_pos, w.light_spheres[i].c ); array_push( w.light_colors, w.light_sphere_color[i] ); } uint value = 0; for ( uint i = 0; i < array_length( w.light_rects ); i++ ){ Rectangle &r = w.light_rects[i]; v3 &color = w.light_rect_color[i]; array_push( w.light_pos, r.p0 + ( r.l1 / 2 )*r.s1 + (r.l2/2)*r.s2 ); array_push( w.light_colors, w.light_rect_color[i] ); array_push( w.color_vertex_data, r.p0 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p1 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p2 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p3 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); // push the indices array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value ); value += 4; } glBindVertexArray( w.color_vao ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, w.color_ebo ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(uint) * array_length( w.color_vertex_indices ), w.color_vertex_indices, GL_STATIC_DRAW ); glBindBuffer( GL_ARRAY_BUFFER, w.color_vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof(v3) * array_length( w.color_vertex_data ), w.color_vertex_data, GL_STATIC_DRAW ); glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(vp) ); glDrawElements(GL_TRIANGLES,array_length(w.color_vertex_data), GL_UNSIGNED_INT, 0 ); array_clear( w.color_vertex_data ); array_clear( w.color_vertex_indices ); glUseProgram( 0 ); // Draw all the lighting stuff glUseProgram( simple_color_shader_info.id ); glUniform1i( simple_color_shader_info.texture0_loc, 0 ); glUniform3fv(simple_color_shader_info.view_pos_loc, 1, w.camera->P.Elements ); uint loop_count = array_length( w.light_pos ) < 4 ? array_length( w.light_pos ) : 4; for ( uint i = 0; i < loop_count ; i++ ){ PointLightLocation &p = simple_color_shader_info.point_light_loc[i]; glUniform3fv( p.pos_loc,1, w.light_pos[i].Elements ); glUniform3fv( p.color_loc,1, w.light_colors[i].Elements ); } glUniform1i( simple_color_shader_info.num_lights_loc, loop_count ); glUniform3fv( simple_color_shader_info.amb_loc,1, w.amb_light.Elements ); glUniformMatrix4fv( simple_color_shader_info.view_loc, 1,GL_FALSE, HMM_MAT4_PTR(v) ); cube_models = w.model_matrices[ OBJECT_CUBE_INSTANCE ]; for ( uint i = 0; i < array_length( w.cubes ); i++ ){ m4 mvp = vp * cube_models[i]; Material &material = w.cube_materials[i]; Texture &texture = material.texture; glActiveTexture(GL_TEXTURE0); if ( material.type == Material::GLASS ){ glBindTexture( GL_TEXTURE_2D, w.white_texture ); } else { switch ( texture.type ){ case Texture::COLOR: glBindTexture( GL_TEXTURE_2D, w.white_texture ); break; case Texture::CHECKER: glBindTexture( GL_TEXTURE_2D, w.checker_texture ); break; case Texture::MARBLE: glBindTexture( GL_TEXTURE_2D, w.marble_texture ); break; } } glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glUniformMatrix4fv( simple_color_shader_info.model_loc, 1,GL_FALSE, HMM_MAT4_PTR( cube_models[i] ) ); glBindVertexArray( w.cubes_vao[i] ); glDrawElements( GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); } sphere_models = w.model_matrices[ OBJECT_SPHERE ]; for ( uint i = 0; i < array_length( w.spheres ); i++ ){ m4 mvp = vp * sphere_models[i]; Material &material = w.sphere_materials[i]; Texture &texture = material.texture; glActiveTexture(GL_TEXTURE0); if ( material.type == Material::GLASS ){ glBindTexture( GL_TEXTURE_2D, w.white_texture ); } else { switch ( texture.type ){ case Texture::COLOR: glBindTexture( GL_TEXTURE_2D, w.white_texture ); break; case Texture::CHECKER: glBindTexture( GL_TEXTURE_2D, w.checker_texture ); break; case Texture::MARBLE: glBindTexture( GL_TEXTURE_2D, w.marble_texture ); break; } } glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(mvp) ); glUniformMatrix4fv( simple_color_shader_info.model_loc, 1,GL_FALSE, HMM_MAT4_PTR( sphere_models[i] ) ); glBindVertexArray( w.spheres_vao[i] ); glDrawElements( GL_TRIANGLES, array_length(SphereIndices), GL_UNSIGNED_INT, 0 ); glBindVertexArray( 0 ); } glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(vp) ); glUniformMatrix4fv( simple_color_shader_info.view_loc, 1,GL_FALSE, HMM_MAT4_PTR( v ) ); glUniformMatrix4fv( simple_color_shader_info.model_loc, 1,GL_FALSE, HMM_MAT4_PTR( HMM_Mat4d(1.0f) ) ); value = 0; for ( uint i = 0; i < array_length( w.rects ); i++ ){ Rectangle &r = w.rects[i]; Material &material = w.rect_materials[i]; Texture &texture = material.texture; v3 color = texture.color; v2 tc[4]; if ( material.type == Material::GLASS ){ glBindTexture( GL_TEXTURE_2D, w.white_texture ); color = GLASS_COLOR; } else { switch ( texture.type ){ case Texture::COLOR: glBindTexture( GL_TEXTURE_2D, w.white_texture ); tc[0] = v2{ 0.0f, 0.0f }; tc[1] = v2{ 1.0f, 0.0f }; tc[2] = v2{ 1.0f, 1.0f }; tc[3] = v2{ 0.0f, 1.0f }; break; case Texture::CHECKER: { glBindTexture( GL_TEXTURE_2D, w.checker_texture ); f32 unit = 0.5f; f32 len1 = r.l1/unit, len2 = r.l2/unit; tc[0] = v2{ 0.0f, 0.0f }; tc[1] = v2{ len1, 0.0f }; tc[2] = v2{ len1, len2 }; tc[3] = v2{ 0, len2 }; } break; case Texture::MARBLE: { glBindTexture( GL_TEXTURE_2D, w.marble_texture ); tc[0] = v2{ 0.0f, 0.0f }; tc[1] = v2{ 1.0f, 0.0f }; tc[2] = v2{ 1.0f, 1.0f }; tc[3] = v2{ 0.0f, 1.0f }; } break; } } f32 vertexes[100]; memcpy( vertexes, r.p0.Elements, sizeof(r.p0) ); memcpy( vertexes + 3, color.Elements, sizeof(color) ); memcpy( vertexes + 6, r.n.Elements, sizeof(r.n) ); memcpy( vertexes + 9, tc[0].Elements, sizeof( tc[0] ) ); memcpy( vertexes + 11, r.p1.Elements, sizeof(r.p0) ); memcpy( vertexes + 14, color.Elements, sizeof(color) ); memcpy( vertexes + 17, r.n.Elements, sizeof(r.n) ); memcpy( vertexes + 20, tc[1].Elements, sizeof( tc[0] ) ); memcpy( vertexes + 22, r.p2.Elements, sizeof(r.p0) ); memcpy( vertexes + 25, color.Elements, sizeof(color) ); memcpy( vertexes + 28, r.n.Elements, sizeof(r.n) ); memcpy( vertexes + 31, tc[2].Elements, sizeof( tc[0] ) ); memcpy( vertexes + 33, r.p3.Elements, sizeof(r.p0) ); memcpy( vertexes + 36, color.Elements, sizeof(color) ); memcpy( vertexes + 39, r.n.Elements, sizeof(r.n) ); memcpy( vertexes + 42, tc[3].Elements, sizeof( tc[0] ) ); #if 0 array_push( w.color_vertex_data, r.p0 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p1 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p2 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); array_push( w.color_vertex_data, r.p3 ); array_push( w.color_vertex_data, color ); array_push( w.color_vertex_data, r.n ); #endif // push the indices glBindVertexArray( w.rect_vao ); glBindBuffer( GL_ARRAY_BUFFER, w.rect_vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof( f32 ) * 44, vertexes, GL_STATIC_DRAW ); glUniformMatrix4fv( simple_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(vp) ); glDrawElements(GL_TRIANGLES,6, GL_UNSIGNED_INT, 0 ); } glUseProgram( 0 ); // Create line vertex data for rendering value = 0; for ( int i = 0; i < array_length( w.temp_color_quads ); i++ ){ const ColorQuad &quad = w.temp_color_quads[i]; // Push the first triangle array_push( w.color_vertex_data, quad.p0 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p1 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p2 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p3 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); // push the indices array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value ); value += 4; } for ( int i = 0; i < array_length( w.perm_color_quads ); i++ ){ const ColorQuad &quad = w.perm_color_quads[i]; // Push the first triangle array_push( w.color_vertex_data, quad.p0 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p1 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p2 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_data, quad.p3 ); array_push( w.color_vertex_data, quad.color ); array_push( w.color_vertex_data, quad.n ); array_push( w.color_vertex_indices, value ); array_push( w.color_vertex_indices, value + 1 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 2 ); array_push( w.color_vertex_indices, value + 3 ); array_push( w.color_vertex_indices, value ); value += 4; } array_push( w.color_vertex_modes, (GLenum)GL_TRIANGLES ); array_push( w.index_stack, array_length( w.color_vertex_indices ) ); for ( int i = 0; i < array_length( w.lines ); i++ ){ // Push the ending point array_push( w.color_vertex_data, w.lines[i].start ); array_push( w.color_vertex_data, w.lines[i].color ); array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_indices, value++ ); // Push the ending point array_push( w.color_vertex_data,w.lines[i].end ); array_push( w.color_vertex_data, w.lines[i].color ); // Line normal, not necessary and only for debuggin purposes // and another shader prob cost too much array_push( w.color_vertex_data, v3{0.0f,0.0f,0.0f} ); array_push( w.color_vertex_indices, value++ ); } for ( uint i = 0; i < array_length( w.boxes ); i++ ){ world_draw_AABB( w, w.boxes[i], v3{1.0f,1.0f,1.0f }, &value ); } array_push( w.color_vertex_modes, (GLenum)GL_LINES ); array_push( w.index_stack, array_length(w.color_vertex_indices) ); glUseProgram( nl_color_shader_info.id ); glBindVertexArray( w.color_vao ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, w.color_ebo ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof(uint) * array_length( w.color_vertex_indices ), w.color_vertex_indices, GL_STATIC_DRAW ); glBindBuffer( GL_ARRAY_BUFFER, w.color_vbo ); glBufferData( GL_ARRAY_BUFFER, sizeof(v3) * array_length( w.color_vertex_data ), w.color_vertex_data, GL_STATIC_DRAW ); glUniformMatrix4fv( nl_color_shader_info.mvp_loc, 1,GL_FALSE, HMM_MAT4_PTR(vp) ); #if 1 uint prev = 0; for ( int i = 0; i < array_length( w.color_vertex_modes);i++ ){ GLenum mode = w.color_vertex_modes[i]; uint len = w.index_stack[i]; uint count = len - prev; glDrawElements( mode, count, GL_UNSIGNED_INT, (void *)( prev * sizeof(uint) )); prev = len; } #else for ( int i = 1; i < array_length( w.color_vertex_modes ); i++ ){ if ( mode != w.color_vertex_modes[i] ){ len = i - start; glDrawElements( mode, count, GL_UNSIGNED_INT, index ); start = i; mode = w.color_vertex_modes[i]; } } if ( start < array_length( w.color_vertex_modes ) ){ glDrawArrays( mode, start, array_length( w.color_vertex_modes ) - start ); } #endif glUseProgram( 0 ); glBindVertexArray( 0 ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); } bool hit_world( const World &w, const Ray &r, f32 tmin, f32 tmax, HitRecord &record ) { f32 max = tmax; HitRecord temp_record; bool hit_anything = false; if ( hit_grid( w.grid, r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.object = ( void *)&w.grid; record.obj.type = OBJECT_GRID; } for ( int i = 0; i < array_length( w.cubes ); i++ ){ if ( hit_cube( w.cubes[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_CUBE_INSTANCE; } } for ( int i = 0; i < array_length( w.spheres ); i++ ){ if ( hit_sphere( w.spheres[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_SPHERE; } } for ( int i = 0 ; i < array_length( w.rects ); i++ ){ if ( hit_rect( w.rects[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_RECT; } } for ( int i = 0; i < array_length( w.light_cubes ); i++ ){ if ( hit_cube( w.light_cubes[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_LIGHT_CUBE_INSTANCE; } } for ( int i = 0; i < array_length( w.light_spheres ); i++ ){ if ( hit_sphere( w.light_spheres[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_LIGHT_SPHERE; } } for ( int i = 0 ; i < array_length( w.light_rects ); i++ ){ if ( hit_rect( w.light_rects[i], r, tmin, max, temp_record ) ){ hit_anything = true; max = temp_record.t; record = temp_record; record.obj.index = i; record.obj.type = OBJECT_LIGHT_RECT; } } return hit_anything; } void dump_texture_data( DumpObjectData &data, v3 *tex_store, uint index ) { switch ( data.texture_type ){ case DumpObjectData::TEXTURE_PLAIN_COLOR: data.texture_data.color = tex_store[index]; break; case DumpObjectData::TEXTURE_CHECKER: data.texture_data.checker_color[0] = v3{0.0f,0.0f,0.0f}; data.texture_data.checker_color[1] = v3{1.0f,1.0f,1.0f}; break; case DumpObjectData::TEXTURE_MARBLE: data.texture_data.marble_color = tex_store[index]; break; default: break; } } void print_dump_data( DumpObjectData *data ){ } void convert_material_to_dump( DumpObjectData &data, const Material &material ) { switch ( material.type ){ case Material::GLASS: printf("Dumping Glass material with value %d\n", DumpObjectData::MATERIAL_GLASS ); data.material_type = DumpObjectData::MATERIAL_GLASS; data.material_data.ri = 1.33f; break; case Material::PURE_DIFFUSE: data.material_type = DumpObjectData::MATERIAL_PURE_DIFFUSE; break; case Material::METALLIC: data.material_type = DumpObjectData::MATERIAL_METALLIC; data.material_data.fuzz = 0.01f; break; } } void convert_texture_to_dump( DumpObjectData &data, const Texture &texture ) { switch ( texture.type ){ case Texture::COLOR: printf("Dumping color texture with value %d\n", DumpObjectData::TEXTURE_PLAIN_COLOR ); data.texture_type= DumpObjectData::TEXTURE_PLAIN_COLOR; data.texture_data.color = texture.color; break; case Texture::MARBLE: printf("Dumping marble texture with value %d\n", DumpObjectData::TEXTURE_MARBLE ); data.texture_type = DumpObjectData::TEXTURE_MARBLE; data.texture_data.marble_color = texture.color; break; case Texture::CHECKER: printf("Dumping checker texture with value %d\n", DumpObjectData::TEXTURE_CHECKER ); data.texture_type = DumpObjectData::TEXTURE_CHECKER; data.texture_data.checker_color[0] = texture.color; data.texture_data.checker_color[1] = v3{0.0f,0.0f,0.0f}; data.texture_data.freq = 8.0f; break; } } void world_dump_rect_data( const World &w, DumpObjectData *store ){ Rectangle *rects = w.rects; for ( uint i = 0; i < array_length( rects ); i++ ){ Material &material = w.rect_materials[i]; Texture &texture = material.texture; DumpObjectData data; data.type = DumpObjectData::RECTANGLE; data.object_data.p0 = rects[i].p0; data.object_data.s1 = rects[i].s1; data.object_data.s2 = rects[i].s2; data.object_data.n = rects[i].n; data.object_data.l1= rects[i].l1; data.object_data.l2= rects[i].l2; convert_material_to_dump( data, material ); convert_texture_to_dump( data, texture ); array_push( store, data ); } } void world_dump_sphere_data( const World &w, DumpObjectData *store ){ Sphere *spheres= w.spheres; for ( uint i = 0; i < array_length( spheres ); i++ ){ Material &material = w.sphere_materials[i]; Texture &texture = material.texture; DumpObjectData data; data.type = DumpObjectData::SPHERE; data.object_data.center = spheres[i].c; data.object_data.radius = spheres[i].r; convert_material_to_dump( data, material ); convert_texture_to_dump( data, texture ); array_push( store, data ); } } void apply_cube_transform_to_rect( Rectangle &r, Cube &cube ){ q4 quat = HMM_NormalizeQuaternion( cube.orientation ); r.l1 = cube.length; r.l2 = cube.length; r.p0 = rotate_vector_by_quaternion( r.p0,quat ); r.s1 = rotate_vector_by_quaternion( r.s1, quat ); r.s2 = rotate_vector_by_quaternion( r.s2, quat ); r.n = rotate_vector_by_quaternion( r.n, quat ); r.p0 += cube.pos; } void world_dump_cube_data( const World &w, DumpObjectData *store ){ for ( uint i = 0; i < array_length( w.cubes ); i++ ){ Rectangle rects[6]; generate_cube_rects( rects, w.cubes[i].length ); Material &material = w.cube_materials[i]; Texture &texture = material.texture; for ( uint faces = 0; faces < 6; faces++ ){ DumpObjectData data; data.type = DumpObjectData::RECTANGLE; // Apply cube transformation to the rectangle apply_cube_transform_to_rect(rects[faces], w.cubes[i] ); data.object_data.p0 = rects[faces].p0; data.object_data.s1 = rects[faces].s1; data.object_data.s2 = rects[faces].s2; data.object_data.n = rects[faces].n; data.object_data.l1= rects[faces].l1; data.object_data.l2= rects[faces].l2; convert_material_to_dump( data, material ); switch ( texture.type ){ case Texture::COLOR: printf("Dumping color texture with value %d\n", DumpObjectData::TEXTURE_PLAIN_COLOR ); data.texture_type= DumpObjectData::TEXTURE_PLAIN_COLOR; data.texture_data.color = texture.face_colors[faces]; break; case Texture::MARBLE: printf("Dumping marble texture with value %d\n", DumpObjectData::TEXTURE_MARBLE ); data.texture_type = DumpObjectData::TEXTURE_MARBLE; data.texture_data.marble_color = texture.face_colors[faces]; break; case Texture::CHECKER: printf("Dumping checker texture with value %d\n", DumpObjectData::TEXTURE_CHECKER ); data.texture_type = DumpObjectData::TEXTURE_CHECKER; data.texture_data.checker_color[0] = texture.face_colors[faces]; data.texture_data.checker_color[1] = v3{0.0f,0.0f,0.0f}; data.texture_data.freq = 2.0f; break; } array_push( store, data ); } } } void world_dump_light_rect_data( const World &w, DumpObjectData *store ) { Rectangle *rects = w.light_rects; for ( uint i = 0; i < array_length( rects ); i++ ){ DumpObjectData data; data.type = DumpObjectData::RECTANGLE; data.object_data.p0 = rects[i].p0; data.object_data.s1 = rects[i].s1; data.object_data.s2 = rects[i].s2; data.object_data.n = rects[i].n; data.object_data.l1= rects[i].l1; data.object_data.l2= rects[i].l2; data.material_type = DumpObjectData::MATERIAL_DIFFUSE_LIGHT; data.material_data.diff_light_color = w.light_rect_color[ i ] * 10.0f; array_push( store, data ); } } void world_dump_light_sphere_data( const World &w, DumpObjectData *store ) { Sphere *spheres= w.light_spheres; for ( uint i = 0; i < array_length( spheres ); i++ ){ DumpObjectData data; data.type = DumpObjectData::SPHERE; data.object_data.center = w.light_spheres[i].c; data.object_data.radius = w.light_spheres[i].r; data.material_type = DumpObjectData::MATERIAL_DIFFUSE_LIGHT; data.material_data.diff_light_color = w.light_sphere_color[ i ] * 10.0f; array_push( store, data ); } } void world_dump_light_cube_data( const World &w, DumpObjectData *store ) { Cube *cubes = w.light_cubes; for ( uint i = 0; i < array_length( cubes ); i++ ){ for ( uint faces = 0; faces < 6; faces++ ){ DumpObjectData data; data.type = DumpObjectData::RECTANGLE; // Apply cube transformation to the rectangle Rectangle r = CubeRects[ faces ]; apply_cube_transform_to_rect(r, w.light_cubes[i] ); data.object_data.p0 = r.p0; data.object_data.s1 = r.s1; data.object_data.s2 = r.s2; data.object_data.n = r.n; data.object_data.l1= r.l1; data.object_data.l2= r.l2; data.material_type = DumpObjectData::MATERIAL_DIFFUSE_LIGHT; data.material_data.diff_light_color = w.light_cube_color[i] * 10.0f; array_push( store, data ); } } } void world_dump_scene_to_file( const World &w, const char *file ) { DumpObjectData *data_store = array_allocate( DumpObjectData, 100 ); DumpCameraData cam; cam.look_from = w.view_camera.P; cam.look_at = w.view_camera.P + w.view_camera.F; cam.z = w.view_near_plane; cam.vfov = w.view_vfov; cam.aspect_ratio = (f32)ScreenWidth/ScreenHeight; cam.aperture = 0.0f; cam.focal_dist = 1.0f; world_dump_rect_data( w, data_store ); world_dump_cube_data( w, data_store ); world_dump_sphere_data( w, data_store ); world_dump_light_cube_data( w, data_store ); world_dump_light_sphere_data( w, data_store ); world_dump_light_rect_data( w, data_store ); FILE *fp = fopen(file,"wb"); if( !fp ){ perror("Unable to open file for output!: "); array_free( data_store ); return; } fwrite( &cam, sizeof(cam), 1, fp ); uint32 len = array_length( data_store ); fwrite( &len, sizeof(len), 1, fp ); fwrite( data_store, sizeof(*data_store), array_length( data_store ), fp ); fclose( fp ); array_free( data_store ); return; } uint8 *load_image( const char *fname, int *width, int *height, int *channels ){ uint8 *data = (uint8 *)stbi_load( fname, width, height, channels, 4 ); if ( data == NULL ){ fprintf( stderr, "Unable to load image %s!", fname ); return NULL; } else { fprintf( stdout, "Image loaded successfully. width = %d, height = %d\n", *width, *height ); } return data; } Image create_image( const char *fname ){ Image image; image.data = load_image( fname, &image.w, &image.h, &image.channels ); return image; } Texture cube_color_texture( ){ Texture t; t.type = Texture::COLOR; t.face_colors[0] = v3{prng_float(), prng_float(), prng_float() }; t.face_colors[1] = v3{prng_float(), prng_float(), prng_float() }; t.face_colors[2] = v3{prng_float(), prng_float(), prng_float() }; t.face_colors[3] = v3{prng_float(), prng_float(), prng_float() }; t.face_colors[4] = v3{prng_float(), prng_float(), prng_float() }; t.face_colors[5] = v3{prng_float(), prng_float(), prng_float() }; return t; } Texture sphere_color_texture( ){ Texture t; t.type = Texture::COLOR; t.color = v3{prng_float(), prng_float(), prng_float() }; return t; } Texture rectangle_color_texture( ){ Texture t; t.type = Texture::COLOR; t.color = v3{prng_float(), prng_float(), prng_float() }; return t; } int main(){ prng_seed(); generate_sphere_vertices(); bool dump_scene_data = false; uint dump_count = 0; glfwInit(); glfwWindowHint( GLFW_CONTEXT_VERSION_MAJOR, 4 ); glfwWindowHint( GLFW_CONTEXT_VERSION_MINOR, 3 ); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); GLFWwindow* window = glfwCreateWindow( ScreenWidth,ScreenHeight, "OpenGl", NULL, NULL ); if ( !window ){ print_error("Unable to open window!"); } glfwMakeContextCurrent( window ); glfwSetFramebufferSizeCallback( window, resizeCallback ); //glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED ); glfwSetCursorPosCallback( window, mouse_callback ); glfwSetMouseButtonCallback(window, mouse_button_callback); glfwSetKeyCallback( window, key_callback ); if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) { print_error("Failed to initialize GLAD"); return -1; } #if ENABLE_GL_DEBUG_PRINT GLint flags; glGetIntegerv(GL_CONTEXT_FLAGS, &flags); if (flags & GL_CONTEXT_FLAG_DEBUG_BIT) { glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); glDebugMessageCallback(glDebugOutput, nullptr); glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, nullptr, GL_TRUE); } else { print_error("Unable to set debug context"); } #endif glEnable( GL_DEPTH_TEST ); Quad_elem_indices= ( uint * )malloc( 6 * 1000 * sizeof( uint ) ); uint t[] = { 0, 1, 2, 2, 3, 0 }; uint *tmp = Quad_elem_indices; for ( int i = 0; i < 1000; i++ ){ for ( int j = 0; j < 6; j++ ){ *tmp = t[j] + 4 * i; tmp++; } } glGenBuffers(1,&quad_elem_buffer_index); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, quad_elem_buffer_index ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( uint ) * 100, Quad_elem_indices, GL_STATIC_DRAW ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); glGenBuffers( 1, &sphere_element_buffer ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, sphere_element_buffer ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( uint ) * array_length( SphereIndices ), SphereIndices, GL_STATIC_DRAW ); if ( create_grid_program() == -1 ){ return -1; } if ( create_simple_color_shader_program() == -1 ){ return -1; } if ( create_nl_color_shader_program() == -1 ){ return -1; } // Load images for texture // uint8 white_texture_data[] = { 255, 255, 255, 255 }; Image checker_image = create_image( "./assets/checkers.png" ); Image white_marble_image = create_image( "./assets/White-Marble-1024.png" ); Image white_image = create_image( "./assets/white.png" ); // create textures Texture checker_texture; checker_texture.type = Texture::CHECKER; checker_texture.image = checker_image; Texture white_marble_texture; white_marble_texture.type = Texture::MARBLE; white_marble_texture.image = white_marble_image; Texture color_texture; color_texture.type = Texture::COLOR; // create_world World *world = (World *)malloc( sizeof(World) ); World &w = *world; w.amb_light = { 0.3f, 0.3f, 0.3f }; w.grid = create_grid( AARect::PLANE_ZX, AABB( v3{ -10.0f, 0.0f, -10.0f }, v3{ 10.0f, 0.0f, 10.0f } ), 0.0f, 0.1f, v3{0.0f,0.0f,1.0f} ); w.ui_vfov = 45; w.ui_near_plane = 0.1f; w.ui_far_plane = 100.0f; w.ui_perspective= HMM_Perspective(45, (float)ScreenWidth/ScreenHeight, 0.1f, 10.0f ); w.view_vfov = 45; w.view_near_plane = 0.1f; w.view_far_plane = 100.0f; w.view_perspective = HMM_Perspective(w.view_vfov, (float)ScreenWidth/ScreenHeight, w.view_near_plane, w.view_far_plane ); w.perspective = w.ui_perspective; uint current_screen_width = ScreenWidth; uint current_screen_height = ScreenHeight; w.ui_camera = Camera( v3{ 0.0f, 0.5f, 5.0f }, v3{ 0.0f, 0.5f, -1.0f }, v3{ 0.0f, 1.0f, 0.0f } ); w.view_camera = Camera( v3{ 0.0f, 0.5f, 5.0f }, v3{ 0.0f, 0.5f, -1.0f }, v3{ 0.0f, 1.0f, 0.0f } ); Cube cube = create_cube_one_color( 0.5f, v3{1,0.25,0}, v3 {0,1,0} ); w.cube.color[Cube::FRONT] = v3{0.82f, 0.36f, 0.45f}; w.cube.color[Cube::BACK] = v3{0.82f, 0.36f, 0.45f}; w.cube.color[Cube::LEFT] = v3{0.32f, 0.32f, 0.86f}; w.cube.color[Cube::RIGHT] = v3{0.32f, 0.32f, 0.86f}; #if 0 world_generate_cube_data(w.cube_vao, w.cube_vbo, w.cube ); world_add_cube_vertex_data( w.cube_vao, w.cube_vbo, w.cube ); #endif for ( uint i = 0; i < _OBJECT_MAX; i++ ){ w.model_matrices[ i ] = array_allocate( m4, 10 ); } w.cubes = array_allocate( Cube, 10 ); w.rects = array_allocate( Rectangle, 10 ); w.boxes = array_allocate( AABB, 10 ); w.lines = array_allocate( Line, 10 ); w.spheres = array_allocate( Sphere, 10 ); w.spheres_transform = array_allocate( m4, 10 ); w.sphere_colors = array_allocate( v3, 10 ); w.rect_colors = array_allocate(v3,10 ); w.cube_materials = array_allocate( Material, 10 ); w.sphere_materials = array_allocate( Material, 10 ); w.rect_materials= array_allocate( Material, 10 ); w.light_cubes = array_allocate( Cube, 10 ); w.light_rects = array_allocate( Rectangle, 10 ); w.light_spheres = array_allocate( Sphere, 10 ); w.light_pos = array_allocate( v3, 10 ); w.light_colors = array_allocate( v3, 10 ); w.light_cube_color = array_allocate( v3, 10 ); w.light_sphere_color = array_allocate( v3, 10 ); w.light_rect_color = array_allocate( v3, 10 ); w.light_cubes_vao = array_allocate( uint, 10 ); w.light_spheres_vao = array_allocate( uint, 10 ); w.light_cubes_vbo = array_allocate( uint, 10 ); w.light_spheres_vbo = array_allocate( uint, 10 ); w.temp_color_quads = array_allocate( ColorQuad, 10 ); w.perm_color_quads = array_allocate( ColorQuad, 10 ); w.cubes_vao = array_allocate( uint, 10 ); w.cubes_vbo = array_allocate( uint, 10 ); w.spheres_vao = array_allocate( uint, 10 ); w.spheres_vbo = array_allocate( uint, 10 ); w.rect_flip_normal = 0; w.color_vertex_data = array_allocate( v3, 1000 ); w.color_vertex_indices = array_allocate( uint, 3000 ); w.index_stack = array_allocate( uint, 10 ); w.color_vertex_modes = array_allocate( GLenum ,10 ); glGenVertexArrays(1, &w.color_vao ); glGenBuffers( 1, &w.color_vbo ); glGenBuffers( 1, &w.color_ebo ); glBindVertexArray( w.color_vao ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, w.color_ebo ); glBufferData( GL_ELEMENT_ARRAY_BUFFER, 1000 * sizeof(v3), NULL, GL_STATIC_DRAW ); glBindBuffer( GL_ARRAY_BUFFER, w.color_vbo ); glBufferData( GL_ARRAY_BUFFER, 2000 * sizeof(v3), NULL, GL_STATIC_DRAW ); glEnableVertexAttribArray( simple_color_shader_info.pos_id ); glEnableVertexAttribArray( simple_color_shader_info.color_id ); glEnableVertexAttribArray( simple_color_shader_info.normal_id ); glVertexAttribPointer( simple_color_shader_info.pos_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3), (void *)( 0 ) ); glVertexAttribPointer( simple_color_shader_info.color_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3), (void *)(sizeof(v3) ) ); glVertexAttribPointer( simple_color_shader_info.normal_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3), (void *)(2 * sizeof(v3) ) ); glBindVertexArray( 0 ); glGenVertexArrays( 1, &w.rect_vao ); glGenBuffers( 1, &w.rect_vbo ); glBindVertexArray( w.rect_vao ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, quad_elem_buffer_index ); glBindBuffer( GL_ARRAY_BUFFER, w.rect_vbo ); glBufferData( GL_ARRAY_BUFFER, 200 * sizeof(v3), NULL, GL_STATIC_DRAW ); glEnableVertexAttribArray( simple_color_shader_info.pos_id ); glEnableVertexAttribArray( simple_color_shader_info.color_id ); glEnableVertexAttribArray( simple_color_shader_info.normal_id ); glEnableVertexAttribArray( simple_color_shader_info.tex_coords_id); glVertexAttribPointer( simple_color_shader_info.pos_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3) + sizeof(v2), (void *)( 0 ) ); glVertexAttribPointer( simple_color_shader_info.color_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3) + sizeof(v2), (void *)(sizeof(v3) ) ); glVertexAttribPointer( simple_color_shader_info.normal_id, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(v3) + sizeof(v2), (void *)(2 * sizeof(v3) ) ); glVertexAttribPointer( simple_color_shader_info.tex_coords_id, 2, GL_FLOAT, GL_FALSE, 3 * sizeof(v3) + sizeof(v2), (void *)(3 * sizeof(v3) ) ); glBindVertexArray( 0 ); // generate opengl Textures glGenTextures( 1, &w.white_texture ); glGenTextures( 1, &w.checker_texture); glGenTextures( 1, &w.marble_texture); glBindTexture(GL_TEXTURE_2D, w.white_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, white_texture_data ); glGenerateMipmap(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, w.checker_texture ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, checker_image.w, checker_image.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, checker_image.data ); glGenerateMipmap(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, w.marble_texture ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, white_marble_image.w, white_marble_image.h, 0, GL_RGBA, GL_UNSIGNED_BYTE, white_marble_image.data ); glGenerateMipmap(GL_TEXTURE_2D); Material m = create_material_diffuse( cube_color_texture() ); world_add_cube( w, &cube, m ); m = create_material_metallic( sphere_color_texture() ); world_add_sphere( w,create_sphere( v3{0.0f,0.0f,0.0f}, 1.0f ) , m ); m = create_material_diffuse( rectangle_color_texture() ); world_add_rect( w,create_rectangle( v3{-1.0f,2.0f,3.0f } ), m ); w.model_matrices[OBJECT_CUBE_INSTANCE][0] = cube.base_transform; world_generate_grid_data(w, w.grid ); #define WORLD_SET_STATE_FREE_VIEW \ do {\ w.camera = &w.ui_camera;\ w.perspective = w.ui_perspective;\ w.state = World::STATE_FREE_VIEW;\ w.show_imgui = false;\ w.camera->should_rotate = true;\ w.camera->should_move = true;\ w.is_selected = false;\ glfwSetCursorPosCallback( window, mouse_callback );\ } while ( 0 ) #define WORLD_SET_STATE_DETACHED\ do {\ w.camera = &w.ui_camera;\ w.perspective = w.ui_perspective;\ w.state = World::STATE_DETACHED;\ w.show_imgui = true;\ w.camera->should_rotate = false;\ w.camera->should_move = true;\ w.is_selected = false;\ glfwSetCursorPosCallback( window, NULL );\ } while ( 0 ) #define WORLD_SET_STATE_SELECTED\ do {\ w.camera = &w.ui_camera;\ w.perspective = w.ui_perspective;\ w.state = World::STATE_SELECTED;\ w.show_imgui = true;\ w.camera->should_rotate = false;\ w.camera->should_move = false;\ glfwSetCursorPosCallback( window, NULL );\ } while ( 0 ) #define WORLD_SET_STATE_ON_HOLD\ do {\ w.camera = &w.ui_camera;\ w.perspective = w.ui_perspective;\ w.state = World::STATE_ON_HOLD;\ w.show_imgui = false;\ w.camera->should_rotate = false;\ w.camera->should_move = true;\ w.is_holding = true;\ glfwSetCursorPosCallback( window, NULL );\ } while ( 0 ) #define WORLD_SET_STATE_VIEW_CAMERA\ do {\ w.camera = &w.view_camera;\ w.perspective = w.view_perspective;\ w.state = World::STATE_VIEW_CAMERA;\ w.show_imgui = true;\ w.camera->should_rotate = true;\ w.camera->should_move = true;\ w.is_holding = false;\ glfwSetCursorPosCallback( window, mouse_callback );\ } while ( 0 ) glBindBuffer( GL_ARRAY_BUFFER, 0 ); int viewport[4]; glGetIntegerv( GL_VIEWPORT, viewport); float dt = 0; float current = glfwGetTime(); m4 vp = HMM_Mat4d(1.0f); double cp[2]; glfwGetCursorPos( window, &cp[0], &cp[1] ); f32 camera_sensitivity = 0.5f; uint8 *key_map = (uint8 *)malloc( sizeof(uint8) * 400 ); memset( key_map, 0, 400 * sizeof(uint8) ); IMGUI_CHECKVERSION(); ImGui::CreateContext(); ImGuiIO& io = ImGui::GetIO(); (void)io; //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls // Setup Dear ImGui style ImGui::StyleColorsDark(); //ImGui::StyleColorsClassic(); // Setup Platform/Renderer bindings ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 430 core"); bool show_imgui = false; bool show_demo_window = false; bool show_another_window = false; ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f); w.camera = &w.ui_camera; WORLD_SET_STATE_FREE_VIEW; while ( !glfwWindowShouldClose( window ) ){ float now = glfwGetTime(); dt = now - current; current = now; if ( current_screen_width != ScreenWidth || current_screen_height != ScreenHeight ) { w.ui_perspective= HMM_Perspective(w.ui_vfov, (float)ScreenWidth/ScreenHeight, w.ui_near_plane, w.ui_far_plane ); w.view_perspective= HMM_Perspective(w.view_vfov, (float)ScreenWidth/ScreenHeight, w.view_near_plane, w.view_far_plane ); if ( w.state == World::STATE_VIEW_CAMERA ){ w.perspective = w.view_perspective; } else { w.perspective = w.ui_perspective; } current_screen_width = ScreenWidth; current_screen_height = ScreenHeight; } process_keyboard_input( window, key_map ); //check camera events for ( int i = 0; i < Event_Count; i++ ){ switch ( Event_Queue[i].type ){ case MOUSE_MOVE: { f32 dx = Event_Queue[i].xp - cp[0]; f32 dy = Event_Queue[i].yp - cp[1]; #if 0 if ( w.state == World::STATE_VIEW_CAMERA ){ w.camera->rotate( -camera_sensitivity*dx, -camera_sensitivity*dy ); } else { w.camera->rotate( camera_sensitivity*dx, camera_sensitivity*dy ); } #endif w.camera->rotate( camera_sensitivity*dx, camera_sensitivity*dy ); cp[0] = Event_Queue[i].xp; cp[1] = Event_Queue[i].yp; break; } case MOUSE_RBUTTON_CLICK: { if ( w.state == World::STATE_VIEW_CAMERA ) break; HitRecord record; v3 point = v3{ ( float )cp[0], (float)cp[1], 0.0f }; v3 wp = HMM_UnProject( point, w.perspective * w.camera->transform(), ScreenWidth, ScreenHeight); Ray ray( w.camera->P, ( wp - w.camera->P ) ); if ( hit_grid( w.grid, ray, 0.001f, 100.0f, record ) ){ record.print(); v3 p0 = grid_get_corner_point( w.grid, record.u, record.v ); print_v3( p0 ); v3 p1 = p0 + w.grid.dir1 * w.grid.w; v3 p2 = p0 + w.grid.dir1 * w.grid.w + w.grid.dir2 * w.grid.w; v3 p3 = p0 + w.grid.dir2 * w.grid.w; ColorQuad quad = { p0, p1, p2, p3, v3{ 0.52f,0.15f,0.93f }, // color w.grid.rect.n }; array_push( w.perm_color_quads, quad ); } #if 0 array_push( w.lines, create_line_from_ray( ray, 10.0f, v3{0,1.0f,0.0f} ) ); #endif break; } case MOUSE_LBUTTON_CLICK: { switch ( w.state ){ case World::STATE_VIEW_CAMERA: case World::STATE_SELECTED: break; case World::STATE_FREE_VIEW: case World::STATE_DETACHED: { glfwGetCursorPos( window, &cp[0], &cp[1] ); HitRecord record; v3 point = v3{ ( float )cp[0], (float)cp[1], 0.0f }; v3 wp = HMM_UnProject( point, w.perspective * w.camera->transform(), ScreenWidth, ScreenHeight ); Ray ray( w.camera->P, ( wp - w.camera->P ) ); if ( hit_world( w, ray, 0.001f, 100.0f, record ) ){ w.is_selected = record.obj.type != OBJECT_GRID; switch ( record.obj.type ){ case OBJECT_LIGHT_CUBE_INSTANCE: case OBJECT_CUBE_INSTANCE: WORLD_SET_STATE_SELECTED; w.selected_object = record.obj; w.selected_aabb = cube_get_AABB; w.selected_move = cube_move; w.selected_rotate = cube_rotate; w.selected_scale = cube_scale; if ( record.obj.type == OBJECT_CUBE_INSTANCE ){ w.cube_face_dropdown = 0; w.selected_data = (void *)( w.cubes + w.selected_object.index ); w.sel_cube_length = w.cubes[w.selected_object.index].length; w.cube_material_dropdown = w.cube_materials[w.selected_object.index].type; w.cube_texture_dropdown = w.cube_materials[w.selected_object.index].texture.type; w.cube_face_color= w.cube_materials[w.selected_object.index].texture.face_colors[0]; } else { w.light_cube_face_color = w.light_cube_color[ w.selected_object.index ]; w.selected_data = (void *)( w.light_cubes + w.selected_object.index ); w.sel_cube_length = w.light_cubes[w.selected_object.index].length; } break; case OBJECT_LIGHT_SPHERE: case OBJECT_SPHERE: WORLD_SET_STATE_SELECTED; w.selected_object = record.obj; w.selected_aabb = sphere_aabb; w.selected_move = sphere_move; w.selected_rotate = sphere_rotate; w.selected_scale= sphere_scale; if ( record.obj.type == OBJECT_SPHERE ){ w.sphere_face_color = w.sphere_colors[ record.obj.index ]; w.selected_data = (void *)( w.spheres + w.selected_object.index ); w.sel_sphere_radius = w.spheres[w.selected_object.index].r; w.sphere_material_dropdown = w.sphere_materials[w.selected_object.index].type; w.sphere_texture_dropdown = w.sphere_materials[w.selected_object.index].texture.type; } else { w.light_sphere_face_color = w.light_sphere_color[ record.obj.index ]; w.selected_data = (void *)( w.light_spheres + w.selected_object.index ); w.sel_sphere_radius = w.light_spheres[w.selected_object.index].r; } break; case OBJECT_LIGHT_RECT: case OBJECT_RECT: WORLD_SET_STATE_SELECTED; w.selected_object = record.obj; w.selected_aabb = rectangle_AABB; w.selected_move = rectangle_move; w.selected_rotate = rectangle_rotate; w.selected_scale= rectangle_scale; if ( record.obj.type == OBJECT_RECT ){ w.rect_face_color= w.rect_materials[ w.selected_object.index].texture.color; w.selected_data = (void *)( w.rects+ w.selected_object.index ); w.sel_rect_l1= w.rects[w.selected_object.index].l1; w.sel_rect_l2= w.rects[w.selected_object.index].l2; w.rect_material_dropdown = w.rect_materials[w.selected_object.index].type; w.rect_texture_dropdown = w.rect_materials[w.selected_object.index].texture.type; } else { w.light_rect_face_color = w.light_rect_color[ record.obj.index ]; w.selected_data = (void *)( w.light_rects+ w.selected_object.index ); w.sel_rect_l1= w.light_rects[w.selected_object.index].l1; w.sel_rect_l2= w.light_rects[w.selected_object.index].l2; } break; case OBJECT_GRID: if ( w.state == World::STATE_FREE_VIEW ) break; WORLD_SET_STATE_ON_HOLD; // Display a see-through silhoulette switch( w.hold_object_id ){ case 0: // This is a cube { } break; case 1: // This is a AARect break; } break; default: break; } } break; } case World::STATE_ON_HOLD: { glfwGetCursorPos( window, &cp[0], &cp[1] ); HitRecord record; v3 point = v3{ ( float )cp[0], (float)cp[1], 0.0f }; v3 wp = HMM_UnProject( point, w.perspective * w.camera->transform(), ScreenWidth, ScreenHeight ); Ray ray( w.camera->P, ( wp - w.camera->P ) ); if ( hit_world( w, ray, 0.001f, 100.0f, record ) ){ if( record.obj.type == OBJECT_GRID ){ switch ( w.hold_object_id ){ case 0: { Material m = create_material_diffuse( cube_color_texture() ); Cube cube = create_cube_one_color( 0.2f, record.p, v3 {0,1,0} ) ; world_add_cube( w, &cube, m ); WORLD_SET_STATE_SELECTED; w.is_selected = true; w.selected_object.type = OBJECT_CUBE_INSTANCE; w.selected_object.index = array_length(w.cubes)-1; w.selected_aabb = cube_get_AABB; w.selected_move = cube_move; w.selected_rotate = cube_rotate; w.cube_face_dropdown = 0; w.cube_material_dropdown = w.cube_materials[w.selected_object.index].type; w.cube_texture_dropdown = w.cube_materials[w.selected_object.index].texture.type; w.cube_face_color= w.cube_materials[w.selected_object.index].texture.face_colors[0]; w.selected_data = (void *)( w.cubes + w.selected_object.index ); w.sel_cube_length = 0.2f; break; } case 1: { Material mat = create_material_metallic( sphere_color_texture() ); Sphere s = create_sphere( record.p, 0.5f ); world_add_sphere( w,s,mat ); WORLD_SET_STATE_SELECTED; w.sel_sphere_radius = 0.5f; w.is_selected = true; w.selected_object.type = OBJECT_SPHERE; w.selected_object.index = array_length(w.spheres)-1; w.selected_aabb = sphere_aabb; w.selected_move = sphere_move; w.selected_rotate = sphere_rotate; w.sphere_material_dropdown = w.sphere_materials[w.selected_object.index].type; w.sphere_texture_dropdown = w.sphere_materials[w.selected_object.index].texture.type; w.sphere_face_color= w.sphere_materials[w.selected_object.index].texture.color; w.selected_data = (void *)( w.spheres+ w.selected_object.index ); break; } case 2: { Material mat = create_material_diffuse( rectangle_color_texture() ); Rectangle r = create_rectangle( record.p ); world_add_rect( w,r,mat ); WORLD_SET_STATE_SELECTED; w.sel_rect_l1 = r.l1; w.sel_rect_l2 = r.l2; w.is_selected = true; w.selected_object.type = OBJECT_RECT; w.selected_object.index = array_length(w.rects)-1; w.selected_aabb = rectangle_AABB; w.selected_move = rectangle_move; w.selected_rotate = rectangle_rotate; w.rect_face_color = mat.texture.color; w.rect_material_dropdown = w.rect_materials[w.selected_object.index].type; w.rect_texture_dropdown = w.rect_materials[w.selected_object.index].texture.type; w.selected_data = (void *)( w.rects + w.selected_object.index ); break; } case 3: { Cube cube = create_cube_one_color( 0.2f, record.p, v3 {1,1,1} ) ; world_add_light_cube( w, &cube, v3{1,1,1} ); WORLD_SET_STATE_SELECTED; w.sel_cube_length = 0.2f; w.is_selected = true; w.selected_object.type = OBJECT_LIGHT_CUBE_INSTANCE; w.selected_object.index = array_length(w.light_cubes)-1; w.selected_aabb = cube_get_AABB; w.selected_move = cube_move; w.selected_rotate = cube_rotate; w.light_cube_face_color = v3{1,1,1}; w.selected_data = (void *)( w.light_cubes + w.selected_object.index ); break; } case 4: { Sphere s = create_sphere( record.p, 0.5f ); world_add_light_sphere( w,s,v3{1.0f,1.0f,1.0f} ); WORLD_SET_STATE_SELECTED; w.sel_sphere_radius = 0.5f; w.is_selected = true; w.selected_object.type = OBJECT_LIGHT_SPHERE; w.selected_object.index=array_length(w.light_spheres)-1; w.selected_aabb = sphere_aabb; w.selected_move = sphere_move; w.selected_rotate = sphere_rotate; w.light_sphere_face_color=v3{1.0f,1.0f,1.0f}; w.selected_data = (void *)( w.light_spheres+ w.selected_object.index ); break; } case 5: { Rectangle r = create_rectangle( record.p ); world_add_light_rect( w,r,v3{1,1,1} ); WORLD_SET_STATE_SELECTED; w.is_selected = true; w.sel_rect_l1 = r.l1; w.sel_rect_l2 = r.l2; w.selected_object.type = OBJECT_LIGHT_RECT; w.selected_object.index = array_length(w.light_rects)-1; w.selected_aabb = rectangle_AABB; w.selected_move = rectangle_move; w.selected_rotate = rectangle_rotate; w.light_rect_face_color=v3{1.0f,1,1}; w.selected_data = (void *)( w.light_rects + w.selected_object.index ); break; } default: break; } } } } break; default: break; } } break; #define SELECTED_MOVE_DIST 0.02f #define SELECTED_MOVE_UP v3{0.0f,1.0f,0.0f} #define SELECTED_MOVE_RIGHT v3{1.0f,0.0f,0.0f} #define SELECTED_MOVE_FRONT v3{0.0f,0.0f,-1.0f} #if 1 case KB_PRESS_W: case KB_REPEAT_W: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 2, 0.2f ,100); } else { w.selected_move( w.selected_data, SELECTED_MOVE_DIST, SELECTED_MOVE_FRONT, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_S:case KB_REPEAT_S: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 2, -0.2f ,100); } else { w.selected_move( w.selected_data, -SELECTED_MOVE_DIST, SELECTED_MOVE_FRONT, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_A:case KB_REPEAT_A: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 0, -0.2f ,100); } else { w.selected_move( w.selected_data, -SELECTED_MOVE_DIST, SELECTED_MOVE_RIGHT, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_D:case KB_REPEAT_D: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 0, 0.2f ,100); } else { w.selected_move( w.selected_data, SELECTED_MOVE_DIST, SELECTED_MOVE_RIGHT, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_I:case KB_REPEAT_I: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 1, 0.2f ,300); } else { w.selected_move( w.selected_data, SELECTED_MOVE_DIST, SELECTED_MOVE_UP, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_K:case KB_REPEAT_K: if ( w.state != World::STATE_SELECTED ){ w.camera->start_animate( 1, -0.2f ,300); } else { w.selected_move( w.selected_data, -SELECTED_MOVE_DIST, SELECTED_MOVE_UP, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_X: case KB_REPEAT_X: show_imgui = !show_imgui; break; case KB_PRESS_T: break; case KB_PRESS_R: WORLD_SET_STATE_DETACHED; w.object_select_dropdown = 0; break; case KB_PRESS_P: w.camera->print(); break; case KB_RELEASE_W: if ( !( key_map[KB_KEY_S] || key_map[KB_KEY_A] || key_map[KB_KEY_D] || key_map[KB_KEY_I] || key_map[KB_KEY_K] ) ) { w.camera->state = Camera::STATIC; } break; case KB_RELEASE_S: if ( !( key_map[KB_KEY_W] || key_map[KB_KEY_A] || key_map[KB_KEY_D] || key_map[KB_KEY_I] || key_map[KB_KEY_K] ) ) { w.camera->state = Camera::STATIC; } break; case KB_RELEASE_A: if ( !( key_map[KB_KEY_S] || key_map[KB_KEY_W] || key_map[KB_KEY_D] || key_map[KB_KEY_I] || key_map[KB_KEY_K] ) ) { w.camera->state = Camera::STATIC; } break; case KB_RELEASE_D: if ( !( key_map[KB_KEY_S] || key_map[KB_KEY_A] || key_map[KB_KEY_W] || key_map[KB_KEY_I] || key_map[KB_KEY_K] ) ) { w.camera->state = Camera::STATIC; } break; case KB_RELEASE_I: if ( !( key_map[KB_KEY_S] || key_map[KB_KEY_A] || key_map[KB_KEY_D] || key_map[KB_KEY_W] || key_map[KB_KEY_K] ) ) { w.camera->state = Camera::STATIC; } break; case KB_RELEASE_K: if ( !( key_map[KB_KEY_S] || key_map[KB_KEY_A] || key_map[KB_KEY_D] || key_map[KB_KEY_I] || key_map[KB_KEY_W] ) ) { w.camera->state = Camera::STATIC; } break; case KB_PRESS_ESCAPE: w.camera = &w.ui_camera; if ( !(w.state == World::STATE_FREE_VIEW ) ){ w.camera = &w.ui_camera; WORLD_SET_STATE_FREE_VIEW; } else { WORLD_SET_STATE_DETACHED; } break; case KB_PRESS_C: if ( !(w.state == World::STATE_VIEW_CAMERA ) ){ w.camera = &w.view_camera; w.perspective = w.view_perspective; WORLD_SET_STATE_VIEW_CAMERA; } else { w.camera = &w.ui_camera; w.perspective = w.ui_perspective; WORLD_SET_STATE_FREE_VIEW; } break; case KB_PRESS_Q: case KB_REPEAT_Q: if ( w.state == World::STATE_SELECTED ){ w.selected_rotate( w.selected_data, 5.0f, v3{0.0f,1.0f,0.0f}, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; case KB_PRESS_E: case KB_REPEAT_E: if ( w.state == World::STATE_SELECTED ){ w.selected_rotate( w.selected_data, -5.0f, v3{0.0f,1.0f,0.0f}, w.model_matrices[w.selected_object.type][w.selected_object.index] ); } break; #endif default: break; } } w.camera->update( dt ); glfwSetCursorPosCallback( window, mouse_callback ); Event_Count = 0; glClearColor(0.0f,0,0,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // the deatched state hover if ( w.state == World::STATE_DETACHED || w.state == World::STATE_ON_HOLD|| w.state == World::STATE_VIEW_CAMERA ) { if ( w.state != World::STATE_VIEW_CAMERA ) glfwGetCursorPos( window, &cp[0], &cp[1] ); HitRecord record; v3 point = v3{ ( float )cp[0], (float)cp[1], 0.0f }; v3 wp = HMM_UnProject( point, w.perspective * w.camera->transform(), ScreenWidth, ScreenHeight ); Ray ray( w.camera->P, ( wp - w.camera->P ) ); if ( hit_world( w, ray, 0.001f, 100.0f, record ) ){ if ( record.obj.type == OBJECT_GRID ){ Grid *grid = (Grid *)record.obj.object; v3 p0 = grid_get_corner_point( *grid, record.u, record.v ); v3 p1 = p0 + grid->dir1 * grid->w; v3 p2 = p0 + grid->dir1 * grid->w + grid->dir2 * grid->w; v3 p3 = p0 + grid->dir2 * grid->w; ColorQuad quad = { p0, p1, p2, p3, v3{ 0.42f,0.65f,0.83f }, // color w.grid.rect.n }; array_push( w.temp_color_quads, quad ); } else if ( record.obj.type == OBJECT_CUBE_INSTANCE ){ array_push( w.boxes, w.cubes[record.obj.index].bounds ); } else if ( record.obj.type == OBJECT_SPHERE ){ array_push( w.boxes, w.spheres[ record.obj.index].box ); } else if ( record.obj.type == OBJECT_RECT ){ array_push( w.boxes, w.rects[ record.obj.index].box ); } else if ( record.obj.type == OBJECT_LIGHT_CUBE_INSTANCE ){ array_push( w.boxes, w.light_cubes[record.obj.index].bounds ); } else if ( record.obj.type == OBJECT_LIGHT_SPHERE ){ array_push( w.boxes, w.light_spheres[ record.obj.index].box ); } else if ( record.obj.type == OBJECT_LIGHT_RECT ){ array_push( w.boxes, w.light_rects[ record.obj.index].box ); } } } if ( w.is_selected ){ array_push( w.boxes, w.selected_aabb( w.selected_data, w.model_matrices[w.selected_object.type][w.selected_object.index] ) ); } draw_world(w); if ( w.show_imgui ){ ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); ImGui::NewFrame(); #define SLIDER_UPPER_LIMIT 10.0f // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear ImGui!). if ( show_demo_window ){ ImGui::ShowDemoWindow(&show_demo_window); } // 2. Show a simple window that we create ourselves. We use a Begin/End pair to created a named window. uint i = w.selected_object.index; if ( w.is_selected ){ float f = 0.0f; int counter = 0; // Create a window called "Hello, world!" and append into it. ImGui::Begin("Object Properties"); // Display some text (you can use a format strings too) ImGui::Text("Change some object properties!"); if ( w.selected_object.type == OBJECT_CUBE_INSTANCE ){ Cube *cube = &w.cubes[ i ]; const char* items[] = { "Front", "Back", "Right","Left", "Up","Down" }; ImGui::Combo("Cube Face", &w.cube_face_dropdown, items, IM_ARRAYSIZE(items)); ImGui::SliderFloat("Cube Length", &w.sel_cube_length, 0.05f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); const char *material_dropdown[] = { "Metallic", "Diffuse", "Glass" }; ImGui::Combo("Material", &w.cube_material_dropdown, material_dropdown, IM_ARRAYSIZE(material_dropdown)); if ( w.cube_material_dropdown == 2 ){ } else { const char *texture_select[] = { "Color","Checker","Marble" }; ImGui::Combo("Texture", &w.cube_texture_dropdown, texture_select, IM_ARRAYSIZE(texture_select)); w.cube_face_color = w.cube_materials[i].texture.face_colors[ w.cube_face_dropdown ]; ImGui::ColorEdit3("clear color", w.cube_face_color.Elements ); } } else if ( w.selected_object.type == OBJECT_SPHERE ){ ImGui::SliderFloat("Sphere Radius", &w.sel_sphere_radius, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); const char *material_dropdown[] = { "Metallic", "Diffuse", "Glass" }; ImGui::Combo("Material", &w.sphere_material_dropdown, material_dropdown, IM_ARRAYSIZE(material_dropdown)); if ( w.sphere_material_dropdown == 2 ){ } else { const char *texture_select[] = { "Color","Checker","Marble" }; ImGui::Combo("Texture", &w.sphere_texture_dropdown, texture_select, IM_ARRAYSIZE(texture_select)); w.sphere_face_color = w.sphere_materials[i].texture.color; ImGui::ColorEdit3("clear color", w.sphere_face_color.Elements ); } } else if ( w.selected_object.type == OBJECT_RECT ){ // TODO: Two sliders if ( ImGui::Button( "Flip Normal" ) ){ w.rect_flip_normal++; } ImGui::SliderFloat("Rectangle length 1", &w.sel_rect_l1, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); ImGui::SliderFloat("Rectangle length 3", &w.sel_rect_l2, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); const char *material_dropdown[] = { "Metallic", "Diffuse", "Glass" }; ImGui::Combo("Material", &w.rect_material_dropdown, material_dropdown, IM_ARRAYSIZE(material_dropdown)); if ( w.rect_material_dropdown == 2 ){ } else { const char *texture_select[] = { "Color","Checker","Marble" }; ImGui::Combo("Texture", &w.rect_texture_dropdown, texture_select, IM_ARRAYSIZE(texture_select)); w.rect_face_color = w.rect_materials[i].texture.color; ImGui::ColorEdit3("clear color", w.rect_face_color.Elements ); } } else if ( w.selected_object.type != OBJECT_GRID ) { v3 *color; switch ( w.selected_object.type ){ case OBJECT_LIGHT_RECT: { color = &w.light_rect_face_color; w.light_rect_face_color= w.light_rect_color[i]; ImGui::SliderFloat("Rectangle length 1", &w.sel_rect_l1, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); ImGui::SliderFloat("Rectangle length 3", &w.sel_rect_l2, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); } break; case OBJECT_LIGHT_SPHERE: { color = &w.light_sphere_face_color; w.light_sphere_face_color = w.light_sphere_color[i]; ImGui::SliderFloat("Sphere Radius", &w.sel_sphere_radius, 0.01f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); } break; case OBJECT_LIGHT_CUBE_INSTANCE: { color = &w.light_cube_face_color; w.light_cube_face_color= w.light_cube_color[i]; ImGui::SliderFloat("Cube Length", &w.sel_cube_length, 0.05f, SLIDER_UPPER_LIMIT, "ratio = %.3f"); } break; default: break; } ImGui::ColorEdit3("Change Color", color->Elements ); } // Buttons return true when clicked (most widgets return true // when edited/activated) if (ImGui::Button("Button")) counter++; ImGui::SameLine(); ImGui::Text("counter = %d", counter); ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate); ImGui::End(); switch ( w.selected_object.type ){ case OBJECT_CUBE_INSTANCE: { Cube *cube =w.cubes + i; if ( w.cube_material_dropdown == 2 ){ w.cube_materials[i].type = Material::GLASS; } else { w.cube_materials[i].type = (Material::MaterialType)w.cube_material_dropdown; switch ( w.cube_texture_dropdown ){ case 0: w.cube_materials[i].texture.type = Texture::COLOR; break; case 1: w.cube_materials[i].texture.type = Texture::CHECKER; break; case 2: w.cube_materials[i].texture.type = Texture::MARBLE; break; default: break; } w.cube_materials[i].texture.face_colors[ w.cube_face_dropdown ] = w.cube_face_color; } f32 l = w.sel_cube_length; cube_scale( cube, v3{l,l,l}, w.model_matrices[OBJECT_CUBE_INSTANCE][i] ); world_add_cube_vertex_data(w,i); } break; case OBJECT_SPHERE: { if ( w.sphere_material_dropdown == 2 ){ w.sphere_materials[i].type = Material::GLASS; } else { w.sphere_materials[i].type = (Material::MaterialType)w.sphere_material_dropdown; w.sphere_materials[i].texture.type = (Texture::TextureType)w.sphere_texture_dropdown; w.sphere_materials[i].texture.color = w.sphere_face_color; } world_add_sphere_vertex_data(w,i); f32 l = w.sel_sphere_radius; sphere_scale(w.spheres+i, v3{l,l,l}, w.model_matrices[OBJECT_SPHERE][i] ); } break; case OBJECT_RECT: { if ( w.rect_flip_normal ){ w.rect_flip_normal--; w.rects[i].n *= -1; } if ( w.rect_material_dropdown == 2 ){ w.rect_materials[i].type = Material::GLASS; } else { w.rect_materials[i].type = (Material::MaterialType)w.rect_material_dropdown; w.rect_materials[i].texture.type = (Texture::TextureType)w.rect_texture_dropdown; w.rect_materials[i].texture.color = w.rect_face_color; } rectangle_scale( w.selected_data,w.sel_rect_l1, w.sel_rect_l2 ); break; } case OBJECT_LIGHT_CUBE_INSTANCE: { Cube *cube =w.light_cubes + i; w.light_cube_color[i] = w.light_cube_face_color; f32 l = w.sel_cube_length; world_add_light_cube_vertex_data(w,i); cube_scale( cube, v3{l,l,l}, w.model_matrices[OBJECT_LIGHT_CUBE_INSTANCE][i] ); } break; case OBJECT_LIGHT_SPHERE: { w.light_sphere_color[i] = w.light_sphere_face_color; world_add_light_sphere_vertex_data(w,i); f32 l = w.sel_sphere_radius; sphere_scale(w.light_spheres+i, v3{l,l,l}, w.model_matrices[OBJECT_LIGHT_SPHERE][i] ); } break; case OBJECT_LIGHT_RECT: w.light_rect_color[i] = w.light_rect_face_color; rectangle_scale( w.selected_data,w.sel_rect_l1, w.sel_rect_l2 ); break; default: break; } } // 3. Show another simple window. if (w.state == World::STATE_DETACHED){ ImGui::Begin("Place Objects", &show_another_window); const char* world_objects[] = { "Cube", "Sphere", "Plane","Light Cube", "Light Sphere", "Light Plane" }; ImGui::Combo("combo", &w.hold_object_id, world_objects, IM_ARRAYSIZE(world_objects)); dump_scene_data = ImGui::Button("Dump Scene Data"); ImGui::End(); } else if ( w.state == World::STATE_VIEW_CAMERA ){ ImGui::Begin( "Camera Properties" ); ImGui::End(); } // Rendering ImGui::Render(); ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); // Dear Imgui related events } glfwSwapBuffers(window); glfwPollEvents(); array_clear( w.color_vertex_data ); array_clear( w.color_vertex_modes ); array_clear( w.color_vertex_indices ); array_clear( w.index_stack ); array_clear( w.temp_color_quads ); array_clear( w.boxes ); array_clear( w.light_pos ); array_clear( w.light_colors ); if ( dump_scene_data ){ dump_scene_data = false; char buff[256]; snprintf( buff, 256, "./bin/dump_file%d.dat", dump_count ); world_dump_scene_to_file( w,buff ); } } glfwTerminate(); }
30.552619
150
0.594915
amritphuyal
d2640a83c636f758bbe9ccc9ed886d422597621f
1,696
cpp
C++
lib/AST/Pattern.cpp
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
1
2022-03-30T22:01:44.000Z
2022-03-30T22:01:44.000Z
lib/AST/Pattern.cpp
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
null
null
null
lib/AST/Pattern.cpp
mattapet/dusk-lang
928b027429a3fd38cece78a89a9619406dcdd9f0
[ "MIT" ]
null
null
null
//===--- Stmt.cpp ---------------------------------------------------------===// // // dusk-lang // This source file is part of a dusk-lang project, which is a semestral // assignement for BI-PJP course at Czech Technical University in Prague. // The software is provided "AS IS", WITHOUT WARRANTY OF ANY KIND. // //===----------------------------------------------------------------------===// #include "dusk/AST/Pattern.h" #include "dusk/AST/Decl.h" #include "dusk/AST/Expr.h" #include "dusk/AST/Stmt.h" using namespace dusk; // MARK: - Pattern Pattern::Pattern(PatternKind K) : Kind(K), Ty(nullptr) {} #define PATTERN(CLASS, PARENT) \ CLASS##Pattern *Pattern::get##CLASS##Pattern() { \ assert(Kind == PatternKind::CLASS && "Invalid conversion"); \ return static_cast<CLASS##Pattern *>(this); \ } #include "dusk/AST/PatternNodes.def" void *Pattern::operator new(size_t Bytes, ASTContext &Context) { return Context.Allocate(Bytes); } // MARK: - Expression pattern ExprPattern::ExprPattern(SmallVector<Expr *, 128> &&V, SMLoc L, SMLoc R) : Pattern(PatternKind::Expr), Values(V), LPar(L), RPar(R) {} SMRange ExprPattern::getSourceRange() const { return {LPar, RPar}; } size_t ExprPattern::count() const { return Values.size(); } // MARK: - Variable pattern VarPattern::VarPattern(SmallVector<Decl *, 128> &&V, SMLoc L, SMLoc R) : Pattern(PatternKind::Var), Vars(V), LPar(L), RPar(R) {} SMRange VarPattern::getSourceRange() const { return {LPar, RPar}; } size_t VarPattern::count() const { return Vars.size(); }
36.085106
80
0.570755
mattapet
d2691261365a587d79634ba5899d220f2bce2c39
2,137
hpp
C++
kits/daisy/src/input/input_manager_mobile_io.hpp
HebiRobotics/hebi-cpp-examples
db01c9b957b3c97885d452d8b72f9919ba6c48c4
[ "Apache-2.0" ]
7
2018-03-31T06:52:08.000Z
2022-02-24T21:27:09.000Z
kits/daisy/src/input/input_manager_mobile_io.hpp
HebiRobotics/hebi-cpp-examples
db01c9b957b3c97885d452d8b72f9919ba6c48c4
[ "Apache-2.0" ]
34
2018-06-03T17:28:08.000Z
2021-05-29T01:15:25.000Z
kits/daisy/src/input/input_manager_mobile_io.hpp
HebiRobotics/hebi-cpp-examples
db01c9b957b3c97885d452d8b72f9919ba6c48c4
[ "Apache-2.0" ]
9
2018-02-08T22:50:58.000Z
2021-03-30T08:07:35.000Z
#pragma once #include "input_manager.hpp" #include <Eigen/Dense> #include "group.hpp" #include <memory> #include <atomic> namespace hebi { namespace input { // If the I/O board/app is not found, command vectors return 0, and button // um toggle/quit states are unchanged by 'update'. Class is not // re-entrant. class InputManagerMobileIO : public InputManager { public: InputManagerMobileIO(); virtual ~InputManagerMobileIO() noexcept = default; // Connect to an I/O board/app and start getting feedback. Return "true" if // found. Clears any existing connection bool reset(); // A debug command that can be used to print the current state of the joystick // variables that are stored by the class. void printState() const override; // Get the current translation velocity command Eigen::Vector3f getTranslationVelocityCmd() const override; // Get the current rotation velocity command Eigen::Vector3f getRotationVelocityCmd() const override; // Returns true if the quit button has ever been pushed bool getQuitButtonPushed() const override; // Gets the number of times the mode button has been toggled since the last // request. Resets this count after retrieving. size_t getMode() override; // Is the joystick connected? // Return "true" if we are connected to an I/O board/app; false otherwise. bool isConnected() const override { return group_ ? true : false; } private: float getVerticalVelocity() const; // The Mobile IO app that serves as a joystick std::shared_ptr<hebi::Group> group_; // Scale the joystick scale to motion of the robot in SI units (m/s, rad/s, // etc). static constexpr float xyz_scale_{0.175}; static constexpr float rot_scale_{0.4}; float left_horz_raw_{0}; // Rotation float left_vert_raw_{0}; // Chassis tilt float slider_1_raw_{0}; // Height float right_horz_raw_{0}; // Translation (l/r) float right_vert_raw_{0}; // Translation (f/b) bool prev_mode_button_state_{false}; // Mode std::atomic<size_t> mode_{0}; // bool has_quit_been_pushed_ = false; // Quit }; } // namespace input } // namespace hebi
27.753247
80
0.722976
HebiRobotics
d26a26e5401be4c03c63188513625929e32a9b38
1,179
cpp
C++
problem 1-50/45. Jump Game II.cpp
just-essential/LeetCode-Cpp
3ec49434d257defd28bfe4784ecd0ff2f9077a31
[ "MIT" ]
null
null
null
problem 1-50/45. Jump Game II.cpp
just-essential/LeetCode-Cpp
3ec49434d257defd28bfe4784ecd0ff2f9077a31
[ "MIT" ]
null
null
null
problem 1-50/45. Jump Game II.cpp
just-essential/LeetCode-Cpp
3ec49434d257defd28bfe4784ecd0ff2f9077a31
[ "MIT" ]
null
null
null
/* Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. Example: Input: [2,3,1,1,4] Output: 2 Explanation: The minimum number of jumps to reach the last index is 2. Jump 1 step from index 0 to 1, then 3 steps to the last index. Note: You can assume that you can always reach the last index. */ class Solution { public: int jump(vector<int> &nums) { int rear = nums.size() - 1, i, j, count, maxStep, pos; for (i = count = 0; i < rear; i = pos) { count++; if (i + nums[i] >= rear) { break; } maxStep = nums[i + 1] + 1; pos = i + 1; for (j = 2; j <= nums[i]; ++j) { if (nums[i + j] + j > maxStep) { maxStep = nums[i + j] + j; pos = i + j; } } } return count; } void test() { vector<int> nums{2, 3, 1, 1, 4}; assert(jump(nums) == 2); } };
27.418605
102
0.516539
just-essential
d26fc404c5320d9b99581cede8b739187ab0c1a2
13,233
cpp
C++
project/TinyCADxxx/XMLReader.cpp
lakeweb/ECAD
9089253afd39adecd88f4a33056f91b646207e00
[ "MIT" ]
null
null
null
project/TinyCADxxx/XMLReader.cpp
lakeweb/ECAD
9089253afd39adecd88f4a33056f91b646207e00
[ "MIT" ]
null
null
null
project/TinyCADxxx/XMLReader.cpp
lakeweb/ECAD
9089253afd39adecd88f4a33056f91b646207e00
[ "MIT" ]
2
2019-06-21T16:17:49.000Z
2020-07-04T13:41:01.000Z
/* TinyCAD program for schematic capture Copyright 1994-2004 Matt Pyne. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // XMLReader.cpp: implementation of the CXMLReader class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <string> //#include "tinycad.h" #include "XMLReader.h" #include "XMLException.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CXMLReader::CXMLReader(CStream* pInput) { //TRACE("CXMLReader::CXMLReader(): Constructor.\n"); m_pInput = pInput; m_uu_data = NULL; m_uu_size = 0; m_uu_state = 0; m_current_self_closing = false; m_charset_conv = CHARSET_INVALID; m_decoded_buffer = NULL; m_decoded_buf_size = 0; m_output_pos = 0; m_decoded_chars = 0; m_line_counter = 0; #ifdef UNICODE SetCharset( _T("UTF-8") ); #endif intoTag(); //TRACE("CXMLReader::CXMLReader(): Leaving CXMLReader() constructor.\n"); } CXMLReader::~CXMLReader() { //TRACE("CXMLReader::~CXMLReader(): Entering Destructor.\n"); while (m_tags.size() > 0) { delete m_tags.front(); m_tags.pop_front(); } if (m_charset_conv != CHARSET_INVALID) { iconv_close(m_charset_conv); } delete m_decoded_buffer; //TRACE("CXMLReader::~CXMLReader(): Leaving Destructor\n"); } // Set up the character set conversions void CXMLReader::SetCharset(const TCHAR* fromcode) { //TRACE("CXMLReader::SetCharset(): Entering - doing iconv stuff.\n"); if (m_charset_conv != CHARSET_INVALID) { iconv_close(m_charset_conv); } #ifdef UNICODE char fc[ 256 ]; int l = WideCharToMultiByte( CP_ACP, 0, fromcode, _tcslen( fromcode), fc, static_cast<int> (sizeof( fc )), NULL, NULL ); fc[ l ] = 0; m_charset_conv = iconv_open( "UCS-2-INTERNAL", fc ); #else m_charset_conv = iconv_open("CHAR", fromcode); #endif //TRACE("CXMLReader::SetCharset(): Leaving.\n"); } // Get the next character from the input stream bool CXMLReader::getNextChar(xml_char_t &c) { if (m_charset_conv != CHARSET_INVALID) { // Are there any bytes in the decoded buffer? if (m_output_pos >= m_decoded_chars) { // No bytes left, so must refetch m_output_pos = 0; // We read in a line at a time and decode it... std::string input; char in_c; do { if (m_pInput->Read(&in_c, 1) != 1) { // Eof break; } input += in_c; if (in_c == '\n') { //track the line number of the input XML file so that it can be used in error messages. m_line_counter++; } } while (in_c != '\r' && in_c != '\n'); if (m_decoded_buf_size < input.size() * 4) { delete m_decoded_buffer; m_decoded_buf_size = input.size() * 4; m_decoded_buffer = new TCHAR[m_decoded_buf_size]; } // Now perform the conversion size_t outbuf_size = m_decoded_buf_size * sizeof(TCHAR); size_t inbuf_size = input.size(); TCHAR *out = m_decoded_buffer; const char *in = input.c_str(); iconv(m_charset_conv, &in, &inbuf_size, (char **) &out, &outbuf_size); m_decoded_chars = (TCHAR*) out - m_decoded_buffer; } // Are there any bytes in the decoded buffer? if (m_output_pos >= m_decoded_chars) { // No bytes left, must be eof return true; } else { c = m_decoded_buffer[m_output_pos]; ++m_output_pos; return false; } } else { // No charset conversion available... return m_pInput->Read(&c, 1) != 1; } } xml_parse_tag* CXMLReader::get_current_tag() { return m_tags.front(); } // Get the attribute information associated with the current // tag... bool CXMLReader::internal_getAttribute(const xml_char_t *name, CString &data) { xml_parse_tag::attrCollection::iterator it = get_current_tag()->m_attributes.find(name); if (it != get_current_tag()->m_attributes.end()) { data = (*it).second; return true; } return false; } void CXMLReader::child_data(const xml_char_t *in) { //TRACE("CXMLReader::child_data(): uudecode stuff\n"); if (m_uu_data != NULL && m_uu_size > 0) { int l = (int) _tcslen(in); while (l > 0) { uudecode(in[0]); in++; l--; } } else { m_child_data += in; } } // Handle the current tag as a system tag void CXMLReader::handleSystemTag() { //TRACE("CXMLReader::handleSystemTag()\n"); xml_parse_tag *tag = get_current_tag(); // Is this the xml header tag? if (tag->m_tag_name == "?xml") { // Ok, get the encoding attribute if it is present... CString data; if (internal_getAttribute(_T("encoding"), data)) { // Use this encoding SetCharset(data); } } } // Scan and find the next tag bool CXMLReader::getNextTag(CString &name) { //TRACE("CXMLReader::getNextTag()\n"); if (m_current_self_closing) { return false; } // Is the sub-buffer for the child data const int build_len = 255; xml_char_t child_data_build[build_len + 1]; int child_data_index = 0; // Now scan to find the next tag... xml_char_t c; for (;;) { do { if (getNextChar(c)) { name = ""; return false; } if (c != '<') { if (child_data_index == build_len || c == '&') { child_data_build[child_data_index] = 0; child_data(child_data_build); child_data_index = 0; } if (c == '&') { child_data(xml_parse_tag::read_entity(this)); } else { child_data_build[child_data_index] = c; child_data_index++; } } } while (c != '<'); // Now we have found the opening for the next // tag, we must scan it... get_current_tag()->parse(this); // Was this a comment? if (get_current_tag()->m_comment) { continue; } // Was this a system tag? if (get_current_tag()->isSystemTag()) { // Handle it... handleSystemTag(); continue; } // Was this a closing tag? if (get_current_tag()->m_closing_tag) { // Yep, so this is the end of this run.... name = get_current_tag()->m_tag_name; child_data_build[child_data_index] = 0; child_data(child_data_build); return false; } else { // Ok, we have a new opening tag... name = get_current_tag()->m_tag_name; child_data_build[child_data_index] = 0; child_data(child_data_build); return true; } } } // Scan until the end of the current tag... // bool CXMLReader::closeTag() { //TRACE("CXMLReader::closeTag()\n"); if (m_current_self_closing) { return true; } // Is this tag self-closing? if (get_current_tag()->m_self_closing_tag || get_current_tag()->m_closing_tag) { return true; } CString close_name = get_current_tag()->m_tag_name; // Nope, we must scan until we find the closing for // this tag ( recursively going into tags and out // again until we find our match...) for (;;) { CString name; // Is this the closing tag for the current tag? if (!getNextTag(name)) { if (close_name == name) { return true; } else { CString diagnosticMessage; diagnosticMessage.Format(_T("Error: XMLReader line #378: ERR_XML_WRONG_CLOSE: Expecting tag [%s], but found tag [%s]. Current line number = %d.\n"), (LPCTSTR)name, (LPCTSTR)close_name, m_line_counter); TRACE(diagnosticMessage); throw new CXMLException(ERR_XML_WRONG_CLOSE, m_line_counter, TRUE); } } else { // Must be an opening tag, so we need to close this // tag now... intoTag(); outofTag(); } } //return true; } // Find the next peer tag of this tag // returns false if there are no more tags at this // level... bool CXMLReader::nextTag(CString &name) { //TRACE("CXMLReader::nextTag()\n"); // First, we must find the closing of the // previous tag if (!closeTag()) { return false; } m_child_data = ""; return getNextTag(name); } // Move inside the current tag. nextTag will then return // tags that are inside the current tag.... void CXMLReader::intoTag() { //TRACE("CXMLReader::intoTag(): Entering.\n"); // Is this tag self-closing? if (m_tags.size() > 0 && get_current_tag()->m_self_closing_tag) { m_current_self_closing = true; } else { // Create a new parser to go into the tag system... xml_parse_tag *tag = new xml_parse_tag(); m_tags.push_front(tag); } //TRACE("CXMLReader::intoTag(): Leaving.\n"); } // Move up one level. nextTag will then return tags // that are one above the current level... // void CXMLReader::outofTag() { //TRACE("CXMLReader::outofTag()\n"); if (m_current_self_closing) { m_current_self_closing = false; return; } // Have we already scanned to the closing tag? if (get_current_tag()->m_closing_tag && m_tags.size() > 1) { CString check_name = get_current_tag()->m_tag_name; // Copy this tag up one level... xml_parse_tag *ptag = m_tags.front(); m_tags.pop_front(); delete m_tags.front(); m_tags.pop_front(); m_tags.push_front(ptag); if (get_current_tag()->m_tag_name != check_name) { CString diagnosticMessage; diagnosticMessage.Format(_T("Error: XMLReader line #475: ERR_XML_WRONG_CLOSE: Expecting tag [%s], but found tag [%s]. Current line number = %d.\n"), (LPCTSTR)check_name, (LPCTSTR)get_current_tag()->m_tag_name, m_line_counter); TRACE(diagnosticMessage); throw new CXMLException(ERR_XML_WRONG_CLOSE, m_line_counter, TRUE); } } else { delete m_tags.front(); m_tags.pop_front(); closeTag(); } } // Get the next child data associated with the current tag // CString CXMLReader::internal_getChildData() { //TRACE("CXMLReader::internal_getChildData()\n"); m_child_data = ""; closeTag(); return m_child_data; } void CXMLReader::getChildDataUUdecode(BYTE* &data, UINT &size) { //TRACE("CXMLReader::getChildDataUUdecode()\n"); // Get the size of this data CString name; getAttribute(_T("size"), size); data = new BYTE[size]; m_uu_size = size; m_uu_data = data; closeTag(); m_uu_data = NULL; m_uu_size = 0; m_uu_state = 0; } // single character decode #define DEC(c) (((c) - ' ') & 077) // UUdecode void CXMLReader::uudecode(xml_char_t in) { //TRACE("CXMLReader::uudecode()\n"); switch (m_uu_state) { case 0: // We are awaiting the line count if (xml_parse_tag::is_whitespace(in)) { break; } // Not whitespace, so must be the line count... m_uu_line_size = DEC(in); m_uu_state++; break; case 1: // We are awating the 1st char in the four char set m_uu_bytes[0] = static_cast<char> (in); m_uu_state++; break; case 2: // We are awating the 2nd char in the four char set m_uu_bytes[1] = static_cast<char> (in); m_uu_state++; break; case 3: // We are awating the 3rd char in the four char set m_uu_bytes[2] = static_cast<char> (in); m_uu_state++; break; case 4: // We are awating the 4th char in the four char set m_uu_bytes[3] = static_cast<char> (in); int c[3]; c[0] = DEC(m_uu_bytes[0]) << 2 | DEC(m_uu_bytes[1]) >> 4; c[1] = DEC(m_uu_bytes[1]) << 4 | DEC(m_uu_bytes[2]) >> 2; c[2] = DEC(m_uu_bytes[2]) << 6 | DEC(m_uu_bytes[3]); for (int i = 0; i < 3; i++) { if (m_uu_line_size > 0 && m_uu_size > 0) { *m_uu_data = (BYTE) c[i]; m_uu_line_size--; m_uu_size--; m_uu_data++; } } if (m_uu_line_size == 0) { m_uu_state = 0; } else { m_uu_state = 1; } break; } } // Type conversions.... void CXMLReader::unmakeString(CString str, CString &data) { data = str; } void CXMLReader::unmakeString(CString str, int &data) { data = _tstoi(str); } void CXMLReader::unmakeString(CString str, UINT &data) { _stscanf_s(str, _T("%u"), &data); } void CXMLReader::unmakeString(CString str, COLORREF &data) { xml_char_t *dummy; data = _tcstol(str, &dummy, 16); } void CXMLReader::unmakeString(CString str, double &data) { data = _tstof(str); } void CXMLReader::unmakeString(CString str, CDPoint &data) { _stscanf_s(str, _T("%lg,%lg"), &data.x, &data.y); data.x = data.unmakeXMLUnits(data.x); data.y = data.unmakeXMLUnits(data.y); } void CXMLReader::unmakeString(CString str, BYTE &data) { int d; unmakeString(str, d); data = (BYTE) d; } void CXMLReader::unmakeString(CString str, unsigned short &data) { int d; unmakeString(str, d); data = (unsigned short) d; } void CXMLReader::unmakeString(CString str, short &data) { int d; unmakeString(str, d); data = (short) d; } void CXMLReader::unmakeString(CString str, long &data) { int d; unmakeString(str, d); data = d; } void CXMLReader::unmakeString(CString str, bool &data) { int d; unmakeString(str, d); data = d != 0; } int CXMLReader::get_line_counter() { return m_line_counter; }
20.580093
233
0.650722
lakeweb
d26fd18e9b47cbcea57806cecceac714dc2d1da4
611
cpp
C++
programming/dataStructure_Algorithm/exercises/bigProblems/pairToUnorderedSet.cpp
ljyang100/dataScience
ad2b243673c570c18d83ab1a0cd1bb4694c17eac
[ "MIT" ]
2
2020-12-10T02:05:29.000Z
2021-05-30T15:23:56.000Z
programming/dataStructure_Algorithm/exercises/bigProblems/pairToUnorderedSet.cpp
ljyang100/dataScience
ad2b243673c570c18d83ab1a0cd1bb4694c17eac
[ "MIT" ]
null
null
null
programming/dataStructure_Algorithm/exercises/bigProblems/pairToUnorderedSet.cpp
ljyang100/dataScience
ad2b243673c570c18d83ab1a0cd1bb4694c17eac
[ "MIT" ]
1
2020-04-21T11:18:18.000Z
2020-04-21T11:18:18.000Z
#include <iostream> #include <algorithm> #include <unordered_map> #include <unordered_set> #include <functional> int main() { //**** Note **** //**** Important. Although in standard we cannot insert pair to unordered_set, we can do so for std::multiset. See example in find K pairs of smallest sum. std::unordered_set<std::pair<int, int>> hello; //There is no standard way to insert pair to unordered_set. //Check "insert pair into unordered_set" for the ways of providing specialize the template to do so. //**** Seems not necessary, because this is what exactly does by un_ordered_map. return 0; }
33.944444
157
0.729951
ljyang100
d2708f9c33f6d973a94fea6a9d89f61d8dd5ee9d
6,256
cpp
C++
BLAXED/AnimatedClanTag.cpp
prismatical/BX-CSGO
24b2cadefdc40cb8d3fca0aab08ec54241518958
[ "MIT" ]
19
2018-03-04T08:04:29.000Z
2022-01-27T11:28:36.000Z
BLAXED/AnimatedClanTag.cpp
prismatical/BX-CSGO
24b2cadefdc40cb8d3fca0aab08ec54241518958
[ "MIT" ]
1
2019-12-27T15:43:41.000Z
2020-05-18T19:16:42.000Z
BLAXED/AnimatedClanTag.cpp
prismatical/BX-CSGO
24b2cadefdc40cb8d3fca0aab08ec54241518958
[ "MIT" ]
9
2019-03-30T22:39:25.000Z
2021-08-13T19:27:27.000Z
#include "SDK.h" #include "Global.h" #include "Configs.h" #include "AnimatedClanTag.h" AnimatedClanTag *animatedClanTag = new AnimatedClanTag(); void AnimatedClanTag::Tick() { char tag[64]; int i = 0; float serverTime = (float)I::pEngineClient->GetServerTick() * (I::pGlobals->interval_per_tick * 2); std::vector<std::string> anim; switch (cfg.Misc.clanTagAnimation) { case 1: i = (int)(serverTime) % 2; if (i == 0 || i == 1) { for (i = 0; i < 4; i++) tag[i] = Math::Random('0', '1'); tag[i] = '\0'; SetClanTag(tag); } break; case 2: anim.push_back(xorstr("getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr(" getze.us ")); anim.push_back(xorstr("getze.us ")); break; case 3: anim.push_back(xorstr("B")); anim.push_back(xorstr("BL")); anim.push_back(xorstr("BLA")); anim.push_back(xorstr("BLAX")); anim.push_back(xorstr("BLAXE")); anim.push_back(xorstr("BLAXED")); anim.push_back(xorstr("BLAXED.")); anim.push_back(xorstr("BLAXED.C")); anim.push_back(xorstr("BLAXED.CO")); anim.push_back(xorstr("BLAXED.COM")); anim.push_back(xorstr("BLAXED.CO")); anim.push_back(xorstr("BLAXED.C")); anim.push_back(xorstr("BLAXED.")); anim.push_back(xorstr("BLAXED")); anim.push_back(xorstr("BLAXE")); anim.push_back(xorstr("BLAX")); anim.push_back(xorstr("BLA")); anim.push_back(xorstr("BL")); anim.push_back(xorstr("B")); break; case 4: anim.push_back(xorstr(" ")); anim.push_back(xorstr("c ")); anim.push_back(xorstr("cc ")); anim.push_back(xorstr(".cc ")); anim.push_back(xorstr("t.cc ")); anim.push_back(xorstr("et.cc ")); anim.push_back(xorstr("eet.cc ")); anim.push_back(xorstr("keet.cc ")); anim.push_back(xorstr("skeet.cc ")); anim.push_back(xorstr(" skeet.cc ")); anim.push_back(xorstr(" skeet.cc ")); anim.push_back(xorstr(" skeet.cc ")); anim.push_back(xorstr(" skeet.cc ")); anim.push_back(xorstr(" skeet.cc ")); anim.push_back(xorstr(" skeet.cc")); anim.push_back(xorstr(" skeet.c")); anim.push_back(xorstr(" skeet.")); anim.push_back(xorstr(" skeet")); anim.push_back(xorstr(" skee")); anim.push_back(xorstr(" ske")); anim.push_back(xorstr(" sk")); anim.push_back(xorstr(" s")); break; case 5: anim.push_back(xorstr("[VALVE]")); break; case 6: anim.push_back(xorstr("[testing]")); break; case 7: anim.push_back(xorstr("- BLAXED +")); anim.push_back(xorstr("+ BLAXED -")); break; case 8: /*anim.push_back(xorstr( "/ GB HvH /" )); anim.push_back(xorstr( "- GB HvH -" )); anim.push_back(xorstr("\\GB HvH \\")); anim.push_back(xorstr( "| GB HvH |" )); anim.push_back(xorstr( "- GB HvH -" )); anim.push_back(xorstr( "/ GB HvH /" )); anim.push_back(xorstr( "- GB HvH-" )); anim.push_back(xorstr("\\ GB HvH \\")); anim.push_back(xorstr( "| GB HvH |" ));*/ /* anim.push_back(xorstr( "/ GB HvH /" )); anim.push_back(xorstr( "- GB HvH -" )); anim.push_back(xorstr("\\ GB HvH \\")); anim.push_back(xorstr( "| GB HvH |" )); anim.push_back(xorstr( "- GB HvH -" )); anim.push_back(xorstr( "/ GB HvH /" )); anim.push_back(xorstr( "- GB HvH -" )); anim.push_back(xorstr("\\ GB HvH \\")); anim.push_back(xorstr( "| GB HvH |" ));*/ anim.push_back(xorstr("RO HVH +")); anim.push_back(xorstr("RO HVH -")); break; case 9: anim.push_back(xorstr("gamesense ")); anim.push_back(xorstr(" gamesense ")); anim.push_back(xorstr(" gamesense ")); anim.push_back(xorstr(" gamesense ")); anim.push_back(xorstr(" gamesense")); anim.push_back(xorstr(" gamesens")); anim.push_back(xorstr(" gamesen")); anim.push_back(xorstr(" gamese")); anim.push_back(xorstr(" games")); anim.push_back(xorstr(" game")); anim.push_back(xorstr(" gam")); anim.push_back(xorstr(" ga")); anim.push_back(xorstr(" g")); anim.push_back(xorstr(" ")); anim.push_back(xorstr("e ")); anim.push_back(xorstr("se ")); anim.push_back(xorstr("nse ")); anim.push_back(xorstr("ense ")); anim.push_back(xorstr("sense ")); anim.push_back(xorstr("esense ")); anim.push_back(xorstr("mesense ")); anim.push_back(xorstr("amesense ")); anim.push_back(xorstr("gamesense ")); break; } static bool reset = 0; if (cfg.Misc.clanTagAnimation != 0) { if (cfg.Misc.clanTagAnimation != 1) { i = (int)(serverTime) % (int)anim.size(); SetClanTag(anim[i].c_str()); reset = true; } } else { if (reset) { SetClanTag(""); reset = false; } } } /*int i = (int)(serverTime) % 21; / * | / - | / - * / switch (i) { case 0:SetClanDGDruedTagName(" \\ "); break; case 1:SetClanDGDruedTagName(" | "); break; case 2: SetClanDGDruedTagName(" / "); break; case 3: SetClanDGDruedTagName(" - "); break; case 5: SetClanDGDruedTagName(" Z "); break; case 6: SetClanDGDruedTagName(" Z\\ "); break; case 7: SetClanDGDruedTagName(" Z| "); break; case 8: SetClanDGDruedTagName(" Z/ "); break; case 9: SetClanDGDruedTagName(" Z- "); break; case 10: SetClanDGDruedTagName(" Ze "); break; case 11: SetClanDGDruedTagName(" Ze\\ "); break; case 12:SetClanDGDruedTagName(" Ze| "); break; case 13:SetClanDGDruedTagName(" Ze/ "); break; case 14:SetClanDGDruedTagName(" Ze- "); break; case 15:SetClanDGDruedTagName(" Zeu "); break; case 16:SetClanDGDruedTagName(" Zeu\\ "); break; case 17:SetClanDGDruedTagName(" Zeu| "); break; case 18:SetClanDGDruedTagName(" Zeu/ "); break; case 19:SetClanDGDruedTagName(" Zeu- "); break; case 20:SetClanDGDruedTagName(" Zeus "); break; } } } */
28.56621
100
0.594789
prismatical
d27d87335727fd36e542dbf7f30cf40b8906ad9f
166
cpp
C++
Tests/TestProjects/VS2010/C++/PreprocessorTest/App/main.cpp
veganaize/make-it-so
e1f8a0c6c372891dfda3a807e80f3797efdc4a99
[ "MIT" ]
null
null
null
Tests/TestProjects/VS2010/C++/PreprocessorTest/App/main.cpp
veganaize/make-it-so
e1f8a0c6c372891dfda3a807e80f3797efdc4a99
[ "MIT" ]
null
null
null
Tests/TestProjects/VS2010/C++/PreprocessorTest/App/main.cpp
veganaize/make-it-so
e1f8a0c6c372891dfda3a807e80f3797efdc4a99
[ "MIT" ]
null
null
null
#include <stdio.h> int main(int argc, char** argv) { #ifdef HELLO printf("Hello, "); #endif #ifdef WORLD printf("World!"); #endif return 0; }
11.857143
32
0.566265
veganaize
d27da382912347321c74faa00cd6f18fe88202cb
1,535
cpp
C++
source/Window/Window-NOTHREAD.cpp
hadryansalles/ray-tracing-from-the-ground-up
4ca02fca2cdd458767b4ab3df15b6cd20cb1f413
[ "MIT" ]
5
2021-09-24T12:22:08.000Z
2022-03-23T06:54:02.000Z
source/Window/Window-NOTHREAD.cpp
hadryans/ray-tracing-from-the-ground-up
4ca02fca2cdd458767b4ab3df15b6cd20cb1f413
[ "MIT" ]
null
null
null
source/Window/Window-NOTHREAD.cpp
hadryans/ray-tracing-from-the-ground-up
4ca02fca2cdd458767b4ab3df15b6cd20cb1f413
[ "MIT" ]
5
2021-08-14T22:26:11.000Z
2022-03-04T09:13:39.000Z
#include "Window-NOTHREAD.hpp" Window_NOTHREAD::Window_NOTHREAD(int width, int height): Window(width, height) { } Window_NOTHREAD::~Window_NOTHREAD(){ pixels.clear(); } void Window_NOTHREAD::init(){ window = SDL_CreateWindow("RTX", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h,SDL_WINDOW_SHOWN); renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, w, h); running = true; clock_gettime(CLOCK_MONOTONIC, &start); } void Window_NOTHREAD::update(){ clock_gettime(CLOCK_MONOTONIC, &finish); elapsed = (finish.tv_sec - start.tv_sec); elapsed += (finish.tv_nsec - start.tv_nsec) / 1000000000.0; if(running && elapsed > 1.0f/60.0f){ clock_gettime(CLOCK_MONOTONIC, &start); while( SDL_PollEvent( &event ) ) { if( ( SDL_QUIT == event.type ) || ( SDL_KEYDOWN == event.type && SDL_SCANCODE_ESCAPE == event.key.keysym.scancode ) ) { SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); SDL_Quit(); running = false; return; } } SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); SDL_RenderClear(renderer); SDL_UpdateTexture(texture, NULL, &pixels[0], w*4); SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); } }
29.519231
99
0.628664
hadryansalles
d28adf99ddc3e918658c5df1e127a050c3fff611
5,523
cpp
C++
cdn/src/v20180606/model/MaxAgeRule.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
43
2019-08-14T08:14:12.000Z
2022-03-30T12:35:09.000Z
cdn/src/v20180606/model/MaxAgeRule.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
12
2019-07-15T10:44:59.000Z
2021-11-02T12:35:00.000Z
cdn/src/v20180606/model/MaxAgeRule.cpp
suluner/tencentcloud-sdk-cpp
a56c73cc3f488c4d1e10755704107bb15c5e000d
[ "Apache-2.0" ]
28
2019-07-12T09:06:22.000Z
2022-03-30T08:04:18.000Z
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <tencentcloud/cdn/v20180606/model/MaxAgeRule.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Cdn::V20180606::Model; using namespace std; MaxAgeRule::MaxAgeRule() : m_maxAgeTypeHasBeenSet(false), m_maxAgeContentsHasBeenSet(false), m_maxAgeTimeHasBeenSet(false), m_followOriginHasBeenSet(false) { } CoreInternalOutcome MaxAgeRule::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("MaxAgeType") && !value["MaxAgeType"].IsNull()) { if (!value["MaxAgeType"].IsString()) { return CoreInternalOutcome(Core::Error("response `MaxAgeRule.MaxAgeType` IsString=false incorrectly").SetRequestId(requestId)); } m_maxAgeType = string(value["MaxAgeType"].GetString()); m_maxAgeTypeHasBeenSet = true; } if (value.HasMember("MaxAgeContents") && !value["MaxAgeContents"].IsNull()) { if (!value["MaxAgeContents"].IsArray()) return CoreInternalOutcome(Core::Error("response `MaxAgeRule.MaxAgeContents` is not array type")); const rapidjson::Value &tmpValue = value["MaxAgeContents"]; for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr) { m_maxAgeContents.push_back((*itr).GetString()); } m_maxAgeContentsHasBeenSet = true; } if (value.HasMember("MaxAgeTime") && !value["MaxAgeTime"].IsNull()) { if (!value["MaxAgeTime"].IsInt64()) { return CoreInternalOutcome(Core::Error("response `MaxAgeRule.MaxAgeTime` IsInt64=false incorrectly").SetRequestId(requestId)); } m_maxAgeTime = value["MaxAgeTime"].GetInt64(); m_maxAgeTimeHasBeenSet = true; } if (value.HasMember("FollowOrigin") && !value["FollowOrigin"].IsNull()) { if (!value["FollowOrigin"].IsString()) { return CoreInternalOutcome(Core::Error("response `MaxAgeRule.FollowOrigin` IsString=false incorrectly").SetRequestId(requestId)); } m_followOrigin = string(value["FollowOrigin"].GetString()); m_followOriginHasBeenSet = true; } return CoreInternalOutcome(true); } void MaxAgeRule::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_maxAgeTypeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "MaxAgeType"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_maxAgeType.c_str(), allocator).Move(), allocator); } if (m_maxAgeContentsHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "MaxAgeContents"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator); for (auto itr = m_maxAgeContents.begin(); itr != m_maxAgeContents.end(); ++itr) { value[key.c_str()].PushBack(rapidjson::Value().SetString((*itr).c_str(), allocator), allocator); } } if (m_maxAgeTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "MaxAgeTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_maxAgeTime, allocator); } if (m_followOriginHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "FollowOrigin"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_followOrigin.c_str(), allocator).Move(), allocator); } } string MaxAgeRule::GetMaxAgeType() const { return m_maxAgeType; } void MaxAgeRule::SetMaxAgeType(const string& _maxAgeType) { m_maxAgeType = _maxAgeType; m_maxAgeTypeHasBeenSet = true; } bool MaxAgeRule::MaxAgeTypeHasBeenSet() const { return m_maxAgeTypeHasBeenSet; } vector<string> MaxAgeRule::GetMaxAgeContents() const { return m_maxAgeContents; } void MaxAgeRule::SetMaxAgeContents(const vector<string>& _maxAgeContents) { m_maxAgeContents = _maxAgeContents; m_maxAgeContentsHasBeenSet = true; } bool MaxAgeRule::MaxAgeContentsHasBeenSet() const { return m_maxAgeContentsHasBeenSet; } int64_t MaxAgeRule::GetMaxAgeTime() const { return m_maxAgeTime; } void MaxAgeRule::SetMaxAgeTime(const int64_t& _maxAgeTime) { m_maxAgeTime = _maxAgeTime; m_maxAgeTimeHasBeenSet = true; } bool MaxAgeRule::MaxAgeTimeHasBeenSet() const { return m_maxAgeTimeHasBeenSet; } string MaxAgeRule::GetFollowOrigin() const { return m_followOrigin; } void MaxAgeRule::SetFollowOrigin(const string& _followOrigin) { m_followOrigin = _followOrigin; m_followOriginHasBeenSet = true; } bool MaxAgeRule::FollowOriginHasBeenSet() const { return m_followOriginHasBeenSet; }
29.068421
141
0.68948
suluner
d28b3547eb0e4d66d90ddbaf151154ec854349e9
364
cpp
C++
experimental/Pomdog.Experimental/Rendering/Commands/PrimitiveCommand.cpp
ValtoForks/pomdog
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
[ "MIT" ]
null
null
null
experimental/Pomdog.Experimental/Rendering/Commands/PrimitiveCommand.cpp
ValtoForks/pomdog
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
[ "MIT" ]
null
null
null
experimental/Pomdog.Experimental/Rendering/Commands/PrimitiveCommand.cpp
ValtoForks/pomdog
73798ae5f4a4c3b9b1e1e96239187c4b842c93b2
[ "MIT" ]
null
null
null
// Copyright (c) 2013-2018 mogemimi. Distributed under the MIT license. #include "PrimitiveCommand.hpp" #include <typeinfo> namespace Pomdog { namespace Rendering { std::type_index PrimitiveCommand::GetType() const noexcept { static const std::type_index index = typeid(PrimitiveCommand); return index; } } // namespace Rendering } // namespace Pomdog
21.411765
71
0.75
ValtoForks
d28e0ed0eec37b8be772216052d755a22ef7a7cc
362
cpp
C++
Series Patterns/seriespattern16.cpp
Starkl7/CPlusPlus-PatternHouse
cf53feac9857d0d87981909e0e8daeda26cb02f4
[ "MIT" ]
4
2021-09-21T03:43:26.000Z
2022-01-07T03:07:56.000Z
Series Patterns/seriespattern16.cpp
Starkl7/CPlusPlus-PatternHouse
cf53feac9857d0d87981909e0e8daeda26cb02f4
[ "MIT" ]
916
2021-09-01T15:40:24.000Z
2022-01-10T17:57:59.000Z
Series Patterns/seriespattern16.cpp
Starkl7/CPlusPlus-PatternHouse
cf53feac9857d0d87981909e0e8daeda26cb02f4
[ "MIT" ]
20
2021-09-30T18:13:58.000Z
2022-01-06T09:55:36.000Z
#include<iostream> using namespace std; int main() { long d,n,a1; float an; cout<<"Enter first term "; cin>>a1; cout<<"Enter difference "; cin>>d; cout<<"Enter number of terms"; cin>>n; cout<<"Harmonic progression : "; for(int y=1;y<=n;y++) { an=a1+(y-1)*d; cout<<"1/"<<an<<" "; } return 0; }
18.1
36
0.5
Starkl7
d28fa679fa7114dee2fa1eaf6219907dbacbf930
4,151
cpp
C++
SyP2.cpp
AnimaxNeil/Data-structure
dd7675907bd17325e4629c1529835f0a4452fdcd
[ "MIT" ]
null
null
null
SyP2.cpp
AnimaxNeil/Data-structure
dd7675907bd17325e4629c1529835f0a4452fdcd
[ "MIT" ]
null
null
null
SyP2.cpp
AnimaxNeil/Data-structure
dd7675907bd17325e4629c1529835f0a4452fdcd
[ "MIT" ]
null
null
null
// WAP using templates to sort a list of elements. Give user the option to perform sorting using Insertion sort, Bubble sort or Selection sort. #include <iostream> using namespace std; template <typename T> class List { T *arr; int capacity; void adjust_capacity() { if (size == capacity) { T *prev_arr = arr; capacity *= 2; arr = new T[capacity]; if (arr == NULL) { throw "out of memory"; } for (int i = 0; i < size; i++) { arr[i] = prev_arr[i]; } } } public: int size; List(int capacity = 1) { this->capacity = capacity; arr = new T[capacity]; size = 0; } void insert(T data) { adjust_capacity(); arr[size++] = data; } void ordered_insert(T data) { adjust_capacity(); int p = 0; while (p < size && arr[p] <= data) { p++; } for (int i = size - 1; i >= p; i--) { arr[i + 1] = arr[i]; } arr[p] = data; size++; } void remove(T data) { int p = 0; while (p < size && arr[p] != data) { p++; } if (p == size) { return; } for (int i = p; i < size - 1; i++) { arr[i] = arr[i + 1]; } size--; } void insertion_sort() { int j; T key; for (int i = 1; i < size; i++) { key = arr[i]; j = i - 1; while (j >= 0 && arr[j] > key) { arr[j + 1] = arr[j]; j--; } arr[j + 1] = key; } } void bubble_sort() { bool sorted; T temp; for (int i = 0; i < size - 1; i++) { sorted = true; for (int j = 0; j < size - 1 - i; j++) { if (arr[j] > arr[j + 1]) { sorted = false; temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; } } if (sorted) { break; } } } void selection_sort() { int min_i; T temp; for (int i = 0; i < size - 1; i++) { min_i = i; for (int j = i + 1; j < size; j++) { if (arr[j] < arr[min_i]) { min_i = j; } } temp = arr[i]; arr[i] = arr[min_i]; arr[min_i] = temp; } } void display() { if (size == 0) { cout << "List is empty.\n"; } else { cout << "Displaying list :\n"; for (int i = 0; i < size; i++) { cout << arr[i] << ", "; } cout << "\n"; } } }; int main() { int size; cout << "Input size of list : "; cin >> size; List<int> int_list(size); int integer; cout << "Input list elements :-\n"; for (int i = 0; i < size; i++) { cin >> integer; int_list.insert(integer); } int_list.display(); int sort_choice; cout << "Possible sort types are :-\n1. Insertion\n2. Bubble\n3. Selection\nInput type of sort : "; cin >> sort_choice; switch (sort_choice) { case 1: int_list.insertion_sort(); break; case 2: int_list.bubble_sort(); break; case 3: int_list.selection_sort(); break; default: cout << "Invalid sort type.\n"; return 1; } cout << "List elements sorted. "; int_list.display(); return 0; }
21.396907
144
0.349313
AnimaxNeil
d293773d2f738dab2cb0533707f1492835adb06f
1,455
hpp
C++
client_essential/OpusEnc.hpp
zhang-ray/easy-voice-call
9393a75f89d2f75c9d18d886abd38ffa5d9c5138
[ "MIT" ]
33
2018-10-11T05:30:37.000Z
2022-02-10T12:51:47.000Z
client_essential/OpusEnc.hpp
zhang-ray/easy-voice-call
9393a75f89d2f75c9d18d886abd38ffa5d9c5138
[ "MIT" ]
16
2018-10-15T06:52:41.000Z
2020-11-06T02:53:21.000Z
client_essential/OpusEnc.hpp
zhang-ray/easy-voice-call
9393a75f89d2f75c9d18d886abd38ffa5d9c5138
[ "MIT" ]
2
2019-09-14T18:07:57.000Z
2020-04-29T09:38:02.000Z
#pragma once #include "AudioEncoder.hpp" #include "Singleton.hpp" #include <cstring> #include <set> #if defined(WIN32) || defined(ANDROID) #include <opus.h> #else #include <opus/opus.h> #endif #include "AudioCommon.hpp" #define MAX_PACKET_SIZE (3*1276) // libopus 1.2.1 // it seems like Opus' API is very easy to use. class OpusEnc final : public AudioEncoder, public Singleton<OpusEnc> { private: int err; OpusEncoder *encoder = nullptr; public: virtual ReturnType reInit() override { encoder = opus_encoder_create(sampleRate, 1, OPUS_APPLICATION_VOIP, &err); if (err<0) { return err; } // err = opus_encoder_ctl(encoder, OPUS_SET_BITRATE(64000)); // if (err < 0 ){ // return err; // } return 0; } virtual ReturnType encode(const std::vector<short> &pcmData, std::vector<char> &encodedData) override { unsigned char cbits[MAX_PACKET_SIZE]; /* Encode the frame. */ auto frame_size = pcmData.size(); auto nbBytes = opus_encode(encoder, pcmData.data(), frame_size, cbits, MAX_PACKET_SIZE); if (nbBytes<0) { fprintf(stderr, "%s:%d encode failed: %s\n", __FILE__, __LINE__, opus_strerror(nbBytes)); return EXIT_FAILURE; } encodedData.resize(nbBytes); memcpy(encodedData.data(), cbits, nbBytes); return 0; } virtual ~OpusEnc(){} };
25.526316
107
0.618557
zhang-ray
d293cc2934ff4a15a8f17a225ca290285e373a23
2,035
hpp
C++
utils/reset_mv_camera.hpp
gcusms/WolfVision
f802df73918b7dadafa41bbbe7381a1df79ef07e
[ "MIT" ]
24
2021-07-12T02:24:51.000Z
2022-03-25T19:59:15.000Z
utils/reset_mv_camera.hpp
gcusms/WolfVision
f802df73918b7dadafa41bbbe7381a1df79ef07e
[ "MIT" ]
16
2021-07-10T07:07:51.000Z
2021-12-06T11:36:07.000Z
utils/reset_mv_camera.hpp
gcusms/WolfVision
f802df73918b7dadafa41bbbe7381a1df79ef07e
[ "MIT" ]
38
2021-07-09T14:49:17.000Z
2022-03-27T09:40:59.000Z
#pragma once #include <algorithm> #include <stdexcept> #include <string> #include <vector> #include <fcntl.h> #include <linux/usbdevice_fs.h> #include <sys/ioctl.h> #include <unistd.h> #include <fmt/color.h> namespace utils { inline bool resetMVCamera() { static const auto identifier_green = fmt::format(fg(fmt::color::green) | fmt::emphasis::bold, "reset_mv_camera"); static const auto identifier_red = fmt::format(fg(fmt::color::red) | fmt::emphasis::bold, "reset_mv_camera"); static const std::vector<std::string> vendor_id{"f622", "080b"}; bool status{false}; fmt::print("[{}] Starting mindvision camera soft reset\n", identifier_green); for (const auto& _id : vendor_id) { std::string cmd{ "lsusb -d : | awk '{split($0, i, \":\"); split(i[1], j, \" \"); print(\"/dev/bus/usb/\"j[2]\"/\"j[4])}'"}; std::string result{""}; FILE* pipe = popen(cmd.insert(9, _id).c_str(), "r"); if (!pipe) { fmt::print("[{}] Error, cannot open shell buffer\n", identifier_red); } try { char buffer[128]; while (fgets(buffer, sizeof buffer, pipe) != NULL) { result += buffer; } } catch (...) { pclose(pipe); throw; } pclose(pipe); result.erase(std::remove(result.begin(), result.end(), '\n'), result.end()); if (!result.empty()) { fmt::print("[{}] Performing soft reset on device: {}\n", identifier_green, result); int fd{open(result.c_str(), O_WRONLY)}; if (fd < 0) { fmt::print("[{}] Error, fcntl cannot open device: {}\n", identifier_red, result); } int rc = ioctl(fd, USBDEVFS_RESET, 0); if (rc < 0) { fmt::print("[{}] Error, ioctl cannot reset device: {}\n", identifier_red, result); } else { close(fd); status = true; fmt::print("[{}] Reset device '{}' success\n", identifier_green, result); } } } if (!status) { fmt::print("[{}] Error, cannot apply soft reset\n", identifier_red); } return status; } } // namespace utils
31.307692
115
0.588206
gcusms
d296c22e2245559cb256b471fe1ce8c0b34acc23
1,669
cpp
C++
AK/Tests/TestURL.cpp
JamiKettunen/serenity
232da5cc188496f570ef55276a897f1095509c87
[ "BSD-2-Clause" ]
3
2020-05-01T02:39:03.000Z
2021-11-26T08:34:54.000Z
AK/Tests/TestURL.cpp
JamiKettunen/serenity
232da5cc188496f570ef55276a897f1095509c87
[ "BSD-2-Clause" ]
null
null
null
AK/Tests/TestURL.cpp
JamiKettunen/serenity
232da5cc188496f570ef55276a897f1095509c87
[ "BSD-2-Clause" ]
1
2021-06-02T18:02:51.000Z
2021-06-02T18:02:51.000Z
#include <AK/TestSuite.h> #include <AK/URL.h> TEST_CASE(construct) { EXPECT_EQ(URL().is_valid(), false); } TEST_CASE(basic) { { URL url("http://www.serenityos.org/index.html"); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.protocol(), "http"); EXPECT_EQ(url.port(), 80); EXPECT_EQ(url.path(), "/index.html"); } { URL url("https://localhost:1234/~anon/test/page.html"); EXPECT_EQ(url.is_valid(), true); EXPECT_EQ(url.protocol(), "https"); EXPECT_EQ(url.port(), 1234); EXPECT_EQ(url.path(), "/~anon/test/page.html"); } } TEST_CASE(some_bad_urls) { EXPECT_EQ(URL("http:serenityos.org").is_valid(), false); EXPECT_EQ(URL("http:/serenityos.org").is_valid(), false); EXPECT_EQ(URL("http//serenityos.org").is_valid(), false); EXPECT_EQ(URL("http:///serenityos.org").is_valid(), false); EXPECT_EQ(URL("serenityos.org").is_valid(), false); EXPECT_EQ(URL("://serenityos.org").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:80:80/").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:80:80").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:abc").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:abc:80").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:abc:80/").is_valid(), false); EXPECT_EQ(URL("http://serenityos.org:/abc/").is_valid(), false); } TEST_CASE(serialization) { EXPECT_EQ(URL("http://www.serenityos.org/").to_string(), "http://www.serenityos.org/"); EXPECT_EQ(URL("http://www.serenityos.org:81/").to_string(), "http://www.serenityos.org:81/"); } TEST_MAIN(URL)
32.72549
97
0.633913
JamiKettunen
d29992c0d04925508ac0b1c0b63726e35bf1a70e
440
cpp
C++
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.27.cpp
alaxion/Learning
4b12b1603419252103cd933fdbfc4b2faffb6d00
[ "MIT" ]
null
null
null
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.27.cpp
alaxion/Learning
4b12b1603419252103cd933fdbfc4b2faffb6d00
[ "MIT" ]
null
null
null
CppPrimer/CppPrimer-Exercises/CppPrimer-Ch02/Exercise2.27.cpp
alaxion/Learning
4b12b1603419252103cd933fdbfc4b2faffb6d00
[ "MIT" ]
null
null
null
// Exercise2.27.cpp // Ad // Which of the following are legal? #include <iostream> int main() { int i = -1, &r = 0; // cannot refer to 0 int i2{0}; int *const p2 = &i2; const int ii = -1, &rr = 0; const int *const p3 = &i2; const int *p1 = &i2; const int &const r2; // no const references and not initialized const int i3 = i, &r3 = i; // Pause std::cin.get(); return 0; }
20.952381
75
0.525
alaxion
d2a17d603c73c40b20150d0b9961a53d0ae01394
3,272
hpp
C++
src/ui/Widget.hpp
nopdotcom/opentxs
140428ba8f1bd4c09654ebf0a1c1725f396efa8b
[ "MIT" ]
null
null
null
src/ui/Widget.hpp
nopdotcom/opentxs
140428ba8f1bd4c09654ebf0a1c1725f396efa8b
[ "MIT" ]
null
null
null
src/ui/Widget.hpp
nopdotcom/opentxs
140428ba8f1bd4c09654ebf0a1c1725f396efa8b
[ "MIT" ]
null
null
null
// Copyright (c) 2018 The Open-Transactions developers // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #pragma once #include "Internal.hpp" #include "opentxs/network/zeromq/ListenCallback.hpp" #include "opentxs/network/zeromq/RequestSocket.hpp" #include "opentxs/network/zeromq/SubscribeSocket.hpp" #include "opentxs/ui/Widget.hpp" namespace opentxs::ui::implementation { template <typename T> T extract_custom(const CustomData& custom, const std::size_t index = 0) { OT_ASSERT((index + 1) <= custom.size()) std::unique_ptr<const T> output{static_cast<const T*>(custom.at(index))}; OT_ASSERT(output) return *output; } class Widget : virtual public opentxs::ui::Widget { public: class MessageFunctor { public: virtual void operator()(Widget* object, const network::zeromq::Message&) const = 0; protected: MessageFunctor() = default; private: MessageFunctor(const MessageFunctor&) = delete; MessageFunctor(MessageFunctor&&) = delete; MessageFunctor& operator=(const MessageFunctor&) = delete; MessageFunctor& operator=(MessageFunctor&&) = delete; }; template <typename T> class MessageProcessor : virtual public MessageFunctor { public: typedef void (T::*Function)(const network::zeromq::Message&); void operator()(Widget* object, const network::zeromq::Message& message) const override { auto real = dynamic_cast<T*>(object); OT_ASSERT(nullptr != real) (real->*callback_)(message); } MessageProcessor(Function callback) : callback_(callback) { } MessageProcessor(MessageProcessor&&) = default; MessageProcessor& operator=(MessageProcessor&&) = default; private: Function callback_; MessageProcessor() = delete; MessageProcessor(const MessageProcessor&) = delete; MessageProcessor& operator=(const MessageProcessor&) = delete; }; OTIdentifier WidgetID() const override; virtual ~Widget() = default; protected: using ListenerDefinition = std::pair<std::string, MessageFunctor*>; using ListenerDefinitions = std::vector<ListenerDefinition>; const api::client::Manager& api_; const network::zeromq::PublishSocket& publisher_; const OTIdentifier widget_id_; void setup_listeners(const ListenerDefinitions& definitions); void UpdateNotify() const; Widget( const api::client::Manager& api, const network::zeromq::PublishSocket& publisher, const Identifier& id); Widget( const api::client::Manager& api, const network::zeromq::PublishSocket& publisher); private: std::vector<OTZMQListenCallback> callbacks_; std::vector<OTZMQSubscribeSocket> listeners_; Widget() = delete; Widget(const Widget&) = delete; Widget(Widget&&) = delete; Widget& operator=(const Widget&) = delete; Widget& operator=(Widget&&) = delete; }; // namespace opentxs::ui::implementation } // namespace opentxs::ui::implementation
28.955752
80
0.669927
nopdotcom
d2a2237addccd3dc3fb3f7540c6a37a0de865bb8
258
cpp
C++
exodus/libexodus/exodus/howto.cpp
BOBBYWY/exodusdb
cfe8a3452480af90071dd10cefeed58299eed4e7
[ "MIT" ]
4
2021-01-23T14:36:34.000Z
2021-06-07T10:02:28.000Z
exodus/libexodus/exodus/howto.cpp
BOBBYWY/exodusdb
cfe8a3452480af90071dd10cefeed58299eed4e7
[ "MIT" ]
1
2019-08-04T19:15:56.000Z
2019-08-04T19:15:56.000Z
exodus/libexodus/exodus/howto.cpp
BOBBYWY/exodusdb
cfe8a3452480af90071dd10cefeed58299eed4e7
[ "MIT" ]
1
2022-01-29T22:41:01.000Z
2022-01-29T22:41:01.000Z
#if defined(__CINT__) /* CINT*/ #elif defined(__BORLANDC__) /* ...Borland...*/ #elif defined(__WATCOMC__) /* ...Watcom C/C++...*/ #elif defined(_MSC_VER) /* ...Microsoft C/Visual C+++*/ #elif defined(__CYGWIN__) /* ...cygwin... */ #else /* ...... */ #endif
17.2
31
0.593023
BOBBYWY
d2a478b068e5ecbd5a9328127c98332ddf668aca
2,896
hpp
C++
doc/mainpage.hpp
graphnode/CSFML-Merge
096ae4bfce91a687a999ac4e89617da3b973f90b
[ "Zlib" ]
257
2015-04-30T07:51:40.000Z
2022-03-28T07:59:07.000Z
doc/mainpage.hpp
graphnode/CSFML-Merge
096ae4bfce91a687a999ac4e89617da3b973f90b
[ "Zlib" ]
76
2015-04-30T23:20:53.000Z
2022-03-17T07:58:16.000Z
doc/mainpage.hpp
graphnode/CSFML-Merge
096ae4bfce91a687a999ac4e89617da3b973f90b
[ "Zlib" ]
144
2015-04-30T18:34:50.000Z
2022-03-28T01:28:40.000Z
//////////////////////////////////////////////////////////// /// \mainpage /// /// \section welcome Welcome /// Welcome to the official SFML documentation for C. Here you will find a detailed /// view of all the SFML <a href="./globals_func.htm">functions</a>.<br/> /// If you are looking for tutorials, you can visit the official website /// at <a href="http://www.sfml-dev.org/">www.sfml-dev.org</a>. /// /// \section example Short example /// Here is a short example, to show you how simple it is to use SFML in C : /// /// \code /// /// #include <SFML/Audio.h> /// #include <SFML/Graphics.h> /// /// int main() /// { /// sfVideoMode mode = {800, 600, 32}; /// sfRenderWindow* window; /// sfTexture* texture; /// sfSprite* sprite; /// sfFont* font; /// sfText* text; /// sfMusic* music; /// sfEvent event; /// /// /* Create the main window */ /// window = sfRenderWindow_create(mode, "SFML window", sfResize | sfClose, NULL); /// if (!window) /// return EXIT_FAILURE; /// /// /* Load a sprite to display */ /// texture = sfTexture_createFromFile("cute_image.jpg", NULL); /// if (!texture) /// return EXIT_FAILURE; /// sprite = sfSprite_create(); /// sfSprite_setTexture(sprite, texture, sfTrue); /// /// /* Create a graphical text to display */ /// font = sfFont_createFromFile("arial.ttf"); /// if (!font) /// return EXIT_FAILURE; /// text = sfText_create(); /// sfText_setString(text, "Hello SFML"); /// sfText_setFont(text, font); /// sfText_setCharacterSize(text, 50); /// /// /* Load a music to play */ /// music = sfMusic_createFromFile("nice_music.ogg"); /// if (!music) /// return EXIT_FAILURE; /// /// /* Play the music */ /// sfMusic_play(music); /// /// /* Start the game loop */ /// while (sfRenderWindow_isOpen(window)) /// { /// /* Process events */ /// while (sfRenderWindow_pollEvent(window, &event)) /// { /// /* Close window : exit */ /// if (event.type == sfEvtClosed) /// sfRenderWindow_close(window); /// } /// /// /* Clear the screen */ /// sfRenderWindow_clear(window, sfBlack); /// /// /* Draw the sprite */ /// sfRenderWindow_drawSprite(window, sprite, NULL); /// /// /* Draw the text */ /// sfRenderWindow_drawText(window, text, NULL); /// /// /* Update the window */ /// sfRenderWindow_display(window); /// } /// /// /* Cleanup resources */ /// sfMusic_destroy(music); /// sfText_destroy(text); /// sfFont_destroy(font); /// sfSprite_destroy(sprite); /// sfTexture_destroy(texture); /// sfRenderWindow_destroy(window); /// /// return EXIT_SUCCESS; /// } /// \endcode ////////////////////////////////////////////////////////////
30.808511
86
0.538329
graphnode
d2a5b1c85cc6414396454dd1b4efd88feb1fa317
6,403
cpp
C++
lib/libCFG/src/CapPattern.cpp
cyber-itl/citl-static-analysis
32ef8e519dac1c6a49ff41d902a62df8f5a8e948
[ "MIT" ]
14
2021-05-03T16:03:22.000Z
2022-02-14T23:42:39.000Z
lib/libCFG/src/CapPattern.cpp
cyber-itl/citl-static-analysis
32ef8e519dac1c6a49ff41d902a62df8f5a8e948
[ "MIT" ]
1
2021-09-27T12:01:33.000Z
2021-09-27T12:01:33.000Z
lib/libCFG/src/CapPattern.cpp
cyber-itl/citl-static-analysis
32ef8e519dac1c6a49ff41d902a62df8f5a8e948
[ "MIT" ]
null
null
null
#include <cstdint> #include <vector> #include <algorithm> #include <utility> #include "capstone/capstone.h" #include "glog/logging.h" #include "CapPattern.hpp" OperPat::OperPat(op_type op_type) : reg(0), type(op_type) {}; OperPat::OperPat(op_type op_type, uint64_t reg) : reg(reg), type(op_type) {}; OperPat::OperPat(op_type op_type, const std::vector<uint32_t> &regs) : reg(0), type(op_type), regs{regs} {}; InsnPattern::InsnPattern(uint32_t id) : m_id(id), m_op_count(0) {}; InsnPattern::InsnPattern(uint32_t id, const std::vector<OperPat> &opers) : m_id(id), m_op_count(opers.size()), m_opers(opers) {}; Pattern::Pattern(const std::vector<InsnPattern> &pattern) : type(pat_type::ORDERED), insn_patterns(pattern) {}; Pattern::Pattern(pat_type type, const std::vector<InsnPattern> &pattern) : type(type), insn_patterns(pattern) {}; CapPattern::CapPattern(cs_insn *insns, uint64_t count, cs_arch arch, cs_mode mode) : m_insns(insns), m_count(count), m_arch(arch), m_mode(mode) {}; bool CapPattern::check_pattern(const Pattern &pattern) { if (m_count < pattern.insn_patterns.size()) { return false; } bool unordered_match = false; std::vector<bool> matched_idxs; if (pattern.type == pat_type::UNORDERED) { unordered_match = true; matched_idxs.resize(pattern.insn_patterns.size(), false); } for (uint64_t idx = 0; idx < m_count; idx++) { cs_insn insn = m_insns[idx]; if (idx >= pattern.insn_patterns.size()) { break; } if (unordered_match) { bool match_any = false; uint64_t pat_idx = 0; for (const auto &cur_pat : pattern.insn_patterns) { // Skip things we already matched. if (matched_idxs.at(pat_idx)) { pat_idx++; continue; } if (this->check_insn(insn, cur_pat)) { match_any = true; matched_idxs.at(pat_idx) = true; break; } pat_idx++; } if (!match_any) { return false; } } else { InsnPattern cur_pat = pattern.insn_patterns.at(idx); if (!this->check_insn(insn, cur_pat)) { return false; } } } m_reg_placeholders.clear(); return true; } bool CapPattern::check_insn(cs_insn insn, const InsnPattern &pat) { if (pat.m_id != insn.id) { return false; } if (pat.m_op_count != 0) { bool valid_ops = false; if (m_arch == cs_arch::CS_ARCH_X86) { valid_ops = this->check_x86_ops(insn, pat); } else if (m_arch == cs_arch::CS_ARCH_ARM) { } else if (m_arch == cs_arch::CS_ARCH_ARM64) { } else { } if (!valid_ops) { return false; } } return true; } bool CapPattern::check_x86_ops(cs_insn insn, const InsnPattern &pat) { cs_x86 detail = insn.detail->x86; if (detail.op_count < pat.m_op_count) { return false; } for(uint8_t idx = 0; idx < detail.op_count; idx++) { cs_x86_op op = detail.operands[idx]; if (idx >= pat.m_op_count) { break; } OperPat op_pat = pat.m_opers.at(idx); switch (op_pat.type) { case op_type::WILDCARD: continue; break; case op_type::REG: if (op.type != X86_OP_REG) { return false; } // Allow * reg value's if (op_pat.reg != X86_REG_INVALID) { if (op_pat.reg != op.reg) { return false; } } else { // Check for a list of optional regs if (op_pat.regs.size()) { if (std::find(op_pat.regs.cbegin(), op_pat.regs.cend(), op.reg) == op_pat.regs.cend()) { return false; } } } break; case op_type::SEG: if (op.type != X86_OP_MEM) { return false; } if (op_pat.reg != op.mem.segment) { return false; } break; case op_type::MEM: if (op.type != X86_OP_MEM) { return false; } // Allow empty mem type without a reg. if (op_pat.reg != X86_REG_INVALID) { if (op.mem.base != op_pat.reg) { return false; } } else { // Check for a list of optional regs if (op_pat.regs.size()) { if (std::find(op_pat.regs.cbegin(), op_pat.regs.cend(), op.mem.base) == op_pat.regs.cend()) { return false; } } } break; case op_type::IMM: if (op.type != X86_OP_IMM) { return false; } break; case op_type::REG_PLACEHOLDER: { if (op.type != X86_OP_REG && op.type != X86_OP_MEM) { return false; } uint64_t reg_id = 0; if (op.type == X86_OP_REG) { reg_id = op.reg; } else if (op.type == X86_OP_MEM) { reg_id = op.mem.base; } else { LOG(FATAL) << "Invalid operand type for REG_PLACEHOLDER"; } auto reg_id_kv = m_reg_placeholders.find(op_pat.reg); // if we don't have it in the place holders map, store the first seen value. if (reg_id_kv == m_reg_placeholders.end()) { m_reg_placeholders.emplace(op_pat.reg, reg_id); } else { // Grab from the cache, verify that the current reg value is the same. if (reg_id != reg_id_kv->second) { return false; } } break; } default: LOG(FATAL) << "Invalid operand type: " << static_cast<uint32_t>(op_pat.type); break; } } return true; }
26.568465
113
0.487896
cyber-itl
d2ac808e273e575f526c2af92b34a4dddeda5eca
506
cpp
C++
SDLProjekt/Animator.cpp
TheKrzyko/SokobanSDL
dfc6e5cefcc84d069fcaad6908e9a1ba44444d29
[ "MIT" ]
null
null
null
SDLProjekt/Animator.cpp
TheKrzyko/SokobanSDL
dfc6e5cefcc84d069fcaad6908e9a1ba44444d29
[ "MIT" ]
null
null
null
SDLProjekt/Animator.cpp
TheKrzyko/SokobanSDL
dfc6e5cefcc84d069fcaad6908e9a1ba44444d29
[ "MIT" ]
null
null
null
#include "Animator.h" #include <string.h> Animator::Animator() { } Animator::~Animator() { } void Animator::addState(String name, const FrameAnimation& anim) { animations[name] = new FrameAnimation(anim); } void Animator::setState(String name) { if (currentState == name) return; if(currentState != String("")) animations[currentState]->stop(); currentState = name; animations[currentState]->play(); } Frame Animator::getCurrentFrame() { return animations[currentState]->getCurrentFrame(); }
16.866667
64
0.717391
TheKrzyko
d2ad385eb241038abe711399b0fe8b436e6b1bdf
13,775
cpp
C++
test/test_trial1.cpp
DaziyahS/ExperimentsSP22
22c8abef235a050aa6985cdad1e4db65ef86ea12
[ "MIT" ]
null
null
null
test/test_trial1.cpp
DaziyahS/ExperimentsSP22
22c8abef235a050aa6985cdad1e4db65ef86ea12
[ "MIT" ]
null
null
null
test/test_trial1.cpp
DaziyahS/ExperimentsSP22
22c8abef235a050aa6985cdad1e4db65ef86ea12
[ "MIT" ]
null
null
null
#include <Mahi/Gui.hpp> #include <Mahi/Util.hpp> #include <Mahi/Util/Logging/Log.hpp> #include <syntacts> #include <random> #include <iostream> #include <fstream> // need to include inorder to save to csv #include <chrono> #include <string> // for manipulating file name // local includes #include <Chord.hpp> #include <Note.hpp> // open the namespaces that are relevant for this code using namespace mahi::gui; using namespace mahi::util; using tact::Signal; using tact::sleep; using tact::Sequence; // deteremine application variables int windowWidth = 1920; // 1920 x 1080 is screen dimensions int windowHeight = 1080; std::string my_title= "Play GUI"; ImVec2 buttonSizeBegin = ImVec2(800, 65); // Size of buttons on begin & transition screen ImVec2 buttonSizeTrial = ImVec2(400, 65); // Size of buttons on trial scean ImVec2 buttonSizeSAMs = ImVec2(150, 150); // Size of SAMs buttons int deviceNdx = 5; // tactors of interest int topTact = 4; int botTact = 6; int leftTact = 0; int rightTact = 2; // how to save to an excel document std::string saveSubject; // experiment details, allows me to customize std::ofstream file_name; // this holds the trial information class MyGui : public Application { // Start by declaring the session variable tact::Session s; // this ensures the whole app knows this session private: // Loading in of images bool loadTextureFromFile( const char *filename, GLuint *out_texture, int *out_width, int *out_height) { // Load from file int image_width = 0; int image_height = 0; unsigned char *image_data = stbi_load(filename, &image_width, &image_height, NULL, 4); if (image_data == NULL) return false; // Create a OpenGL texture identifier GLuint image_texture; glGenTextures(1, &image_texture); glBindTexture(GL_TEXTURE_2D, image_texture); // Setup filtering parameters for display glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // This is required on WebGL for non power-of-two textures glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Same // Upload pixels into texture #if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__) glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); #endif glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); stbi_image_free(image_data); *out_texture = image_texture; *out_width = image_width; *out_height = image_height; return true; } // simple wrapper to simplify importing images bool loadIcon(const char *imgPath, GLuint *my_image_texture) { int my_image_width = 0; int my_image_height = 0; bool ret = loadTextureFromFile(imgPath, my_image_texture, &my_image_width, &my_image_height); IM_ASSERT(ret); return true; } // Define the variables for the SAMs GLuint valSAMs[5]; // valence GLuint arousSAMs[5]; // arousal std::string iconValues[5] = {"neg2", "neg1", "0", "1", "2"}; public: // this is a constructor. It initializes your class to a specific state MyGui() : Application(windowWidth, windowHeight, my_title, 0), chordNew(), channelSignals(3) { s.open(deviceNdx); // , tact::API::MME); // opens session with the application // keep in mind, if use device name must also use the API // something the GUI needs *shrugs* ImGui::GetIO().ConfigFlags &= ~ImGuiConfigFlags_ViewportsEnable; set_background(Cyans::Teal); //background_color = Grays::Black; flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse; // so the current chord can play immediately currentChord = chordNew.signal_list[14]; // create the icons for (int i = 0; i < 5; i++) { loadIcon(("../../Figures/arous_" + iconValues[i] + ".png").c_str(), &arousSAMs[i]); loadIcon(("../../Figures/val_" + iconValues[i] + ".png").c_str(), &valSAMs[i]); } } // Define variables needed throughout the program ImGuiWindowFlags flags; // For creating the signal std::string currentChord; // holds name of current chord based on selection Chord chordNew; std::vector<tact::Signal> channelSignals; bool isSim = false; // default is sequential int amp, sus; // to determine state of image selection int pressed = -1; // valence int pressed2 = -1; // arousal // block 1 int train_num1 = 40; // amount of trials in training session int corr_train_num1 = 40; // amount of trials in corrective training session int experiment_num1 = 40; // amount of trials in experiment // block2 int train_num2 = 40; // amount of trials in training session int corr_train_num2 = 40; // amount of trials in corrective training session int experiment_num2 = 40; // amount of trials in experiment int val = 0, arous = 0; // initialize val&arous values int final_block_num = 6; // number of blocks total // For playing the signal Clock play_clock; // keeping track of time for non-blocking pauses bool playTime = false; // for knowing how long to play cues // Set up timing within the trials itself Clock trial_clock; double timeRespond; // track how long people take to decide // The amplitudes in a vector std::vector<int> listAmp = {0, 1, 2, 3}; // The sustains in a vector std::vector<int> listSus = {0, 1, 2}; // The base parameters for my chords std::vector<int> chordList = {0, 1, 2, 3, 4, 5, 6, 7}; // for all chords std::vector<int> baseChordList; // to determine the chords list for the next screen // Vector for if play can be pressed bool dontPlay = false; bool first_in_trial = true; // for collecting data int item_current_val = 0; int item_current_arous = 0; int currentChordNum = 0; // chord number to be played // for screens std::string screen_name = "begin_screen"; // start at the beginning screen int exp_num = 1; // start with major/minor identification virtual void update() override { ImGui::BeginFixed("", {50,50}, {(float)windowWidth-100, (float)windowHeight-100}, flags); trialScreen1(); ImGui::End(); } void trialScreen1(); { // Set up the paramaters // Define the base cue paramaters currentChord = chordNew.signal_list[currentChordNum]; // internal trial tracker static int count = 0; // random number generator static auto rng = std::default_random_engine {}; if (first_in_trial){ list = chordList; // initial randomization std::shuffle(std::begin(list), std::end(list), rng); // counter for trial starts at 0 in beginning count = 0; // set first_in_trial to false so initial randomization can happen once first_in_trial = false; } if (count < experiment_num){ if (!dontPlay){ } else { ImGui::Text("Valence"); for (int i = 0; i < 10; i++) { if (i < 5) { if (i > 0) { ImGui::SameLine(); } ImGui::PushID(i); if (pressed == i){ ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); } else ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(1 / 7.0f, 0.3f, 0.3f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(2 / 7.0f, 0.6f, 0.6f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(5 / 7.0f, 0.9f, 0.9f)); if(ImGui::ImageButton((void *)(intptr_t)valSAMs[i],buttonSizeSAMs, ImVec2(0,0), ImVec2(1,1), 5)) { pressed = i; val = pressed - 2; }; } else { if (i > 5) { ImGui::SameLine(); } else { ImGui::Text("Arousal"); } ImGui::PushID(i); if (pressed2 == i){ ImGui::PushStyleColor(ImGuiCol_Button,ImVec4(1.0f, 1.0f, 0.0f, 1.0f)); } else ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(1 / 7.0f, 0.3f, 0.3f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(2 / 7.0f, 0.6f, 0.6f)); ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)ImColor::HSV(5 / 7.0f, 0.9f, 0.9f)); if(ImGui::ImageButton((void *)(intptr_t)arousSAMs[i-5],buttonSizeSAMs, ImVec2(0,0), ImVec2(1,1), 5)) { pressed2 = i; arous = pressed2 - 7; }; } ImGui::PopStyleColor(3); ImGui::PopID(); } ImGui::NewLine(); ImGui::NewLine(); ImGui::SameLine(205); // Go to next cue if(ImGui::Button("Next",buttonSizeTrial)){ // Record the answers if (pressed > 0 && pressed2 > 0) { // timestamp information********** timeRespond = trial_clock.get_elapsed_time().as_seconds(); // get response time // put in the excel sheet file_name << count << ","; // track trial file_name << currentChordNum << "," << sus << "," << amp << "," << isSim << "," << chordNew.getMajor() << ","; // gathers experimental paramaters file_name << val << "," << arous << "," << timeRespond << std::endl; // gathers experimental input // reset values for drop down list pressed = -1; pressed2 = -1; // shuffle the amplitude list if needed int cue_num = count % 4; if (cue_num == 3){ std::shuffle(std::begin(list), std::end(list), rng); } // increase the list number count++; dontPlay = false; if(count < experiment_num) // if not final trial { // Play the next cue for listening purposes // determine which part of the list should be used cue_num = count%4; // determine what is the amp amp = list[cue_num]; // create the cue chordNew = Chord(currentChord, sus, amp, isSim); // determine the values for each channel channelSignals = chordNew.playValues(); // play_trial(cue_num); s.play(leftTact, channelSignals[0]); s.play(botTact, channelSignals[1]); s.play(rightTact, channelSignals[2]); // reset the play time clock play_clock.restart(); // allow for the play time to be measured and pause to be enabled playTime = true; } } else { ImGui::OpenPopup("Error"); } } if(ImGui::BeginPopup("Error")){ ImGui::Text("Please make both a valence and arousal selection before continuing."); if(ImGui::Button("Close")) { ImGui::CloseCurrentPopup(); } } } // Dictate how long the signal plays if (playTime) { // Let the user know that they should feel something ImGui::Text("The cue is currently playing."); int cue_num = count % 4; // if the signal time has passed, stop the signal on all channels if(play_clock.get_elapsed_time().as_seconds() > channelSignals[0].length()){ // if whole signal is played s.stopAll(); playTime = false; // do not reopen this until Play is pressed again trial_clock.restart(); // start recording the response time // Don't allow the user to press play again dontPlay = true; } } } else // if trials are done { cout << "done" << endl; } }
41.242515
165
0.532341
DaziyahS
d2b888ee6ffeb89540abf52892fd5c48fb0a3b60
228
hpp
C++
scicpp/linalg.hpp
tvanderbruggen/SciCpp
09408506c8d0b49ca5dadb8cd1f3cb4db41c8c46
[ "MIT" ]
2
2021-08-02T09:03:30.000Z
2022-02-17T11:58:05.000Z
scicpp/linalg.hpp
tvanderbruggen/SciCpp
09408506c8d0b49ca5dadb8cd1f3cb4db41c8c46
[ "MIT" ]
null
null
null
scicpp/linalg.hpp
tvanderbruggen/SciCpp
09408506c8d0b49ca5dadb8cd1f3cb4db41c8c46
[ "MIT" ]
null
null
null
// SPDX-License-Identifier: MIT // Copyright (c) 2019-2021 Thomas Vanderbruggen <[email protected]> #ifndef SCICPP_LINALG_HEADER #define SCICPP_LINALG_HEADER #include "linalg/solve.hpp" #endif // SCICPP_LINALG_HEADER
25.333333
76
0.798246
tvanderbruggen
d2b9aa173bf1cca601f0ac9b79473a26a0225895
29,356
cpp
C++
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
2
2020-03-03T12:40:29.000Z
2021-05-06T06:20:19.000Z
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
7
2020-01-14T20:38:04.000Z
2021-05-17T09:52:07.000Z
nodes/dash_shared/src/sync_db.cpp
solosTec/node
e35e127867a4f66129477b780cbd09c5231fc7da
[ "MIT" ]
2
2019-11-09T09:14:48.000Z
2020-03-03T12:40:30.000Z
/* * The MIT License (MIT) * * Copyright (c) 2018 Sylko Olzscher * */ #include "sync_db.h" #include "../../shared/db/db_schemes.h" #include <smf/cluster/generator.h> #include <cyng/table/meta.hpp> #include <cyng/io/serializer.h> #include <cyng/tuple_cast.hpp> #include <boost/algorithm/string.hpp> #include <boost/uuid/nil_generator.hpp> namespace node { void create_cache(cyng::logging::log_ptr logger, cyng::store::db& db) { CYNG_LOG_TRACE(logger, "create cache tables"); if (!create_table(db, "TDevice")) { CYNG_LOG_FATAL(logger, "cannot create table TDevice"); } // // Has more columns than original TGateway definition // if (!db.create_table(cyng::table::make_meta_table<1, 16>("TGateway", { "pk" // primary key , "serverId" // (1) Server-ID (i.e. 0500153B02517E) , "manufacturer" // (2) manufacturer (i.e. EMH) , "made" // (4) production date , "factoryNr" // (6) fabrik nummer (i.e. 06441734) , "ifService" // (7) MAC of service interface , "ifData" // (8) MAC od data interface , "pwdDef" // (9) Default PW , "pwdRoot" // (10) root PW , "mbus" // (11) W-Mbus ID (i.e. A815408943050131) , "userName" // (12) , "userPwd" // (13) // since here columns specific for dash/s and not part of the original table scheme , "name" // IP-T/device name , "descr" // IP-T/device description , "model" // (3) Typbezeichnung (i.e. Variomuc ETHERNET) , "vFirmware" // (5) firmware version (i.e. 11600000) , "online" // (14) }, { cyng::TC_UUID // pk , cyng::TC_STRING // server id , cyng::TC_STRING // manufacturer , cyng::TC_TIME_POINT // production data , cyng::TC_STRING // Fabriknummer/serial number (i.e. 06441734) , cyng::TC_MAC48 // MAC of service interface , cyng::TC_MAC48 // MAC od data interface , cyng::TC_STRING // Default PW , cyng::TC_STRING // root PW , cyng::TC_STRING // W-Mbus ID (i.e. A815408943050131) , cyng::TC_STRING // operator , cyng::TC_STRING // operator // --- dynamic part: , cyng::TC_STRING // IP-T/device name , cyng::TC_STRING // model , cyng::TC_STRING // vFirmware , cyng::TC_INT32 // on/offline state }, { 36 // pk , 23 // server id , 64 // manufacturer , 0 // production date , 8 // serial , 18 // MAC , 18 // MAC , 32 // PW , 32 // PW , 16 // M-Bus , 32 // PW , 32 // PW , 128 // IP-T/device name , 64 // model , 64 // vFirmware , 0 // online/offline state }))) { CYNG_LOG_FATAL(logger, "cannot create table TGateway"); } // https://www.thethingsnetwork.org/docs/lorawan/address-space.html#devices // DevEUI - 64 bit end-device identifier, EUI-64 (unique) // DevAddr - 32 bit device address (non-unique) if (!create_table(db, "TLoRaDevice")) { CYNG_LOG_FATAL(logger, "cannot create table TLoRaDevice"); } if (!db.create_table(cyng::table::make_meta_table<1, 13>("TMeter", { "pk" , "ident" // ident nummer (i.e. 1EMH0006441734, 01-e61e-13090016-3c-07) , "meter" // meter number (i.e. 16000913) 4 bytes , "code" // metering code - changed at 2019-01-31 , "maker" // manufacturer , "tom" // time of manufacture , "vFirmware" // firmwareversion (i.e. 11600000) , "vParam" // parametrierversion (i.e. 16A098828.pse) , "factoryNr" // fabrik nummer (i.e. 06441734) , "item" // ArtikeltypBezeichnung = "NXT4-S20EW-6N00-4000-5020-E50/Q" , "mClass" // Metrological Class: A, B, C, Q3/Q1, ... , "gw" // optional gateway pk // -- additional columns , "serverId" // optional gateway server ID , "online" // gateway online state (1,2,3) }, { cyng::TC_UUID , cyng::TC_STRING // ident , cyng::TC_STRING // meter , cyng::TC_STRING // code , cyng::TC_STRING // maker , cyng::TC_TIME_POINT // tom , cyng::TC_STRING // vFirmware , cyng::TC_STRING // vParam , cyng::TC_STRING // factoryNr , cyng::TC_STRING // item , cyng::TC_STRING // mClass , cyng::TC_UUID // gw , cyng::TC_STRING // serverID , cyng::TC_INT32 // on/offline state }, { 36 , 24 // ident , 8 // meter , 33 // code - country[2], ident[11], number[22] , 64 // maker , 0 // tom , 64 // vFirmware , 64 // vParam , 32 // factoryNr , 128 // item , 8 // mClass , 36 // gw , 23 // serverId , 0 // on/offline state }))) { CYNG_LOG_FATAL(logger, "cannot create table TMeter"); } if (!create_table(db, "_Session")) { CYNG_LOG_FATAL(logger, "cannot create table _Session"); } if (!create_table(db, "_Target")) { CYNG_LOG_FATAL(logger, "cannot create table _Target"); } if (!create_table(db, "_Connection")) { CYNG_LOG_FATAL(logger, "cannot create table _Connection"); } if (!create_table(db, "_Cluster")) { CYNG_LOG_FATAL(logger, "cannot create table _Cluster"); } if (!create_table(db, "_Config")) { CYNG_LOG_FATAL(logger, "cannot create table _Config"); } else { // // set initial value // //db.insert("_Config", cyng::table::key_generator("cpu:load"), cyng::table::data_generator(0.0), 0, bus_->vm_.tag()); } if (!create_table(db, "_SysMsg")) { CYNG_LOG_FATAL(logger, "cannot create table _SysMsg"); } if (!create_table(db, "_TimeSeries")) { CYNG_LOG_FATAL(logger, "cannot create table _TimeSeries"); } if (!create_table(db, "_CSV")) { CYNG_LOG_FATAL(logger, "cannot create table _CSV"); } if (!create_table(db, "_LoRaUplink")) { CYNG_LOG_FATAL(logger, "cannot create table _LoRaUplink"); } // // all tables created // CYNG_LOG_INFO(logger, db.size() << " tables created"); } void clear_cache(cyng::store::db& db, boost::uuids::uuid tag) { db.clear("TDevice", tag); db.clear("TGateway", tag); db.clear("TMeter", tag); db.clear("_Session", tag); db.clear("_Target", tag); db.clear("_Connection", tag); db.clear("_Cluster", tag); db.clear("_Config", tag); db.insert("_Config", cyng::table::key_generator("cpu:load"), cyng::table::data_generator(0.0), 0, tag); //cache_.clear("_SysMsg", bus_->vm_.tag()); } void res_subscribe(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::table::data_type data // [2] record , std::uint64_t gen // [3] generation , boost::uuids::uuid origin // [4] origin session id , std::size_t tsk) { // // Boost gateway records with additional data from TDevice and _Session table // if (boost::algorithm::equals(table, "TGateway")) { // // Additional values for TGateway // db.access([&](const cyng::store::table* tbl_dev, const cyng::store::table* tbl_ses) { // // Gateway and Device table share the same table key // look for a session of this device // auto dev_rec = tbl_dev->lookup(key); auto ses_rec = tbl_ses->find_first(cyng::param_t("device", key.at(0))); // // set device name // set model // set firmware // set online state // if (!dev_rec.empty()) { data.push_back(dev_rec["name"]); data.push_back(dev_rec["descr"]); data.push_back(dev_rec["id"]); data.push_back(dev_rec["vFirmware"]); if (ses_rec.empty()) { data.push_back(cyng::make_object(0)); } else { const auto peer = cyng::value_cast(ses_rec["rtag"], boost::uuids::nil_uuid()); data.push_back(cyng::make_object(peer.is_nil() ? 1 : 2)); } } else { CYNG_LOG_WARNING(logger, "res.subscribe - gateway" << cyng::io::to_str(key) << " has no associated device"); } } , cyng::store::read_access("TDevice") , cyng::store::read_access("_Session")); } // // Boost meter records with additional data from TGateway // else if (boost::algorithm::equals(table, "TMeter")) { // // Additional values for TMeter // db.access([&](const cyng::store::table* tbl_gw) { // // TMeter contains an optional reference to TGateway table // auto key = cyng::table::key_generator(data.at(10)); auto dev_gw = tbl_gw->lookup(key); // // set serverId and online state // if (!dev_gw.empty()) { data.push_back(dev_gw["serverId"]); data.push_back(dev_gw["online"]); } else { data.push_back(cyng::make_object("05000000000000")); data.push_back(cyng::make_object(-1)); CYNG_LOG_WARNING(logger, "res.subscribe - meter" << cyng::io::to_str(key) << " has no associated gateway"); } }, cyng::store::read_access("TGateway")); } // // insert new record // if (!db.insert(table // table name , key // table key , data // table data , gen // generation , origin)) { CYNG_LOG_WARNING(logger, "res.subscribe failed " << table // table name << " - " << cyng::io::to_str(key)); } else { if (boost::algorithm::equals(table, "_Session")) { // // mark gateways as online // db.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set state: offline tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { // // If rtag is not nil then this session has an open connection // auto const rtag = cyng::value_cast(rec["rtag"], boost::uuids::nil_uuid()); auto const state = rtag.is_nil() ? 1 : 2; tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", state), origin); // // update TMeter // Lookup if TMeter has a gateway with this key // This method is inherently slow. // ToDo: optimize // std::map<cyng::table::key_type, int> result; auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is online/connected // result.emplace(rec.key(), state); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item.first, cyng::param_factory("online", item.second), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } } } db_sync::db_sync(cyng::logging::log_ptr logger, cyng::store::db& db) : logger_(logger) , db_(db) {} void db_sync::register_this(cyng::controller& vm) { vm.register_function("db.res.insert", 4, std::bind(&db_sync::db_res_insert, this, std::placeholders::_1)); vm.register_function("db.res.remove", 2, std::bind(&db_sync::db_res_remove, this, std::placeholders::_1)); vm.register_function("db.res.modify.by.attr", 3, std::bind(&db_sync::db_res_modify_by_attr, this, std::placeholders::_1)); vm.register_function("db.res.modify.by.param", 3, std::bind(&db_sync::db_res_modify_by_param, this, std::placeholders::_1)); vm.register_function("db.req.insert", 4, std::bind(&db_sync::db_req_insert, this, std::placeholders::_1)); vm.register_function("db.req.remove", 3, std::bind(&db_sync::db_req_remove, this, std::placeholders::_1)); vm.register_function("db.req.modify.by.param", 5, std::bind(&db_sync::db_req_modify_by_param, this, std::placeholders::_1)); } void db_sync::db_res_insert(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [TDevice,[32f1a373-83c9-4f24-8fac-b13103bc7466],[00000006,2018-03-11 18:35:33.61302590,true,,,comment #10,1010000,secret,device-10000],0] // // * table name // * record key // * record data // * generation // CYNG_LOG_TRACE(logger_, "db.res.insert - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::table::data_type, // [2] record std::uint64_t // [3] generation >(frame); // // assemble a record // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); std::reverse(std::get<2>(tpl).begin(), std::get<2>(tpl).end()); db_insert(ctx , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl) // [2] record , std::get<3>(tpl) // [3] generation , ctx.tag()); // [4] origin } void db_sync::db_req_insert(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // // * table name // * record key // * record data // * generation // CYNG_LOG_TRACE(logger_, "db.req.insert - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::table::data_type, // [2] record std::uint64_t, // [3] generation boost::uuids::uuid // [4] source >(frame); // // assemble a record // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); std::reverse(std::get<2>(tpl).begin(), std::get<2>(tpl).end()); db_insert(ctx , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl) // [2] record , std::get<3>(tpl) // [3] generation , std::get<4>(tpl)); // [4] origin } void db_sync::db_req_remove(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [*Session,[e72bc048-cb37-4a86-b156-d07f22608476]] // // * table name // * record key // * source // CYNG_LOG_TRACE(logger_, "db.req.remove - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key boost::uuids::uuid // [2] source >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_req_remove(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::get<2>(tpl)); // [2] source } void db_sync::db_res_remove(cyng::context& ctx) { const cyng::vector_t frame = ctx.get_frame(); // // [TDevice,[def8e1ef-4a67-49ff-84a9-fda31509dd8e]] // // * table name // * record key // CYNG_LOG_TRACE(logger_, "db.res.remove - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type // [1] table key >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_res_remove(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , ctx.tag()); // [2] source } void db_sync::db_res_modify_by_attr(cyng::context& ctx) { // [TDevice,[0950f361-7800-4d80-b3bc-c6689f159439],(1:secret)] // // * table name // * record key // * attr [column,value] // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.res.modify.by.attr - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::attr_t // [2] attribute >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_res_modify_by_attr(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] attribute , ctx.tag()); // [3] source } void db_sync::db_res_modify_by_param(cyng::context& ctx) { // // // * table name // * record key // * param [column,value] // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.res.modify.by.param - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::param_t // [2] parameter >(frame); node::db_res_modify_by_param(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] parameter , ctx.tag()); // [3] source } void db_sync::db_req_modify_by_param(cyng::context& ctx) { // // [*Session,[35d1d76d-56c3-4df7-b1ff-b7ad374d2e8f],("rx":33344),327,35d1d76d-56c3-4df7-b1ff-b7ad374d2e8f] // [*Cluster,[1e4527b3-6479-4b2c-854b-e4793f40d864],("ping":00:00:0.003736),4,1e4527b3-6479-4b2c-854b-e4793f40d864] // // * table name // * record key // * param [column,value] // * generation // * source // const cyng::vector_t frame = ctx.get_frame(); CYNG_LOG_TRACE(logger_, "db.req.modify.by.param - " << cyng::io::to_str(frame)); auto tpl = cyng::tuple_cast< std::string, // [0] table name cyng::table::key_type, // [1] table key cyng::param_t, // [2] parameter std::uint64_t, // [3] generation boost::uuids::uuid // [4] source >(frame); // // reordering table key // std::reverse(std::get<1>(tpl).begin(), std::get<1>(tpl).end()); node::db_req_modify_by_param(logger_ , db_ , std::get<0>(tpl) // [0] table name , std::get<1>(tpl) // [1] table key , std::move(std::get<2>(tpl)) // [2] parameter , std::get<3>(tpl) // [3] generation , std::get<4>(tpl)); // [4] source } void db_sync::db_insert(cyng::context& ctx , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::table::data_type data // [2] record , std::uint64_t gen , boost::uuids::uuid origin) { if (boost::algorithm::equals(table, "TGateway")) { db_.access([&](cyng::store::table* tbl_gw, const cyng::store::table* tbl_dev, const cyng::store::table* tbl_ses) { // // search session with this device/GW tag // auto dev_rec = tbl_dev->lookup(key); // // set device name // set model // set vFirmware // set online state // if (!dev_rec.empty()) { data.push_back(dev_rec["name"]); data.push_back(dev_rec["descr"]); data.push_back(dev_rec["id"]); data.push_back(dev_rec["vFirmware"]); // // get online state // auto ses_rec = tbl_ses->find_first(cyng::param_t("device", key.at(0))); if (ses_rec.empty()) { data.push_back(cyng::make_object(0)); } else { const auto rtag = cyng::value_cast(ses_rec["rtag"], boost::uuids::nil_uuid()); data.push_back(cyng::make_object(rtag.is_nil() ? 1 : 2)); } if (!tbl_gw->insert(key, data, gen, origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); } } else { std::stringstream ss; ss << "gateway " << cyng::io::to_str(key) << " has no associated device" ; CYNG_LOG_WARNING(logger_, ss.str()); ctx.queue(bus_insert_msg(cyng::logging::severity::LEVEL_WARNING, ss.str())); } } , cyng::store::write_access("TGateway") , cyng::store::read_access("TDevice") , cyng::store::read_access("_Session")); } else if (boost::algorithm::equals(table, "TMeter")) { // // Additional values for TMeter // db_.access([&](cyng::store::table* tbl_meter, cyng::store::table const* tbl_gw) { // // TMeter contains an optional reference to TGateway table // auto const key_gw = cyng::table::key_generator(data.at(10)); auto const dev_gw = tbl_gw->lookup(key_gw); // // set serverId // if (!dev_gw.empty()) { data.push_back(dev_gw["serverId"]); data.push_back(dev_gw["online"]); } else { data.push_back(cyng::make_object("00000000000000")); data.push_back(cyng::make_object(-1)); CYNG_LOG_WARNING(logger_, "res.subscribe - meter" << cyng::io::to_str(key) << " has no associated gateway"); } if (!tbl_meter->insert(key, data, gen, origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); } } , cyng::store::write_access("TMeter") , cyng::store::read_access("TGateway")); } else if (!db_.insert(table , key , data , gen , origin)) { CYNG_LOG_WARNING(logger_, ctx.get_name() << " failed " << table // table name << " - " << cyng::io::to_str(key) << " => " << cyng::io::to_str(data)); // // dump record data // std::size_t idx{ 0 }; for (auto const& obj : data) { CYNG_LOG_TRACE(logger_, "data [" << idx++ << "] " << obj.get_class().type_name() << ": " << cyng::io::to_str(obj)) ; } } else { if (boost::algorithm::equals(table, "_Session")) { db_.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set online state tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { auto const rtag = cyng::value_cast(rec["rtag"], boost::uuids::nil_uuid()); auto const state = rtag.is_nil() ? 1 : 2; tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", state), origin); // // update TMeter // Lookup if TMeter has a gateway with this key // This method is inherently slow. // ToDo: optimize // std::map<cyng::table::key_type, int> result; auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is online/connected // result.emplace(rec.key(), state); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item.first, cyng::param_factory("online", item.second), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } } } void db_req_remove(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , boost::uuids::uuid origin) { // // we have to query session data before session will be removed // if (boost::algorithm::equals(table, "_Session")) { db.access([&](cyng::store::table* tbl_gw, cyng::store::table* tbl_meter, const cyng::store::table* tbl_ses) { // // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (!rec.empty()) { // set online state auto const gw_tag = cyng::value_cast(rec["device"], boost::uuids::nil_uuid()); tbl_gw->modify(cyng::table::key_generator(gw_tag), cyng::param_factory("online", 0), origin); // // find meters of this gateway and set offline // std::set<cyng::table::key_type> result; tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { // // The gateway of this meter is offline // result.emplace(rec.key()); } return true; // continue }); // // Update all found meters // for (auto const& item : result) { tbl_meter->modify(item, cyng::param_factory("online", 0), origin); } } } , cyng::store::write_access("TGateway") , cyng::store::write_access("TMeter") , cyng::store::read_access("_Session")); } // // remove record // if (!db.erase(table, key, origin)) { CYNG_LOG_WARNING(logger, "db.req.remove failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_remove(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , boost::uuids::uuid origin) { if (!db.erase(table, key, origin)) { CYNG_LOG_WARNING(logger, "db.res.remove failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_modify_by_attr(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::attr_t attr // [2] attribute , boost::uuids::uuid origin) { // // distribute some changes to other tables too // if (boost::algorithm::equals(table, "TDevice")) { switch (attr.first) { case 0: // change name db.modify("TGateway", key, cyng::param_factory("name", attr.second), origin); break; case 3: // change description db.modify("TGateway", key, cyng::param_factory("descr", attr.second), origin); break; default: break; } } else if (boost::algorithm::equals(table, "TGateway")) { // // distribute changes from TGateway to TMeter // switch (attr.first) { case 0: // modified serverID db.access([&](cyng::store::table* tbl_meter) { auto const gw_tag = cyng::value_cast(key.at(0), boost::uuids::nil_uuid()); std::set<cyng::table::key_type> result; tbl_meter->loop([&](cyng::table::record const& rec) -> bool { auto const tag = cyng::value_cast(rec["gw"], boost::uuids::nil_uuid()); if (tag == gw_tag) { result.insert(rec.key()); } return true; // continue }); for (auto const& item : result) { tbl_meter->modify(item, cyng::param_factory("serverId", attr.second), origin); } }, cyng::store::write_access("TMeter")); break; default: break; } } // // update cache // if (!db.modify(table, key, std::move(attr), origin)) { CYNG_LOG_WARNING(logger, "db.res.modify.by.attr failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_res_modify_by_param(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::param_t param // [2] parameter , boost::uuids::uuid origin) { if (!db.modify(table, key, param, origin)) { CYNG_LOG_WARNING(logger, "db.res.modify.by.param failed " << table // table name << " - " << cyng::io::to_str(key)); } } void db_req_modify_by_param(cyng::logging::log_ptr logger , cyng::store::db& db , std::string const& table // [0] table name , cyng::table::key_type key // [1] table key , cyng::param_t param // [2] parameter , std::uint64_t gen // [3] generation , boost::uuids::uuid origin) { if (boost::algorithm::equals(table, "_Session")) { if (boost::algorithm::equals(param.first, "rtag")) { const auto rtag = cyng::value_cast(param.second, boost::uuids::nil_uuid()); // // mark gateways as online // db.access([&](cyng::store::table* tbl_gw, const cyng::store::table* tbl_ses) { // // [*Session,[2ce46726-6bca-44b6-84ed-0efccb67774f],[00000000-0000-0000-0000-000000000000,2018-03-12 17:56:27.10338240,f51f2ae7,data-store,eaec7649-80d5-4b71-8450-3ee2c7ef4917,94aa40f9-70e8-4c13-987e-3ed542ecf7ab,null,session],1] // Gateway and Device table share the same table key // auto rec = tbl_ses->lookup(key); if (rec.empty()) { // set online state tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", 0), origin); } else { tbl_gw->modify(cyng::table::key_generator(rec["device"]), cyng::param_factory("online", rtag.is_nil() ? 1 : 2), origin); } } , cyng::store::write_access("TGateway") , cyng::store::read_access("_Session")); } } if (!db.modify(table, key, param, origin)) { CYNG_LOG_WARNING(logger, "db.req.modify.by.param failed " << table // table name << " - " << cyng::io::to_str(key)); } } }
28.226923
234
0.598617
solosTec
d2bd648559a621c4b9ee276afe119fd1ef0202ae
361
cpp
C++
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
cuddlySys/updatepetprofile.cpp
alisultan14/Pet_Matchmaker
98b9b2261430ca52d56f5ad670b486c0533444a6
[ "MIT" ]
null
null
null
#include "updatepetprofile.h" #include "ui_updatepetprofile.h" /** * @brief Constructor for the class * @param parent */ updatepetprofile::updatepetprofile(QWidget *parent) : QWidget(parent), ui(new Ui::updatepetprofile) { ui->setupUi(this); } /** * @brief Destructor for the class */ updatepetprofile::~updatepetprofile() { delete ui; }
16.409091
53
0.689751
alisultan14
d2c4a86d2544d252c415e7a8fed4b6dc477617c9
2,837
cpp
C++
RVAF-GUI/teechart/highlowseries.cpp
YangQun1/RVAF-GUI
f187e2325fc8fdbac84a63515b7dd67c09e2fc72
[ "BSD-2-Clause" ]
4
2018-03-31T10:45:19.000Z
2021-10-09T02:57:13.000Z
RVAF-GUI/teechart/highlowseries.cpp
P-Chao/RVAF-GUI
3bbeed7d2ffa400f754f095e7c08400f701813d4
[ "BSD-2-Clause" ]
1
2018-04-22T05:12:36.000Z
2018-04-22T05:12:36.000Z
RVAF-GUI/teechart/highlowseries.cpp
YangQun1/RVAF-GUI
f187e2325fc8fdbac84a63515b7dd67c09e2fc72
[ "BSD-2-Clause" ]
5
2018-01-13T15:57:14.000Z
2019-11-12T03:23:18.000Z
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. #include "stdafx.h" #include "highlowseries.h" // Dispatch interfaces referenced by this interface #include "valuelist.h" #include "brush.h" #include "pen.h" ///////////////////////////////////////////////////////////////////////////// // CHighLowSeries properties ///////////////////////////////////////////////////////////////////////////// // CHighLowSeries operations long CHighLowSeries::AddHighLow(double AX, double AHigh, double ALow, LPCTSTR AXLabel, unsigned long AColor) { long result; static BYTE parms[] = VTS_R8 VTS_R8 VTS_R8 VTS_BSTR VTS_I4; InvokeHelper(0xc9, DISPATCH_METHOD, VT_I4, (void*)&result, parms, AX, AHigh, ALow, AXLabel, AColor); return result; } CValueList CHighLowSeries::GetHighValues() { LPDISPATCH pDispatch; InvokeHelper(0xca, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CValueList(pDispatch); } CValueList CHighLowSeries::GetLowValues() { LPDISPATCH pDispatch; InvokeHelper(0xcb, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CValueList(pDispatch); } double CHighLowSeries::MaxYValue() { double result; InvokeHelper(0xcc, DISPATCH_METHOD, VT_R8, (void*)&result, NULL); return result; } double CHighLowSeries::MinYValue() { double result; InvokeHelper(0xcd, DISPATCH_METHOD, VT_R8, (void*)&result, NULL); return result; } CBrush1 CHighLowSeries::GetHighBrush() { LPDISPATCH pDispatch; InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CBrush1(pDispatch); } CPen1 CHighLowSeries::GetHighPen() { LPDISPATCH pDispatch; InvokeHelper(0x3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } CBrush1 CHighLowSeries::GetLowBrush() { LPDISPATCH pDispatch; InvokeHelper(0x5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CBrush1(pDispatch); } CPen1 CHighLowSeries::GetLowPen() { LPDISPATCH pDispatch; InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } CPen1 CHighLowSeries::GetPen() { LPDISPATCH pDispatch; InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&pDispatch, NULL); return CPen1(pDispatch); } long CHighLowSeries::GetTransparency() { long result; InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); return result; } void CHighLowSeries::SetTransparency(long nNewValue) { static BYTE parms[] = VTS_I4; InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, nNewValue); }
26.027523
109
0.694043
YangQun1
d2c64b2dd24a59bb3dd307e7ca8d91bb9df81260
8,336
hpp
C++
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
include/UnityEngine/Mathf.hpp
darknight1050/BeatSaber-Quest-Codegen
a6eeecc3f0e8f6079630f9a9a72b3121ac7b2032
[ "Unlicense" ]
null
null
null
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include <initializer_list> // Including type: System.ValueType #include "System/ValueType.hpp" // Completed includes // Begin il2cpp-utils forward declares template<class T> struct Array; // Completed il2cpp-utils forward declares // Type namespace: UnityEngine namespace UnityEngine { // Size: 0x0 #pragma pack(push, 1) // WARNING Layout: Sequential may not be correctly taken into account! // Autogenerated type: UnityEngine.Mathf // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC // [NativeHeaderAttribute] Offset: D8F8FC struct Mathf/*, public System::ValueType*/ { public: // Creating value type constructor for type: Mathf constexpr Mathf() noexcept {} // Creating interface conversion operator: operator System::ValueType operator System::ValueType() noexcept { return *reinterpret_cast<System::ValueType*>(this); } // Get static field: static public readonly System.Single Epsilon static float _get_Epsilon(); // Set static field: static public readonly System.Single Epsilon static void _set_Epsilon(float value); // static public System.Int32 NextPowerOfTwo(System.Int32 value) // Offset: 0x1BF493C static int NextPowerOfTwo(int value); // static public System.Single GammaToLinearSpace(System.Single value) // Offset: 0x1BF497C static float GammaToLinearSpace(float value); // static public System.Single LinearToGammaSpace(System.Single value) // Offset: 0x1BF49C0 static float LinearToGammaSpace(float value); // static public System.Single PerlinNoise(System.Single x, System.Single y) // Offset: 0x1BF4A04 static float PerlinNoise(float x, float y); // static public System.Single Sin(System.Single f) // Offset: 0x1BF4A50 static float Sin(float f); // static public System.Single Cos(System.Single f) // Offset: 0x1BF4AC4 static float Cos(float f); // static public System.Single Tan(System.Single f) // Offset: 0x1BF4B38 static float Tan(float f); // static public System.Single Asin(System.Single f) // Offset: 0x1BF4BAC static float Asin(float f); // static public System.Single Acos(System.Single f) // Offset: 0x1BF4C20 static float Acos(float f); // static public System.Single Atan(System.Single f) // Offset: 0x1BF4C94 static float Atan(float f); // static public System.Single Atan2(System.Single y, System.Single x) // Offset: 0x1BF4D08 static float Atan2(float y, float x); // static public System.Single Sqrt(System.Single f) // Offset: 0x1BF4D84 static float Sqrt(float f); // static public System.Single Abs(System.Single f) // Offset: 0x1BF4E0C static float Abs(float f); // static public System.Int32 Abs(System.Int32 value) // Offset: 0x1BF4E78 static int Abs(int value); // static public System.Single Min(System.Single a, System.Single b) // Offset: 0x1BF4EE0 static float Min(float a, float b); // static public System.Int32 Min(System.Int32 a, System.Int32 b) // Offset: 0x1BF4EEC static int Min(int a, int b); // static public System.Single Max(System.Single a, System.Single b) // Offset: 0x1BF4EF8 static float Max(float a, float b); // static public System.Single Max(params System.Single[] values) // Offset: 0x1BF4F04 static float Max(::Array<float>* values); // Creating initializer_list -> params proxy for: System.Single Max(params System.Single[] values) static float Max(std::initializer_list<float> values); // Creating TArgs -> initializer_list proxy for: System.Single Max(params System.Single[] values) template<class ...TParams> static float Max(TParams&&... values) { return Max({values...}); } // static public System.Int32 Max(System.Int32 a, System.Int32 b) // Offset: 0x1BF4F58 static int Max(int a, int b); // static public System.Single Pow(System.Single f, System.Single p) // Offset: 0x1BF4F64 static float Pow(float f, float p); // static public System.Single Log(System.Single f, System.Single p) // Offset: 0x1BF4FE4 static float Log(float f, float p); // static public System.Single Log(System.Single f) // Offset: 0x1BF5064 static float Log(float f); // static public System.Single Ceil(System.Single f) // Offset: 0x1BF50D8 static float Ceil(float f); // static public System.Single Floor(System.Single f) // Offset: 0x1BF5144 static float Floor(float f); // static public System.Single Round(System.Single f) // Offset: 0x1BF51B0 static float Round(float f); // static public System.Int32 CeilToInt(System.Single f) // Offset: 0x1BF5288 static int CeilToInt(float f); // static public System.Int32 FloorToInt(System.Single f) // Offset: 0x1BF52F4 static int FloorToInt(float f); // static public System.Int32 RoundToInt(System.Single f) // Offset: 0x1BF5360 static int RoundToInt(float f); // static public System.Single Sign(System.Single f) // Offset: 0x1BF5438 static float Sign(float f); // static public System.Single Clamp(System.Single value, System.Single min, System.Single max) // Offset: 0x1BF544C static float Clamp(float value, float min, float max); // static public System.Int32 Clamp(System.Int32 value, System.Int32 min, System.Int32 max) // Offset: 0x1BF5468 static int Clamp(int value, int min, int max); // static public System.Single Clamp01(System.Single value) // Offset: 0x1BF5484 static float Clamp01(float value); // static public System.Single Lerp(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF54A0 static float Lerp(float a, float b, float t); // static public System.Single LerpUnclamped(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF5538 static float LerpUnclamped(float a, float b, float t); // static public System.Single LerpAngle(System.Single a, System.Single b, System.Single t) // Offset: 0x1BF5548 static float LerpAngle(float a, float b, float t); // static public System.Single MoveTowards(System.Single current, System.Single target, System.Single maxDelta) // Offset: 0x1BF56B0 static float MoveTowards(float current, float target, float maxDelta); // static public System.Boolean Approximately(System.Single a, System.Single b) // Offset: 0x1BF576C static bool Approximately(float a, float b); // static public System.Single SmoothDamp(System.Single current, System.Single target, ref System.Single currentVelocity, System.Single smoothTime) // Offset: 0x1BF581C static float SmoothDamp(float current, float target, float& currentVelocity, float smoothTime); // static public System.Single SmoothDamp(System.Single current, System.Single target, ref System.Single currentVelocity, System.Single smoothTime, System.Single maxSpeed, System.Single deltaTime) // Offset: 0x1BF58C0 static float SmoothDamp(float current, float target, float& currentVelocity, float smoothTime, float maxSpeed, float deltaTime); // static public System.Single Repeat(System.Single t, System.Single length) // Offset: 0x1BF5620 static float Repeat(float t, float length); // static public System.Single InverseLerp(System.Single a, System.Single b, System.Single value) // Offset: 0x1BF5A14 static float InverseLerp(float a, float b, float value); // static public System.Single DeltaAngle(System.Single current, System.Single target) // Offset: 0x1BF5AB8 static float DeltaAngle(float current, float target); // static private System.Void .cctor() // Offset: 0x1BF5B50 static void _cctor(); }; // UnityEngine.Mathf #pragma pack(pop) } #include "extern/beatsaber-hook/shared/utils/il2cpp-type-check.hpp" DEFINE_IL2CPP_ARG_TYPE(UnityEngine::Mathf, "UnityEngine", "Mathf");
47.096045
201
0.691819
darknight1050
d2c7e9ab7e38e29a8a77911dce767c34047af947
11,563
cc
C++
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2021-04-21T06:39:42.000Z
2021-04-21T06:39:42.000Z
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2019-01-20T17:35:23.000Z
2019-01-22T21:41:38.000Z
ns-allinone-2.35/tcp/scoreboard-rh.cc
nitishk017/ns2project
f037b796ff10300ffe0422580be5855c37d0b140
[ "MIT" ]
1
2021-09-29T16:06:57.000Z
2021-09-29T16:06:57.000Z
/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyright (c) 1996 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Network Research * Group at Lawrence Berkeley National Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* 9/96 Pittsburgh Supercomputing Center * UpdateScoreBoard, CheckSndNxt, MarkRetran modified for fack */ #ifndef lint static const char rcsid[] = "@(#) $Header: /cvsroot/nsnam/ns-2/tcp/scoreboard-rh.cc,v 1.2 2000/08/12 21:45:39 sfloyd Exp $ (LBL)"; #endif /* A quick hack version of the scoreboard */ #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <math.h> #include "packet.h" #include "scoreboard-rh.h" #include "tcp.h" #define ASSERT(x) if (!(x)) {printf ("Assert SB failed\n"); exit(1);} #define ASSERT1(x) if (!(x)) {printf ("Assert1 SB (length)\n"); exit(1);} #define SBNI SBN[i%SBSIZE] // last_ack = TCP last ack int ScoreBoardRH::UpdateScoreBoard (int last_ack, hdr_tcp* tcph, int rh_id) { int i, sack_index, sack_left, sack_right; int sack_max = 0; int retran_decr = 0; /* Can't do this, because we need to process out the retran_decr */ #if 0 if (tcph->sa_length() == 0) { // There are no SACK blocks, so clear the scoreboard. this->ClearScoreBoard(); return(0); } #endif /* What we do need to do is not create a scoreboard if we don't need one. */ if ((tcph->sa_length() == 0) && (length_ == 0)) { return(0); } // If there is no scoreboard, create one. if (length_ == 0) { i = last_ack+1; SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; first_ = i%SBSIZE; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } // Advance the left edge of the block. if (SBN[first_].seq_no_ <= last_ack) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<=last_ack; i++) { // Advance the ACK if (SBNI.seq_no_ <= last_ack) { ASSERT(first_ == i%SBSIZE); first_ = (first_+1)%SBSIZE; length_--; ASSERT1(length_ >= 0); SBNI.ack_flag_ = 1; SBNI.sack_flag_ = 1; if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; retran_sacked_ = rh_id; } if (length_==0) break; } } } for (sack_index=0; sack_index < tcph->sa_length(); sack_index++) { sack_left = tcph->sa_left(sack_index); sack_right = tcph->sa_right(sack_index); /* Remember the highest segment SACKed by this packet */ if (sack_right > sack_max) { sack_max = sack_right; } // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_right; i++) { // Check to see if this segment is now covered by the sack block if (SBNI.seq_no_ >= sack_left && SBNI.seq_no_ < sack_right) { if (! SBNI.sack_flag_) { SBNI.sack_flag_ = 1; } if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; retran_sacked_ = rh_id; } } } } /* Now go through the whole scoreboard and update sack_cnt on holes which still exist. */ if (length_ != 0) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_max; i++) { // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.sack_cnt_++; } } } retran_decr += CheckSndNxt(sack_max); return (retran_decr); } int ScoreBoardRH::CheckSndNxt (int sack_max) { int i; int num_lost = 0; if (length_ != 0) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_max; i++) { // Check to see if this segment's snd_nxt_ is now covered by the sack block if (SBNI.retran_ && SBNI.snd_nxt_ < sack_max) { // the packet was lost again SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 1; num_lost++; } } } return (num_lost); } void ScoreBoardRH::ClearScoreBoard() { length_ = 0; } /* * GetNextRetran() returns "-1" if there is no packet that is * not acked and not sacked and not retransmitted. */ int ScoreBoardRH::GetNextRetran() // Returns sequence number of next pkt... { int i; if (length_) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && !SBNI.retran_ && (SBNI.sack_cnt_ >= *numdupacks_)) { return (i); } } } return (-1); } void ScoreBoardRH::MarkRetran (int retran_seqno, int snd_nxt, int rh_id) { SBN[retran_seqno%SBSIZE].retran_ = 1; SBN[retran_seqno%SBSIZE].snd_nxt_ = snd_nxt; SBN[retran_seqno%SBSIZE].rh_id_ = rh_id; retran_occured_ = rh_id; } int ScoreBoardRH::GetFack (int last_ack) { if (length_) { return(SBN[(first_)%SBSIZE].seq_no_+length_-1); } else { return(last_ack); } } int ScoreBoardRH::GetNewHoles () { int i, new_holes=0; for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { // Check to see if this segment is a new hole #if 1 if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && SBNI.sack_cnt_ == 1) { new_holes++; } #else if (!SBNI.ack_flag_ && !SBNI.sack_flag_ && SBNI.sack_cnt_ == *numdupacks_) { new_holes++; } #endif } return (new_holes); } void ScoreBoardRH::TimeoutScoreBoard (int snd_nxt) { int i, sack_right; if (length_ == 0) { // No need to do anything! return; } sack_right = snd_nxt; // Use this to know how far to extend. // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } /* Now go through the whole scoreboard and update sack_cnt on holes; clear retran flag on everything. */ for (i=SBN[(first_)%SBSIZE].seq_no_; i<SBN[(first_)%SBSIZE].seq_no_+length_; i++) { // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = *numdupacks_; // This forces all holes to be retransmitted. } } /* And, finally, check the first segment in case of a renege. */ i=SBN[(first_)%SBSIZE].seq_no_; if (!SBNI.ack_flag_ && SBNI.sack_flag_) { printf ("Renege!!! seqno = %d\n", SBNI.seq_no_); SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = *numdupacks_; // This forces it to be retransmitted. } } #if 0 /* This routine inserts a fake sack block of length num_dupacks, starting at last_ack+1. It is for use during NewReno recovery. */ int ScoreBoardRH::FakeSack (int last_ack, int num_dupacks) { int i, sack_left, sack_right; int retran_decr = 0; // If there is no scoreboard, create one. if (length_ == 0) { i = last_ack+1; SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; first_ = i%SBSIZE; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } // Advance the left edge of the scoreboard. if (SBN[first_].seq_no_ <= last_ack) { for (i=SBN[(first_)%SBSIZE].seq_no_; i<=last_ack; i++) { // Advance the ACK if (SBNI.seq_no_ <= last_ack) { ASSERT(first_ == i%SBSIZE); first_ = (first_+1)%SBSIZE; length_--; ASSERT1(length_ >= 0); SBNI.ack_flag_ = 1; SBNI.sack_flag_ = 1; if (SBNI.retran_) { SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; retran_decr++; } if (length_==0) break; } } /* Now create a new hole in the first position */ i=SBN[(first_)%SBSIZE].seq_no_; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.rh_id_ = 0; SBNI.sack_cnt_ = num_dupacks; } sack_left = last_ack + 1; sack_right = sack_left + num_dupacks - 1; // Create new entries off the right side. if (sack_right > SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_) { // Create new entries for (i = SBN[(first_+length_+SBSIZE-1)%SBSIZE].seq_no_+1; i<sack_right; i++) { SBNI.seq_no_ = i; SBNI.ack_flag_ = 0; SBNI.sack_flag_ = 0; SBNI.retran_ = 0; SBNI.snd_nxt_ = 0; SBNI.sack_cnt_ = 0; SBNI.rh_id_ = 0; length_++; if (length_ >= SBSIZE) { printf ("Error, scoreboard too large (increase SBSIZE for more space)\n"); exit(1); } } } for (i=SBN[(first_)%SBSIZE].seq_no_; i<sack_right; i++) { // Check to see if this segment is now covered by the sack block if (SBNI.seq_no_ >= sack_left && SBNI.seq_no_ < sack_right) { if (! SBNI.sack_flag_) { SBNI.sack_flag_ = 1; } if (SBNI.retran_) { SBNI.retran_ = 0; retran_decr++; } } } /* Now go through the whole scoreboard and update sack_cnt on holes which still exist. In this case the only possible case is the first hole. */ i=SBN[(first_)%SBSIZE].seq_no_; // Check to see if this segment is a hole if (!SBNI.ack_flag_ && !SBNI.sack_flag_) { SBNI.sack_cnt_++; } return (retran_decr); } #endif int ScoreBoardRH::RetranSacked (int rh_id) { return (retran_sacked_ == rh_id); }
26.890698
106
0.653204
nitishk017
d2d4fb3e81870b5007f46b2a23d4511f5b85e1e2
489
hpp
C++
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
sdk/include/xfMdiFrame.hpp
qianxj/XExplorer
00e326da03ffcaa21115a2345275452607c6bab5
[ "MIT" ]
null
null
null
#pragma once #include "xfwin.hpp" namespace Hxsoft{ namespace XFrame { class XFRAME_API xfMdiFrame : public xfWin { public: xfMdiFrame(void); ~xfMdiFrame(void); public: virtual int OnXCommand(LPCTSTR pStrID, class xfControl * pControl); public: HWND m_hMdiClient; public: virtual int AddSheet(xfWin * pWin){return 1;} virtual int SelectSheet(int nIndex){return 1;} virtual int PreSelectSheet(int nIndex){return 1;} public: virtual HWND GetActiveSheet(); }; }}
19.56
69
0.728016
qianxj
d2d51e30449a024b8d8bfe29da811c37a009916a
765
cc
C++
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
1
2018-09-20T08:27:38.000Z
2018-09-20T08:27:38.000Z
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
null
null
null
examples/netcat/NetCat.cc
LeoGale/wood
8eef60cbeb006c732f6eadfd48d917e264bae401
[ "BSD-2-Clause" ]
null
null
null
#include <thread> #include <assert.h> #include <unistd.h> #include <wood/net/EventLoop.hh> int main() { assert(wood::EventLoop::getCurerntEventLoop() == nullptr); wood::EventLoop loop; assert(wood::EventLoop::getCurerntEventLoop() == &loop); std::thread ex([&loop](){ assert(wood::EventLoop::getCurerntEventLoop() == nullptr); sleep(2); for(int i= 0; i < 10; i++) { sleep(1); loop.wake(); } loop.runInLoop([&loop](){ loop.stop(); }); }); loop.loop(); if(ex.joinable()) { ex.join(); } }
21.857143
74
0.418301
LeoGale
d2e1c460f4706588be2c969a3492d31fbb82824f
1,572
cpp
C++
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
linkedList/singleLinkedList/middleElementLinkedList.cpp
hkansal27/15days-code
0ff3c3c55e3b8a96e0d55c6c1e88d1e4122965e1
[ "MIT" ]
null
null
null
// A sample program to find the middle element of the single linked list. // one simple approach is to first find the length of the linked list then again traversal to find the middle element. // second algo is implemented below: #include<iostream> using namespace std; class Node { public: int data; Node * next; }; void pushData(Node ** head_ref, int data ) { Node * temp = new Node(); temp -> data = data; temp -> next = nullptr; Node * current = * head_ref; if(current == nullptr) { *head_ref = temp; } else { while(current -> next != nullptr) { current = current -> next; } current -> next = temp; } } void printList(Node ** head_ref) { Node * current = * head_ref; while (current != nullptr) { cout << current -> data << endl; current = current -> next; } } int findMiddle(Node ** head_ref) { Node * slow_ptr, * fast_ptr; slow_ptr = *head_ref; fast_ptr = *head_ref; while(fast_ptr -> next != nullptr) { slow_ptr = slow_ptr->next; if(fast_ptr -> next -> next != nullptr) { fast_ptr = fast_ptr -> next -> next; } else { fast_ptr = fast_ptr -> next; } } return slow_ptr -> data; } int main() { Node * head = nullptr; pushData(&head, 4); pushData(&head, 5); pushData(&head, 6); pushData(&head, 7); pushData(&head, 8); pushData(&head, 6); printList(&head); cout << "The middle node data is " << findMiddle(&head); return 0; }
20.96
118
0.566158
hkansal27
d2e3e7d318a6cb5b7b7f768f2c37986834e176c9
42,106
cc
C++
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
src/input_handler.cc
nojhan/kakoune
c8156429c4685189e0a6b7bd0f273dc64432db2c
[ "Unlicense" ]
null
null
null
#include "input_handler.hh" #include "window.hh" #include "utf8.hh" #include "user_interface.hh" #include "buffer_manager.hh" #include "register_manager.hh" #include "normal.hh" #include "event_manager.hh" #include "client.hh" #include "color_registry.hh" #include "file.hh" #include "word_db.hh" #include <unordered_map> namespace Kakoune { class InputMode { public: InputMode(InputHandler& input_handler) : m_input_handler(input_handler) {} virtual ~InputMode() {} InputMode(const InputMode&) = delete; InputMode& operator=(const InputMode&) = delete; virtual void on_key(Key key) = 0; virtual void on_replaced() {} Context& context() const { return m_input_handler.context(); } virtual String description() const = 0; virtual KeymapMode keymap_mode() const = 0; using Insertion = InputHandler::Insertion; Insertion& last_insert() { return m_input_handler.m_last_insert; } protected: void reset_normal_mode(); private: InputHandler& m_input_handler; }; namespace InputModes { static constexpr std::chrono::milliseconds idle_timeout{100}; static constexpr std::chrono::milliseconds fs_check_timeout{500}; class Normal : public InputMode { public: Normal(InputHandler& input_handler) : InputMode(input_handler), m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { context().hooks().run_hook("NormalIdle", "", context()); }}, m_fs_check_timer{Clock::now() + fs_check_timeout, [this](Timer& timer) { if (not context().has_client()) return; context().client().check_buffer_fs_timestamp(); timer.set_next_date(Clock::now() + fs_check_timeout); }} { context().hooks().run_hook("NormalBegin", "", context()); } void on_replaced() override { context().hooks().run_hook("NormalEnd", "", context()); } void on_key(Key key) override { if (key.modifiers == Key::Modifiers::None and isdigit(key.key)) m_count = m_count * 10 + key.key - '0'; else { auto it = keymap.find(key); if (it != keymap.end()) it->second(context(), m_count); m_count = 0; } context().hooks().run_hook("NormalKey", key_to_str(key), context()); m_idle_timer.set_next_date(Clock::now() + idle_timeout); } String description() const override { return to_string(context().selections().size()) + (m_count != 0 ? " sel; param=" + to_string(m_count) : " sel"); } KeymapMode keymap_mode() const override { return KeymapMode::Normal; } private: int m_count = 0; Timer m_idle_timer; Timer m_fs_check_timer; }; class LineEditor { public: void handle_key(Key key) { if (key == Key::Left or key == ctrl('b')) { if (m_cursor_pos > 0) --m_cursor_pos; } else if (key == Key::Right or key == ctrl('f')) { if (m_cursor_pos < m_line.char_length()) ++m_cursor_pos; } else if (key == Key::Home) m_cursor_pos = 0; else if (key == Key::End) m_cursor_pos = m_line.char_length(); else if (key == Key::Backspace) { if (m_cursor_pos != 0) { m_line = m_line.substr(0, m_cursor_pos - 1) + m_line.substr(m_cursor_pos); --m_cursor_pos; } } else if (key == Key::Erase) { if (m_cursor_pos != m_line.char_length()) m_line = m_line.substr(0, m_cursor_pos) + m_line.substr(m_cursor_pos+1); } else { m_line = m_line.substr(0, m_cursor_pos) + codepoint_to_str(key.key) + m_line.substr(m_cursor_pos); ++m_cursor_pos; } } void insert(const String& str) { insert_from(m_cursor_pos, str); } void insert_from(CharCount start, const String& str) { kak_assert(start <= m_cursor_pos); m_line = m_line.substr(0, start) + str + m_line.substr(m_cursor_pos); m_cursor_pos = start + str.char_length(); } void reset(String line) { m_line = std::move(line); m_cursor_pos = m_line.char_length(); } const String& line() const { return m_line; } CharCount cursor_pos() const { return m_cursor_pos; } DisplayLine build_display_line() const { kak_assert(m_cursor_pos <= m_line.char_length()); if (m_cursor_pos == m_line.char_length()) return DisplayLine{{ {m_line, get_color("StatusLine")}, {" "_str, get_color("StatusCursor")} }}; else return DisplayLine({ { m_line.substr(0, m_cursor_pos), get_color("StatusLine") }, { m_line.substr(m_cursor_pos, 1), get_color("StatusCursor") }, { m_line.substr(m_cursor_pos+1), get_color("StatusLine") } }); } private: CharCount m_cursor_pos = 0; String m_line; }; class Menu : public InputMode { public: Menu(InputHandler& input_handler, memoryview<String> choices, MenuCallback callback) : InputMode(input_handler), m_callback(callback), m_choices(choices.begin(), choices.end()), m_selected(m_choices.begin()) { if (not context().has_ui()) return; DisplayCoord menu_pos{ context().ui().dimensions().line, 0_char }; context().ui().menu_show(choices, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Prompt); context().ui().menu_select(0); } void on_key(Key key) override { auto match_filter = [this](const String& str) { return boost::regex_match(str.begin(), str.end(), m_filter); }; if (key == ctrl('m')) { if (context().has_ui()) context().ui().menu_hide(); context().print_status(DisplayLine{}); reset_normal_mode(); int selected = m_selected - m_choices.begin(); m_callback(selected, MenuEvent::Validate, context()); return; } else if (key == Key::Escape or key == ctrl('c')) { if (m_edit_filter) { m_edit_filter = false; m_filter = boost::regex(".*"); m_filter_editor.reset(""); context().print_status(DisplayLine{}); } else { if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); int selected = m_selected - m_choices.begin(); m_callback(selected, MenuEvent::Abort, context()); } } else if (key == Key::Down or key == ctrl('i') or key == ctrl('n') or key == 'j') { auto it = std::find_if(m_selected+1, m_choices.end(), match_filter); if (it == m_choices.end()) it = std::find_if(m_choices.begin(), m_selected, match_filter); select(it); } else if (key == Key::Up or key == Key::BackTab or key == ctrl('p') or key == 'k') { ChoiceList::const_reverse_iterator selected(m_selected+1); auto it = std::find_if(selected+1, m_choices.rend(), match_filter); if (it == m_choices.rend()) it = std::find_if(m_choices.rbegin(), selected, match_filter); select(it.base()-1); } else if (key == '/' and not m_edit_filter) { m_edit_filter = true; } else if (m_edit_filter) { m_filter_editor.handle_key(key); auto search = ".*" + m_filter_editor.line() + ".*"; m_filter = boost::regex(search.begin(), search.end()); auto it = std::find_if(m_selected, m_choices.end(), match_filter); if (it == m_choices.end()) it = std::find_if(m_choices.begin(), m_selected, match_filter); select(it); } if (m_edit_filter) { auto display_line = m_filter_editor.build_display_line(); display_line.insert(display_line.begin(), { "filter:"_str, get_color("Prompt") }); context().print_status(display_line); } } String description() const override { return "menu"; } KeymapMode keymap_mode() const override { return KeymapMode::Menu; } private: MenuCallback m_callback; using ChoiceList = std::vector<String>; const ChoiceList m_choices; ChoiceList::const_iterator m_selected; void select(ChoiceList::const_iterator it) { m_selected = it; int selected = m_selected - m_choices.begin(); if (context().has_ui()) context().ui().menu_select(selected); m_callback(selected, MenuEvent::Select, context()); } boost::regex m_filter = boost::regex(".*"); bool m_edit_filter = false; LineEditor m_filter_editor; }; String common_prefix(memoryview<String> strings) { String res; if (strings.empty()) return res; res = strings[0]; for (auto& str : strings) { ByteCount len = std::min(res.length(), str.length()); ByteCount common_len = 0; while (common_len < len and str[common_len] == res[common_len]) ++common_len; if (common_len != res.length()) res = res.substr(0, common_len); } return res; } class Prompt : public InputMode { public: Prompt(InputHandler& input_handler, const String& prompt, ColorPair colors, Completer completer, PromptCallback callback) : InputMode(input_handler), m_prompt(prompt), m_prompt_colors(colors), m_completer(completer), m_callback(callback) { m_history_it = ms_history[m_prompt].end(); if (context().options()["autoshowcompl"].get<bool>()) refresh_completions(CompletionFlags::Fast); display(); } void on_key(Key key) override { std::vector<String>& history = ms_history[m_prompt]; const String& line = m_line_editor.line(); bool showcompl = false; if (m_mode == Mode::InsertReg) { String reg = RegisterManager::instance()[key.key].values(context())[0]; m_line_editor.insert(reg); m_mode = Mode::Default; } else if (key == ctrl('m')) // enter { if (not line.empty()) { std::vector<String>::iterator it; while ((it = find(history, line)) != history.end()) history.erase(it); history.push_back(line); } context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); // call callback after reset_normal_mode so that callback // may change the mode m_callback(line, PromptEvent::Validate, context()); return; } else if (key == Key::Escape or key == ctrl('c')) { context().print_status(DisplayLine{}); if (context().has_ui()) context().ui().menu_hide(); reset_normal_mode(); m_callback(line, PromptEvent::Abort, context()); return; } else if (key == ctrl('r')) { m_mode = Mode::InsertReg; } else if (key == Key::Up or key == ctrl('p')) { if (m_history_it != history.begin()) { if (m_history_it == history.end()) m_prefix = line; auto it = m_history_it; // search for the previous history entry matching typed prefix do { --it; if (prefix_match(*it, m_prefix)) { m_history_it = it; m_line_editor.reset(*it); break; } } while (it != history.begin()); clear_completions(); showcompl = true; } } else if (key == Key::Down or key == ctrl('n')) // next { if (m_history_it != history.end()) { // search for the next history entry matching typed prefix ++m_history_it; while (m_history_it != history.end() and prefix_match(*m_history_it, m_prefix)) ++m_history_it; if (m_history_it != history.end()) m_line_editor.reset(*m_history_it); else m_line_editor.reset(m_prefix); clear_completions(); showcompl = true; } } else if (key == ctrl('i') or key == Key::BackTab) // tab completion { const bool reverse = (key == Key::BackTab); CandidateList& candidates = m_completions.candidates; // first try, we need to ask our completer for completions if (candidates.empty()) { refresh_completions(CompletionFlags::None); if (candidates.empty()) return; } bool did_prefix = false; if (m_current_completion == -1 and context().options()["complete_prefix"].get<bool>()) { const String& line = m_line_editor.line(); CandidateList& candidates = m_completions.candidates; String prefix = common_prefix(candidates); if (m_completions.end - m_completions.start > prefix.length()) prefix = line.substr(m_completions.start, m_completions.end - m_completions.start); if (not prefix.empty()) { auto it = find(candidates, prefix); if (it == candidates.end()) { m_current_completion = candidates.size(); candidates.push_back(prefix); } else m_current_completion = it - candidates.begin(); CharCount start = line.char_count_to(m_completions.start); did_prefix = prefix != line.substr(start, m_line_editor.cursor_pos() - start); } } if (not did_prefix) { if (not reverse and ++m_current_completion >= candidates.size()) m_current_completion = 0; else if (reverse and --m_current_completion < 0) m_current_completion = candidates.size()-1; } const String& completion = candidates[m_current_completion]; if (context().has_ui()) context().ui().menu_select(m_current_completion); m_line_editor.insert_from(line.char_count_to(m_completions.start), completion); // when we have only one completion candidate, make next tab complete // from the new content. if (candidates.size() == 1) { m_current_completion = -1; candidates.clear(); showcompl = true; } } else { m_line_editor.handle_key(key); clear_completions(); showcompl = true; } if (showcompl and context().options()["autoshowcompl"].get<bool>()) refresh_completions(CompletionFlags::Fast); display(); m_callback(line, PromptEvent::Change, context()); } void set_prompt_colors(ColorPair colors) { if (colors != m_prompt_colors) { m_prompt_colors = colors; display(); } } String description() const override { return "prompt"; } KeymapMode keymap_mode() const override { return KeymapMode::Prompt; } private: void refresh_completions(CompletionFlags flags) { try { const String& line = m_line_editor.line(); m_completions = m_completer(context(), flags, line, line.byte_count_to(m_line_editor.cursor_pos())); CandidateList& candidates = m_completions.candidates; if (context().has_ui() and not candidates.empty()) { DisplayCoord menu_pos{ context().ui().dimensions().line, 0_char }; context().ui().menu_show(candidates, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Prompt); } } catch (runtime_error&) {} } void clear_completions() { m_current_completion = -1; if (context().has_ui()) context().ui().menu_hide(); } void display() const { auto display_line = m_line_editor.build_display_line(); display_line.insert(display_line.begin(), { m_prompt, m_prompt_colors }); context().print_status(display_line); } enum class Mode { Default, InsertReg }; PromptCallback m_callback; Completer m_completer; const String m_prompt; ColorPair m_prompt_colors; Completions m_completions; int m_current_completion = -1; String m_prefix; LineEditor m_line_editor; Mode m_mode = Mode::Default; static std::unordered_map<String, std::vector<String>> ms_history; std::vector<String>::iterator m_history_it; }; std::unordered_map<String, std::vector<String>> Prompt::ms_history; class NextKey : public InputMode { public: NextKey(InputHandler& input_handler, KeyCallback callback) : InputMode(input_handler), m_callback(callback) {} void on_key(Key key) override { reset_normal_mode(); m_callback(key, context()); } String description() const override { return "enter key"; } KeymapMode keymap_mode() const override { return KeymapMode::None; } private: KeyCallback m_callback; }; struct BufferCompletion { BufferCoord begin; BufferCoord end; CandidateList candidates; size_t timestamp; bool is_valid() const { return not candidates.empty(); } }; class BufferCompleter : public OptionManagerWatcher_AutoRegister { public: BufferCompleter(const Context& context) : OptionManagerWatcher_AutoRegister(context.options()), m_context(context) {} BufferCompleter(const BufferCompleter&) = delete; BufferCompleter& operator=(const BufferCompleter&) = delete; void select(int offset) { if (not setup_ifn()) return; auto& buffer = m_context.buffer(); m_current_candidate = (m_current_candidate + offset) % (int)m_matching_candidates.size(); if (m_current_candidate < 0) m_current_candidate += m_matching_candidates.size(); const String& candidate = m_matching_candidates[m_current_candidate]; const auto& cursor_pos = m_context.selections().main().cursor(); const auto prefix_len = buffer.distance(m_completions.begin, cursor_pos); const auto suffix_len = std::max(0_byte, buffer.distance(cursor_pos, m_completions.end)); const auto buffer_len = buffer.byte_count(); auto ref = buffer.string(m_completions.begin, m_completions.end); for (auto& sel : m_context.selections()) { auto offset = buffer.offset(sel.cursor()); auto pos = buffer.iterator_at(sel.cursor()); if (offset >= prefix_len and offset + suffix_len < buffer_len and std::equal(ref.begin(), ref.end(), pos - prefix_len)) { pos = buffer.erase(pos - prefix_len, pos + suffix_len); buffer.insert(pos, candidate); } } m_completions.end = cursor_pos; m_completions.begin = buffer.advance(m_completions.end, -candidate.length()); m_completions.timestamp = m_context.buffer().timestamp(); if (m_context.has_ui()) m_context.ui().menu_select(m_current_candidate); // when we select a match, remove non displayed matches from the candidates // which are considered as invalid with the new completion timestamp m_completions.candidates.clear(); std::copy(m_matching_candidates.begin(), m_matching_candidates.end()-1, std::back_inserter(m_completions.candidates)); } void update() { if (m_completions.is_valid()) { ByteCount longest_completion = 0; for (auto& candidate : m_completions.candidates) longest_completion = std::max(longest_completion, candidate.length()); BufferCoord cursor = m_context.selections().main().cursor(); BufferCoord compl_beg = m_completions.begin; if (cursor.line == compl_beg.line and is_in_range(cursor.column - compl_beg.column, ByteCount{0}, longest_completion-1)) { String prefix = m_context.buffer().string(compl_beg, cursor); if (m_context.buffer().timestamp() == m_completions.timestamp) m_matching_candidates = m_completions.candidates; else { m_matching_candidates.clear(); for (auto& candidate : m_completions.candidates) { if (candidate.substr(0, prefix.length()) == prefix) m_matching_candidates.push_back(candidate); } } if (not m_matching_candidates.empty()) { m_current_candidate = m_matching_candidates.size(); m_completions.end = cursor; menu_show(); m_matching_candidates.push_back(prefix); return; } } } reset(); setup_ifn(); } void reset() { m_completions = BufferCompletion{}; if (m_context.has_ui()) m_context.ui().menu_hide(); } template<BufferCompletion (BufferCompleter::*complete_func)(const Buffer&, BufferCoord)> bool try_complete() { auto& buffer = m_context.buffer(); BufferCoord cursor_pos = m_context.selections().main().cursor(); m_completions = (this->*complete_func)(buffer, cursor_pos); if (not m_completions.is_valid()) return false; kak_assert(cursor_pos >= m_completions.begin); m_matching_candidates = m_completions.candidates; m_current_candidate = m_matching_candidates.size(); menu_show(); m_matching_candidates.push_back(buffer.string(m_completions.begin, m_completions.end)); return true; } using StringList = std::vector<String>; static WordDB& get_word_db(const Buffer& buffer) { static const ValueId word_db_id = ValueId::get_free_id(); Value& cache_val = buffer.values()[word_db_id]; if (not cache_val) cache_val = Value(WordDB{buffer}); return cache_val.as<WordDB>(); } template<bool other_buffers> BufferCompletion complete_word(const Buffer& buffer, BufferCoord cursor_pos) { auto pos = buffer.iterator_at(cursor_pos); if (pos == buffer.begin() or not is_word(*utf8::previous(pos))) return {}; auto end = buffer.iterator_at(cursor_pos); auto begin = end-1; while (begin != buffer.begin() and is_word(*begin)) --begin; if (not is_word(*begin)) ++begin; String prefix{begin, end}; std::unordered_set<String> matches; auto bufmatches = get_word_db(buffer).find_prefix(prefix); matches.insert(bufmatches.begin(), bufmatches.end()); if (other_buffers) { for (const auto& buf : BufferManager::instance()) { if (buf.get() == &buffer) continue; bufmatches = get_word_db(*buf).find_prefix(prefix); matches.insert(bufmatches.begin(), bufmatches.end()); } } matches.erase(prefix); CandidateList result; std::copy(make_move_iterator(matches.begin()), make_move_iterator(matches.end()), inserter(result, result.begin())); std::sort(result.begin(), result.end()); return { begin.coord(), end.coord(), std::move(result), buffer.timestamp() }; } BufferCompletion complete_filename(const Buffer& buffer, BufferCoord cursor_pos) { auto pos = buffer.iterator_at(cursor_pos); auto begin = pos; auto is_filename = [](char c) { return isalnum(c) or c == '/' or c == '.' or c == '_' or c == '-'; }; while (begin != buffer.begin() and is_filename(*(begin-1))) --begin; if (begin == pos) return {}; String prefix{begin, pos}; StringList res; if (prefix.front() == '/') res = Kakoune::complete_filename(prefix, Regex{}); else { for (auto dir : options()["path"].get<StringList>()) { if (not dir.empty() and dir.back() != '/') dir += '/'; for (auto& filename : Kakoune::complete_filename(dir + prefix, Regex{})) res.push_back(filename.substr(dir.length())); } } if (res.empty()) return {}; return { begin.coord(), pos.coord(), std::move(res), buffer.timestamp() }; } BufferCompletion complete_option(const Buffer& buffer, BufferCoord cursor_pos) { const StringList& opt = options()["completions"].get<StringList>(); if (opt.empty()) return {}; auto& desc = opt[0]; static const Regex re(R"((\d+)\.(\d+)(?:\+(\d+))?@(\d+))"); boost::smatch match; if (boost::regex_match(desc.begin(), desc.end(), match, re)) { BufferCoord coord{ str_to_int(match[1].str()) - 1, str_to_int(match[2].str()) - 1 }; if (not buffer.is_valid(coord)) return {}; auto end = coord; if (match[3].matched) { ByteCount len = str_to_int(match[3].str()); end = buffer.advance(coord, len); } size_t timestamp = (size_t)str_to_int(match[4].str()); ByteCount longest_completion = 0; for (auto it = opt.begin() + 1; it != opt.end(); ++it) longest_completion = std::max(longest_completion, it->length()); if (timestamp == buffer.timestamp() and cursor_pos.line == coord.line and cursor_pos.column >= coord.column and buffer.distance(coord, cursor_pos) < longest_completion) return { coord, end, { opt.begin() + 1, opt.end() }, timestamp }; } return {}; } BufferCompletion complete_line(const Buffer& buffer, BufferCoord cursor_pos) { String prefix = buffer[cursor_pos.line].substr(0_byte, cursor_pos.column); StringList res; for (LineCount l = 0_line; l < buffer.line_count(); ++l) { if (l == cursor_pos.line) continue; ByteCount len = buffer[l].length(); if (len > cursor_pos.column and std::equal(prefix.begin(), prefix.end(), buffer[l].begin())) res.push_back(buffer[l].substr(0_byte, len-1)); } if (res.empty()) return {}; std::sort(res.begin(), res.end()); res.erase(std::unique(res.begin(), res.end()), res.end()); return { cursor_pos.line, cursor_pos, std::move(res), buffer.timestamp() }; } private: void on_option_changed(const Option& opt) override { if (opt.name() == "completions") { reset(); setup_ifn(); } } void menu_show() { if (not m_context.has_ui()) return; DisplayCoord menu_pos = m_context.window().display_position(m_completions.begin); m_context.ui().menu_show(m_matching_candidates, menu_pos, get_color("MenuForeground"), get_color("MenuBackground"), MenuStyle::Inline); m_context.ui().menu_select(m_current_candidate); } bool setup_ifn() { if (not m_completions.is_valid()) { auto& completers = options()["completers"].get<StringList>(); if (contains(completers, "option") and try_complete<&BufferCompleter::complete_option>()) return true; if (contains(completers, "word=buffer") and try_complete<&BufferCompleter::complete_word<false>>()) return true; if (contains(completers, "word=all") and try_complete<&BufferCompleter::complete_word<true>>()) return true; if (contains(completers, "filename") and try_complete<&BufferCompleter::complete_filename>()) return true; return false; } return true; } const Context& m_context; BufferCompletion m_completions; CandidateList m_matching_candidates; int m_current_candidate = -1; }; class Insert : public InputMode { public: Insert(InputHandler& input_handler, InsertMode mode) : InputMode(input_handler), m_insert_mode(mode), m_edition(context()), m_completer(context()), m_idle_timer{Clock::now() + idle_timeout, [this](Timer& timer) { context().hooks().run_hook("InsertIdle", "", context()); m_completer.update(); }} { last_insert().first = mode; last_insert().second.clear(); context().hooks().run_hook("InsertBegin", "", context()); prepare(m_insert_mode); } void on_key(Key key) override { auto& buffer = context().buffer(); last_insert().second.push_back(key); if (m_mode == Mode::InsertReg) { if (key.modifiers == Key::Modifiers::None) insert(RegisterManager::instance()[key.key].values(context())); m_mode = Mode::Default; return; } if (m_mode == Mode::Complete) { if (key.key == 'f') m_completer.try_complete<&BufferCompleter::complete_filename>(); if (key.key == 'w') m_completer.try_complete<&BufferCompleter::complete_word<true>>(); if (key.key == 'o') m_completer.try_complete<&BufferCompleter::complete_option>(); if (key.key == 'l') m_completer.try_complete<&BufferCompleter::complete_line>(); m_mode = Mode::Default; return; } bool update_completions = true; bool moved = false; if (key == Key::Escape or key == ctrl('c')) { context().hooks().run_hook("InsertEnd", "", context()); m_completer.reset(); reset_normal_mode(); } else if (key == Key::Backspace) { for (auto& sel : context().selections()) { if (sel.cursor() == BufferCoord{0,0}) continue; auto pos = buffer.iterator_at(sel.cursor()); buffer.erase(utf8::previous(pos), pos); } } else if (key == Key::Erase) { for (auto& sel : context().selections()) { auto pos = buffer.iterator_at(sel.cursor()); buffer.erase(pos, utf8::next(pos)); } } else if (key == Key::Left) { move(-1_char); moved = true; } else if (key == Key::Right) { move(1_char); moved = true; } else if (key == Key::Up) { move(-1_line); moved = true; } else if (key == Key::Down) { move(1_line); moved = true; } else if (key.modifiers == Key::Modifiers::None) insert(key.key); else if (key == ctrl('r')) m_mode = Mode::InsertReg; else if ( key == ctrl('m')) insert('\n'); else if ( key == ctrl('i')) insert('\t'); else if ( key == ctrl('n')) { m_completer.select(1); update_completions = false; } else if ( key == ctrl('p')) { m_completer.select(-1); update_completions = false; } else if ( key == ctrl('x')) m_mode = Mode::Complete; else if ( key == ctrl('u')) context().buffer().commit_undo_group(); context().hooks().run_hook("InsertKey", key_to_str(key), context()); if (update_completions) m_idle_timer.set_next_date(Clock::now() + idle_timeout); if (moved) context().hooks().run_hook("InsertMove", key_to_str(key), context()); } String description() const override { return "insert"; } KeymapMode keymap_mode() const override { return KeymapMode::Insert; } private: template<typename Type> void move(Type offset) { auto& selections = context().selections(); for (auto& sel : selections) { auto cursor = context().has_window() ? context().window().offset_coord(sel.cursor(), offset) : context().buffer().offset_coord(sel.cursor(), offset); sel.anchor() = sel.cursor() = cursor; } selections.sort_and_merge_overlapping(); } void insert(memoryview<String> strings) { auto& buffer = context().buffer(); auto& selections = context().selections(); for (size_t i = 0; i < selections.size(); ++i) { size_t index = std::min(i, strings.size()-1); buffer.insert(buffer.iterator_at(selections[i].cursor()), strings[index]); } } void insert(Codepoint key) { auto str = codepoint_to_str(key); auto& buffer = context().buffer(); for (auto& sel : context().selections()) buffer.insert(buffer.iterator_at(sel.cursor()), str); context().hooks().run_hook("InsertChar", str, context()); } void prepare(InsertMode mode) { SelectionList& selections = context().selections(); Buffer& buffer = context().buffer(); for (auto& sel : selections) { BufferCoord anchor, cursor; switch (mode) { case InsertMode::Insert: anchor = sel.max(); cursor = sel.min(); break; case InsertMode::Replace: anchor = cursor = Kakoune::erase(buffer, sel).coord(); break; case InsertMode::Append: anchor = sel.min(); cursor = sel.max(); // special case for end of lines, append to current line instead if (cursor.column != buffer[cursor.line].length() - 1) cursor = buffer.char_next(cursor); break; case InsertMode::OpenLineBelow: case InsertMode::AppendAtLineEnd: anchor = cursor = BufferCoord{sel.max().line, buffer[sel.max().line].length() - 1}; break; case InsertMode::OpenLineAbove: case InsertMode::InsertAtLineBegin: anchor = sel.min().line; if (mode == InsertMode::OpenLineAbove) anchor = buffer.char_prev(anchor); else { auto anchor_non_blank = buffer.iterator_at(anchor); while (*anchor_non_blank == ' ' or *anchor_non_blank == '\t') ++anchor_non_blank; if (*anchor_non_blank != '\n') anchor = anchor_non_blank.coord(); } cursor = anchor; break; case InsertMode::InsertAtNextLineBegin: kak_assert(false); // not implemented break; } if (buffer.is_end(anchor)) anchor = buffer.char_prev(anchor); if (buffer.is_end(cursor)) cursor = buffer.char_prev(cursor); sel.anchor() = anchor; sel.cursor() = cursor; } if (mode == InsertMode::OpenLineBelow or mode == InsertMode::OpenLineAbove) { insert('\n'); if (mode == InsertMode::OpenLineAbove) { for (auto& sel : selections) { // special case, the --first line above did nothing, so we need to compensate now if (sel.anchor() == buffer.char_next({0,0})) sel.anchor() = sel.cursor() = BufferCoord{0,0}; } } } selections.sort_and_merge_overlapping(); selections.check_invariant(); buffer.check_invariant(); } void on_replaced() override { for (auto& sel : context().selections()) { if (m_insert_mode == InsertMode::Append and sel.cursor().column > 0) sel.cursor() = context().buffer().char_prev(sel.cursor()); avoid_eol(context().buffer(), sel); } } enum class Mode { Default, Complete, InsertReg }; Mode m_mode = Mode::Default; InsertMode m_insert_mode; ScopedEdition m_edition; BufferCompleter m_completer; Timer m_idle_timer; }; } void InputMode::reset_normal_mode() { m_input_handler.reset_normal_mode(); } InputHandler::InputHandler(Buffer& buffer, SelectionList selections, String name) : m_mode(new InputModes::Normal(*this)), m_context(*this, buffer, std::move(selections), std::move(name)) { } InputHandler::~InputHandler() {} void InputHandler::change_input_mode(InputMode* new_mode) { m_mode->on_replaced(); m_mode_trash.emplace_back(std::move(m_mode)); m_mode.reset(new_mode); } void InputHandler::insert(InsertMode mode) { change_input_mode(new InputModes::Insert(*this, mode)); } void InputHandler::repeat_last_insert() { if (m_last_insert.second.empty()) return; std::vector<Key> keys; swap(keys, m_last_insert.second); // context.last_insert will be refilled by the new Insert // this is very inefficient. change_input_mode(new InputModes::Insert(*this, m_last_insert.first)); for (auto& key : keys) m_mode->on_key(key); kak_assert(dynamic_cast<InputModes::Normal*>(m_mode.get()) != nullptr); } void InputHandler::prompt(const String& prompt, ColorPair prompt_colors, Completer completer, PromptCallback callback) { change_input_mode(new InputModes::Prompt(*this, prompt, prompt_colors, completer, callback)); } void InputHandler::set_prompt_colors(ColorPair prompt_colors) { InputModes::Prompt* prompt = dynamic_cast<InputModes::Prompt*>(m_mode.get()); if (prompt) prompt->set_prompt_colors(prompt_colors); } void InputHandler::menu(memoryview<String> choices, MenuCallback callback) { change_input_mode(new InputModes::Menu(*this, choices, callback)); } void InputHandler::on_next_key(KeyCallback callback) { change_input_mode(new InputModes::NextKey(*this, callback)); } static bool is_valid(Key key) { return key != Key::Invalid and key.key <= 0x10FFFF; } void InputHandler::handle_key(Key key) { if (is_valid(key)) { const bool was_recording = is_recording(); auto keymap_mode = m_mode->keymap_mode(); KeymapManager& keymaps = m_context.keymaps(); if (keymaps.is_mapped(key, keymap_mode)) { for (auto& k : keymaps.get_mapping(key, keymap_mode)) m_mode->on_key(k); } else m_mode->on_key(key); // do not record the key that made us enter or leave recording mode. if (was_recording and is_recording()) m_recorded_keys += key_to_str(key); } } void InputHandler::start_recording(char reg) { kak_assert(m_recording_reg == 0); m_recorded_keys = ""; m_recording_reg = reg; } bool InputHandler::is_recording() const { return m_recording_reg != 0; } void InputHandler::stop_recording() { kak_assert(m_recording_reg != 0); RegisterManager::instance()[m_recording_reg] = memoryview<String>(m_recorded_keys); m_recording_reg = 0; } void InputHandler::reset_normal_mode() { change_input_mode(new InputModes::Normal(*this)); } String InputHandler::mode_string() const { return m_mode->description(); } void InputHandler::clear_mode_trash() { m_mode_trash.clear(); } }
32.895313
111
0.546074
nojhan
d2e4418179bc5c59c361a7ddae44a46f32e42af6
3,322
cpp
C++
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
slywin32/src/win32/os/window.cpp
Gibbeon/sly
9216cf04a78f1d41af01186489ba6680b9641229
[ "MIT" ]
null
null
null
#include "sly/win32/os/window.h" using namespace sly::os; Win32Window::Win32Window(Win32WindowSystem& parent) : _parent(parent), _initialized(false) { } sly::retval<void> Win32Window::release() { if(_initialized) { setVisible(false); DestroyWindow(_hWND); _hWND = nullptr; _parent.release(*this); _initialized = false; } return success(); } sly::retval<void> Win32Window::init(const WindowDesc& desc) { _width = desc.width; _height = desc.height; _title = desc.title; HINSTANCE hInstance= GetModuleHandle(NULL); // Initialize the window class. WNDCLASSEX windowClass = { 0 }; windowClass.cbSize = sizeof(WNDCLASSEX); windowClass.style = CS_HREDRAW | CS_VREDRAW; windowClass.lpfnWndProc = WindowProc; windowClass.hInstance = hInstance; windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); windowClass.lpszClassName = "Win32Window"; RegisterClassEx(&windowClass); ::RECT windowRect = { 0, 0, static_cast<LONG>(_width), static_cast<LONG>(_height) }; AdjustWindowRect(&windowRect, WS_OVERLAPPED, FALSE); /* _In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam); */ // Create the window and store a handle to it. this->setHwnd(CreateWindowEx( WS_EX_TRANSPARENT, windowClass.lpszClassName, getTitle().c_str(), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, nullptr, // We have no parent window. nullptr, // We aren't using menus. hInstance, this)); //ShowWindow(_hWND, SW_SHOWDEFAULT); _initialized = true; return success(); } bool_t Win32Window::processMessages() { MSG msg = {}; bool_t process = true; while (process) { process = false; // Process any messages in the queue. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); process = true; } } // Return this part of the WM_QUIT message to Windows. return static_cast<char>(msg.wParam); } // Main message handler for the sample. LRESULT CALLBACK Win32Window::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { Win32Window* pSample = reinterpret_cast<Win32Window*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); switch (message) { case WM_CREATE: { // Save the DXSample* passed in to CreateWindow. LPCREATESTRUCT pCreateStruct = reinterpret_cast<LPCREATESTRUCT>(lParam); SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pCreateStruct->lpCreateParams)); } return 0; case WM_PAINT: { ValidateRect(hWnd, NULL); } return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } // Handle any messages the switch statement didn't. return DefWindowProc(hWnd, message, wParam, lParam); }
26.365079
109
0.643287
Gibbeon
5e44a3b5dc5626758232f2c869ca651829479a98
2,339
hpp
C++
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
cs161/assignments/assignment6/helper.hpp
franzmk/Oregon-State-Schoolwork
20f8a72e78ec4baa131add2dda8026cd47f36188
[ "MIT" ]
null
null
null
#include <fstream> #include <string.h> /********************************************************************* ** Program Filename: fileWrite ** Author: Mason Sidebottom ** Date: Feb. 2019 ** Description: Helper functionality for binary file IO *********************************************************************/ class fileWriter { private: std::ofstream file; public: /********************************************************************* ** Function: Constructor ** Description: Sets up writer class ** Parameters: String -> File name ** Pre-Conditions: N/A ** Post-Conditions: osfstream is initialized to be used in output mode, ** with binary output. *********************************************************************/ fileWriter (const char * filename) : file(filename, std::ofstream::out | std::ofstream::binary){} /********************************************************************* ** Function: Destructor ** Description: Closes file ** Pre-Conditions: File is open ** Post-Conditions: File will be closed *********************************************************************/ ~fileWriter () { this->file.close(); } /********************************************************************* ** Function: Write ** Description: Writes a file using binary data, instead of string ** representation. ** Pre-Conditions: File is open *********************************************************************/ template <typename T> void write(const T val){ // Create byte array of with as many bytes in type unsigned char * str = new unsigned char [sizeof(T)]; // Copy contents of memory memcpy(str, &val, sizeof(T)); // Write individual bytes so that all zeros are written for(int i = 0; i < sizeof(T); i++) this->file << str[i]; // Free byte array delete [] str; } /********************************************************************* ** Function: Overloaded stream operator ** Description: Calls write, see above ** Returns: fileWrite &, allows for fW << a < b << c << ... *********************************************************************/ template <typename T> friend fileWriter& operator<<(fileWriter & writer, const T val){ writer.write(val); return writer; } };
33.898551
99
0.446345
franzmk
5e45349a9480f07bc6f22d8abf2101dcea77be4a
2,492
cpp
C++
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
37
2020-01-20T06:21:24.000Z
2022-03-21T17:44:50.000Z
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
null
null
null
src/eepp/audio/soundfilereadermp3.cpp
jayrulez/eepp
09c5c1b6b4c0306bb0a188474778c6949b5df3a7
[ "MIT" ]
9
2019-03-22T00:33:07.000Z
2022-03-01T01:35:59.000Z
#include <eepp/audio/soundfilereadermp3.hpp> #define DR_MP3_IMPLEMENTATION #include <algorithm> #include <cctype> #include <dr_libs/dr_mp3.h> #include <eepp/audio/mp3info.hpp> #include <eepp/core/core.hpp> #include <eepp/system/iostreammemory.hpp> static size_t drmp3_func_read( void* data, void* ptr, size_t size ) { IOStream* stream = static_cast<IOStream*>( data ); return static_cast<std::size_t>( stream->read( (char*)ptr, size ) ); } static drmp3_bool32 drmp3_func_seek( void* data, int offset, drmp3_seek_origin whence ) { IOStream* stream = static_cast<IOStream*>( data ); switch ( whence ) { case drmp3_seek_origin_start: break; case drmp3_seek_origin_current: offset += stream->tell(); break; } stream->seek( offset ); return 1; } namespace EE { namespace Audio { namespace Private { bool SoundFileReaderMp3::check( IOStream& stream ) { return Mp3Info( stream ).isValidMp3(); } SoundFileReaderMp3::SoundFileReaderMp3() : mChannelCount( 0 ), mMp3( NULL ) {} SoundFileReaderMp3::~SoundFileReaderMp3() { close(); } bool SoundFileReaderMp3::open( IOStream& stream, Info& info ) { mMp3 = (drmp3*)eeMalloc( sizeof( drmp3 ) ); // This could be solved with drmp3_get_mp3_frame_count, but our implementation is faster. Mp3Info::Info mp3info = Mp3Info( stream ).getInfo(); stream.seek( 0 ); if ( drmp3_init( mMp3, drmp3_func_read, drmp3_func_seek, &stream, NULL ) ) { info.channelCount = mChannelCount = mMp3->channels; info.sampleRate = mMp3->sampleRate; info.sampleCount = mp3info.frames * DRMP3_MAX_SAMPLES_PER_FRAME; return true; } eeSAFE_FREE( mMp3 ); return false; } void SoundFileReaderMp3::seek( Uint64 sampleOffset ) { if ( mMp3 ) { drmp3_seek_to_pcm_frame( mMp3, sampleOffset / mChannelCount ); } } Uint64 SoundFileReaderMp3::read( Int16* samples, Uint64 maxCount ) { eeASSERT( mMp3 ); Uint64 count = 0; while ( count < maxCount ) { const int samplesToRead = static_cast<int>( maxCount - count ); int frames = samplesToRead / mChannelCount; long framesRead = drmp3_read_pcm_frames_s16( mMp3, frames, samples ); if ( framesRead > 0 ) { long samplesRead = framesRead * mChannelCount; count += samplesRead; samples += samplesRead; if ( framesRead != frames ) break; } else { // error or end of file break; } } return count; } void SoundFileReaderMp3::close() { if ( mMp3 ) { drmp3_uninit( mMp3 ); eeSAFE_FREE( mMp3 ); mChannelCount = 0; } } }}} // namespace EE::Audio::Private
25.171717
90
0.708668
jayrulez
5e4be236582911556188763659fd9ab7a5b5e7fd
534
cpp
C++
Upsolving/URI/2172.cpp
rodrigoAMF7/Notebook---Maratonas
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
4
2019-01-25T21:22:55.000Z
2019-03-20T18:04:01.000Z
Upsolving/URI/2172.cpp
rodrigoAMF/competitive-programming-notebook
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
null
null
null
Upsolving/URI/2172.cpp
rodrigoAMF/competitive-programming-notebook
06b38197a042bfbd27b20f707493e0a19fda7234
[ "MIT" ]
null
null
null
#include <bits/stdc++.h> #define INF 0x3F3F3F3F #define LINF 0x3F3F3F3F3F3F3F3FLL #define DINF (double)1e+30 #define forn(i, n) for ( int i = 0; i < (n); ++i ) #define forxn(i, x, n) for ( int i = (x); i < (n); ++i ) #define forr(i, a, b) for ( int i = (a); i <= (b); ++i ) #define ford(i, a, b) for ( int i = (a); i >= (b); −−i ) using namespace std; int main(){ long long int x, m, resultado; while(true){ cin >> x >> m; if(x == m && x == 0) break; resultado = x*m; cout << resultado << endl; } return 0; }
19.071429
56
0.537453
rodrigoAMF7
5e516da768c2054897032efed128b7565b103cd1
401
cpp
C++
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
3
2018-04-05T04:04:17.000Z
2021-02-01T17:50:01.000Z
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
null
null
null
third_party/common/src/RE/GameSettingCollection.cpp
qis/alchemy
fe6897fa8c065eccc49b61c8c82eda223d865d51
[ "0BSD" ]
1
2021-02-01T17:50:03.000Z
2021-02-01T17:50:03.000Z
#include "RE/GameSettingCollection.h" #include "RE/Offsets.h" #include "REL/Relocation.h" namespace RE { GameSettingCollection* GameSettingCollection::GetSingleton() { REL::Offset<GameSettingCollection**> singleton(Offset::GameSettingCollection::Singleton); return *singleton; } Setting* GameSettingCollection::GetSetting(const char* a_name) { return settings.find(a_name).first; } }
19.095238
91
0.763092
qis
5e52823b75293ea1aaa1aa4fc7f759592ab0df80
7,217
cpp
C++
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
2,113
2015-01-01T11:23:01.000Z
2022-03-28T04:51:46.000Z
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
948
2015-01-02T01:50:00.000Z
2022-02-27T05:56:40.000Z
Engine/source/afx/xm/afxXM_Aim.cpp
vbillet/Torque3D
ece8823599424ea675e5f79d9bcb44e42cba8cae
[ "MIT" ]
944
2015-01-01T09:33:53.000Z
2022-03-15T22:23:03.000Z
//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// // Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames // Copyright (C) 2015 Faust Logic, Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// #include "afx/arcaneFX.h" #include "math/mathUtils.h" #include "afx/afxEffectWrapper.h" #include "afx/afxChoreographer.h" #include "afx/xm/afxXfmMod.h" //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// class afxXM_AimData : public afxXM_WeightedBaseData { typedef afxXM_WeightedBaseData Parent; public: bool aim_z_only; public: /*C*/ afxXM_AimData(); /*C*/ afxXM_AimData(const afxXM_AimData&, bool = false); void packData(BitStream* stream); void unpackData(BitStream* stream); virtual bool allowSubstitutions() const { return true; } static void initPersistFields(); afxXM_Base* create(afxEffectWrapper* fx, bool on_server); DECLARE_CONOBJECT(afxXM_AimData); DECLARE_CATEGORY("AFX"); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxConstraint; class afxXM_Aim_weighted : public afxXM_WeightedBase { typedef afxXM_WeightedBase Parent; public: /*C*/ afxXM_Aim_weighted(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_weighted_z : public afxXM_WeightedBase { typedef afxXM_WeightedBase Parent; public: /*C*/ afxXM_Aim_weighted_z(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_fixed : public afxXM_Base { typedef afxXM_Base Parent; public: /*C*/ afxXM_Aim_fixed(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// class afxXM_Aim_fixed_z : public afxXM_Base { typedef afxXM_Base Parent; public: /*C*/ afxXM_Aim_fixed_z(afxXM_AimData*, afxEffectWrapper*); virtual void updateParams(F32 dt, F32 elapsed, afxXM_Params& params); }; //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~// IMPLEMENT_CO_DATABLOCK_V1(afxXM_AimData); ConsoleDocClass( afxXM_AimData, "@brief An xmod datablock.\n\n" "@ingroup afxXMods\n" "@ingroup AFX\n" "@ingroup Datablocks\n" ); afxXM_AimData::afxXM_AimData() { aim_z_only = false; } afxXM_AimData::afxXM_AimData(const afxXM_AimData& other, bool temp_clone) : afxXM_WeightedBaseData(other, temp_clone) { aim_z_only = other.aim_z_only; } void afxXM_AimData::initPersistFields() { addField("aimZOnly", TypeBool, Offset(aim_z_only, afxXM_AimData), "..."); Parent::initPersistFields(); } void afxXM_AimData::packData(BitStream* stream) { Parent::packData(stream); stream->writeFlag(aim_z_only); } void afxXM_AimData::unpackData(BitStream* stream) { Parent::unpackData(stream); aim_z_only = stream->readFlag(); } afxXM_Base* afxXM_AimData::create(afxEffectWrapper* fx, bool on_server) { afxXM_AimData* datablock = this; if (getSubstitutionCount() > 0) { datablock = new afxXM_AimData(*this, true); this->performSubstitutions(datablock, fx->getChoreographer(), fx->getGroupIndex()); } if (datablock->aim_z_only) { if (datablock->hasFixedWeight()) return new afxXM_Aim_fixed_z(datablock, fx); else return new afxXM_Aim_weighted_z(datablock, fx); } else { if (datablock->hasFixedWeight()) return new afxXM_Aim_fixed(datablock, fx); else return new afxXM_Aim_weighted(datablock, fx); } } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_weighted::afxXM_Aim_weighted(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_WeightedBase(db, fxw) { } void afxXM_Aim_weighted::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { VectorF line_of_sight = params.pos2 - params.pos; line_of_sight.normalize(); F32 wt_factor = calc_weight_factor(elapsed); QuatF qt_ori_incoming(params.ori); MatrixF ori_outgoing = MathUtils::createOrientFromDir(line_of_sight); QuatF qt_ori_outgoing(ori_outgoing); QuatF qt_ori = qt_ori_incoming.slerp(qt_ori_outgoing, wt_factor); qt_ori.setMatrix(&params.ori); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_weighted_z::afxXM_Aim_weighted_z(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_WeightedBase(db, fxw) { } void afxXM_Aim_weighted_z::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { Point3F aim_at_pos = params.pos2; aim_at_pos.z = params.pos.z; VectorF line_of_sight = aim_at_pos - params.pos; line_of_sight.normalize(); F32 wt_factor = calc_weight_factor(elapsed); QuatF qt_ori_incoming(params.ori); MatrixF ori_outgoing = MathUtils::createOrientFromDir(line_of_sight); QuatF qt_ori_outgoing( ori_outgoing ); QuatF qt_ori = qt_ori_incoming.slerp(qt_ori_outgoing, wt_factor); qt_ori.setMatrix(&params.ori); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_fixed::afxXM_Aim_fixed(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_Base(db, fxw) { } void afxXM_Aim_fixed::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { VectorF line_of_sight = params.pos2 - params.pos; line_of_sight.normalize(); params.ori = MathUtils::createOrientFromDir(line_of_sight); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~// afxXM_Aim_fixed_z::afxXM_Aim_fixed_z(afxXM_AimData* db, afxEffectWrapper* fxw) : afxXM_Base(db, fxw) { } void afxXM_Aim_fixed_z::updateParams(F32 dt, F32 elapsed, afxXM_Params& params) { Point3F aim_at_pos = params.pos2; aim_at_pos.z = params.pos.z; VectorF line_of_sight = aim_at_pos - params.pos; line_of_sight.normalize(); params.ori = MathUtils::createOrientFromDir(line_of_sight); } //~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
27.651341
117
0.65221
vbillet
5e536b2583624ff446f0da1baa8400a0d00529de
1,431
cpp
C++
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
usaco12.cpp
versionwen/ACM
7be6de3f7b563cac927b5f84fff97864eb0b9d37
[ "Apache-2.0" ]
null
null
null
/* ID: scwswx2 LANG: C++ PROG: crypt1 */ /*#include <iostream> #include <fstream> #include <string> #include <cstring> #include <map> #include <cstdio> #include <algorithm> using namespace std; int table[10]; int check ( int x ) { while (x) { if (!table[x%10]){ return 1; } x = x/10; } return 0; } int main() { int sum=0,n,t; freopen("crypt1.in","r",stdin); freopen("crypt1.out","w",stdout); scanf("%d",&n); for ( int i = 0;i < n;i++ ) { scanf("%d",&t); table[t] = 1; } for ( int i = 100;i < 1000;i++ ) { if ( check(i)) continue; for ( int j = 10;j < 100;j++ ) { int m = i*j; if ( m>9999 ) break; if ( check(j)||check(m)) continue; int fm = (j%10)*i; if ( fm<100||fm>=1000 ) continue; int sm = (j/10)*i; if ( sm<100||sm>=1000 ) continue; if ( check(sm)||check(fm) ) continue; sum++; } } cout<<sum<<endl; return 0; } */
21.681818
48
0.331936
versionwen
5e550339af045cd98886f1befda646e1558b2523
6,359
cpp
C++
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
52
2015-01-13T05:17:23.000Z
2021-05-09T14:09:39.000Z
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
7
2015-01-12T10:25:14.000Z
2018-09-18T12:34:15.000Z
libs/ram/Core/ramGlobal.cpp
YCAMInterlab/RAMDanceToolkit
5db15135f4ad6f6a9116610b909df99036f74797
[ "Apache-2.0" ]
31
2015-01-12T06:39:15.000Z
2020-04-06T07:05:08.000Z
// // ramGlobal.cpp - RAMDanceToolkit // // Copyright 2012-2013 YCAM InterLab, Yoshito Onishi, Satoru Higa, Motoi Shimizu, and Kyle McDonald // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "ramGlobal.h" #include "ramSimpleShadow.h" #include "ramPhysics.h" #include "ramControlPanel.h" #include "ramSceneManager.h" static ramSimpleShadow ram_simple_shadow; ramActorManager& ramGlobalShortcut::getActorManager() { return ramActorManager::instance(); } const ramActorManager& ramGlobalShortcut::getActorManager() const { return ramActorManager::instance(); } ramCommunicationManager& ramGlobalShortcut::getCommunicationManager() { return ramCommunicationManager::instance(); } const ramCommunicationManager& ramGlobalShortcut::getCommunicationManager() const { return ramCommunicationManager::instance(); } ramOscManager& ramGlobalShortcut::getOscManager() {return ramOscManager::instance(); } const ramOscManager& ramGlobalShortcut::getOscManager() const {return ramOscManager::instance(); } const vector<string>& ramGlobalShortcut::getNodeArrayNames() const { return ramActorManager::instance().getNodeArrayNames(); } bool ramGlobalShortcut::hasNodeArray(const string &key) const { return ramActorManager::instance().hasNodeArray(key); } ramNodeArray& ramGlobalShortcut::getNodeArray(const string &name) { return ramActorManager::instance().getNodeArray(name); } const ramNodeArray& ramGlobalShortcut::getNodeArray(const string &name) const { return ramActorManager::instance().getNodeArray(name); } size_t ramGlobalShortcut::getNumNodeArray() const { return ramActorManager::instance().getNumNodeArray(); } ramNodeArray& ramGlobalShortcut::getNodeArray(int index) { return ramActorManager::instance().getNodeArray(index); } const ramNodeArray& ramGlobalShortcut::getNodeArray(int index) const { return ramActorManager::instance().getNodeArray(index); } vector<ramNodeArray> ramGlobalShortcut::getAllNodeArrays() const { return ramActorManager::instance().getAllNodeArrays(); } ramCameraManager& ramGlobalShortcut::getCameraManager() { return ramCameraManager::instance(); } ofCamera& ramGlobalShortcut::getActiveCamera() { return ramCameraManager::instance().getActiveCamera(); } //ramSceneManager& ramGlobalShortcut::getSceneManager() { return ramSceneManager::instance(); } #pragma mark - core void ramInitialize(int oscPort, bool usePresetScenes) { static bool inited = false; if (inited) return; inited = true; ram_simple_shadow.setup(); ramOscManager::instance().setup(oscPort); ramActorManager::instance().setup(); ramActorManager::instance().setupOscReceiver(&ramOscManager::instance()); ramSceneManager::instance().setup(); ramPhysics::instance(); ramGetGUI().setup(usePresetScenes); ramCommunicationManager::instance().setup(&ramOscManager::instance()); } string ramToResourcePath(const string& path) { string base_path = "resources"; bool dirExists = false; const int maxDepth = 5; for (int i=0; i<maxDepth; i++) { ofDirectory dir(base_path); if (dir.exists()) { dirExists = true; break; } string tmpPath = ofToDataPath(base_path); ofDirectory dirFromDataPath(tmpPath); if (dirFromDataPath.exists()) { base_path = tmpPath; dirExists = true; break; } base_path = "../" + base_path; } if (!dirExists) { ofLogError() << "resources folder dosen't found"; } return ofFilePath::join(base_path, path); } #pragma mark - actors void ramEnableShowActors(bool v) { ramSceneManager::instance().setShowAllActors(v); } bool ramShowActorsEnabled() { return ramSceneManager::instance().getShowAllActors(); } ramNode _evilNode; const ramNode& ramGetNode(unsigned int actorId, unsigned int jointId){ const int numNA = ramActorManager::instance().getNumNodeArray(); // if the actor does not exist... if (!(0 < numNA) || (numNA-1 <= actorId)) { ofLogError("getRamNode()") << "the actor id " << actorId << " is not found. retruned evil node."; return _evilNode; } ramNodeArray &NA = ramActorManager::instance().getNodeArray(actorId); // if the joint does not exist... if (NA.getNumNode() >= jointId) { ofLogError("getRamNode()") << "the joint id " << jointId << " is greater than " << NA.getName() << "'s number of joints. retruned evil node."; return _evilNode; } return NA.getNode(jointId); } #pragma mark - camera static ofRectangle _viewport; void ramSetViewPort(ofRectangle viewport) { _viewport = viewport; } ofRectangle ramGetViewPort() { return _viewport; } void ramBeginCamera(ofRectangle viewport) { ofRectangle v = viewport; if (v.isEmpty()) v = ofGetCurrentViewport(); ramCameraManager::instance().getActiveCamera().begin(v); } void ramEndCamera() { ramCameraManager::instance().getActiveCamera().end(); } void ramEnableInteractiveCamera(bool v) { ramCameraManager::instance().setEnableInteractiveCamera(v); } #pragma mark - shadows void ramEnableShadow(bool v) { ram_simple_shadow.setEnable(v); } void ramDisableShadow() { ram_simple_shadow.setEnable(false); } bool ramShadowEnabled() { return ram_simple_shadow.getEnable(); } void ramBeginShadow() { ram_simple_shadow.begin(); } void ramEndShadow() { ram_simple_shadow.end(); } void ramSetShadowAlpha(float alpha) { ram_simple_shadow.setShadowAlpha(alpha); } #pragma mark - physics static bool ram_enable_physics_primitive = true; void ramEnablePhysicsPrimitive(bool v) { ram_enable_physics_primitive = v; } void ramDisablePhysicsPrimitive() { ram_enable_physics_primitive = false; } bool ramGetEnablePhysicsPrimitive() { return ram_enable_physics_primitive; } #pragma mark - error void ramNotImplementedError() { ofLogWarning("RAM Dance Toolkit") << "not implemented yet"; }
26.831224
144
0.736122
YCAMInterlab
5e577f7f085c0266f90064f9f4c9d7376fcfdfd6
1,654
cpp
C++
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
src/core/subsystem/gamelogic/SSTerrainFollow.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
/************************************************** Copyright 2015 Ola Enberg ***************************************************/ #include "SSTerrainFollow.h" #include <gfx/GraphicsEngine.h> #include "../../datadriven/DenseComponentCollection.h" #include "../../component/PlacementComponent.h" #include "../../component/TerrainFollowComponent.h" #include "../../datadriven/EntityManager.h" SSTerrainFollow& SSTerrainFollow::GetInstance() { static SSTerrainFollow instance; return instance; } void SSTerrainFollow::Startup() { Subsystem::Startup(); } void SSTerrainFollow::UpdateUserLayer( const float deltaTime ) { EntityMask placementFlag = DenseComponentCollection<PlacementComponent>::GetInstance().GetComponentTypeFlag(); EntityMask terrainFollowFlag = DenseComponentCollection<TerrainFollowComponent>::GetInstance().GetComponentTypeFlag(); EntityMask combinedFlag = placementFlag | terrainFollowFlag; int entityID = 0; for ( auto& entityMask : EntityManager::GetInstance().GetEntityMasks() ) { // Check if entity has a placement component if ( ( entityMask & combinedFlag ) == combinedFlag ) { PlacementComponent* placementComponent = GetDenseComponent<PlacementComponent>( entityID ); TerrainFollowComponent* terrainFollowComponent = GetDenseComponent<TerrainFollowComponent>( entityID ); float addedHeight = terrainFollowComponent->Offset * placementComponent->Scale.y; placementComponent->Position.y = gfx::g_GFXTerrain.GetHeightAtWorldCoord(placementComponent->Position.x, placementComponent->Position.z) + addedHeight + 0.2f; } entityID++; } } void SSTerrainFollow::Shutdown() { Subsystem::Shutdown(); }
34.458333
161
0.729746
Robograde
5e58d9b177591bf633607aa836258e0d2e4d6e4b
1,053
hpp
C++
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
src/include/operators/crossover.hpp
AndrSar/ga
0185ed52a7b71e64f5f7cfd8dd0187663d70f5f6
[ "BSL-1.0" ]
null
null
null
#pragma once #include "../detail/detail.hpp" #include "../random_generator.hpp" #include <vector> namespace ga { namespace operators { template <class GenotypeModel> class crossover { public: using genotype = typename GenotypeModel::representation; using gene_value_type = typename GenotypeModel::value_type; public: virtual std::pair<genotype, genotype> apply(const genotype &a, const genotype &b) = 0; ~crossover() {} }; template <class GenotypeModel> class one_point_crossover : public crossover<GenotypeModel> { public: using genotype = typename GenotypeModel::representation; using gene_value_type = typename GenotypeModel::value_type; public: std::pair<genotype, genotype> apply(const genotype &a, const genotype &b) override { const std::size_t point_index = rg.generate(std::uniform_int_distribution<unsigned long>(1, a.size() - 2)); return detail::one_point_crossover(a, b, point_index); } private: random_generator rg; }; } //namespace operators } //namespace ga
21.489796
90
0.717949
AndrSar
5e58dc866b936d77cffbf8f319d51d0d453bf584
13,351
cpp
C++
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
30
2020-09-16T17:39:36.000Z
2022-02-17T08:32:53.000Z
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
7
2020-11-23T14:37:15.000Z
2022-01-17T11:35:32.000Z
binding/Python/interactive/src/Rivet/DockingManager.cpp
Fabrice-Praxinos/ULIS
232ad5c0804da1202d8231fda67ff4aea70f57ef
[ "RSA-MD" ]
5
2020-09-17T00:39:14.000Z
2021-08-30T16:14:07.000Z
// IDDN FR.001.250001.004.S.X.2019.000.00000 // ULIS is subject to copyright laws and is the legal and intellectual property of Praxinos,Inc /* * ULIS *__________________ * @file DockingManager.cpp * @author Clement Berthaud * @brief pyULIS_Interactive application for testing pyULIS. * @copyright Copyright 2018-2021 Praxinos, Inc. All Rights Reserved. * @license Please refer to LICENSE.md */ #include "DockingManager.h" #include "Tab.h" #include "TabArea.h" #include "GeometryUtils.h" #include "WinExtras.h" #include <QApplication> #include <QShortcut> #include <QEvent> #include <QMouseEvent> #include <assert.h> //////////////////////////////////////////////////////////////////////////////////////// //// STATIC TOOLS //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------- Static functions & tools for sorting struct FZOrderingPair { int zOrder; FTabArea* area; }; // Struct for ordering and selecting area while dragging struct FElligibleArea { FTabArea* mArea; QRegion mRegion; }; static bool SortZ( const FZOrderingPair& iA, const FZOrderingPair& iB ) { return iA.zOrder < iB.zOrder; } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE CONSTRUCTION //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //----------------------------------------------------------- Construction / Destruction FDockingManager::~FDockingManager() { } FDockingManager::FDockingManager() : mCurrentDraggingTab( NULL ), mCurrentTargetArea( NULL ), mLastLiftedFrom( NULL ) { } //////////////////////////////////////////////////////////////////////////////////////// //// PUBLIC SINGLETON API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------------------------- Singleton Accessor // static FDockingManager* FDockingManager::DockingManager() { static FDockingManager* sgDockingManager = 0; if( !sgDockingManager ) sgDockingManager = new FDockingManager(); return sgDockingManager; } //////////////////////////////////////////////////////////////////////////////////////// //// INFO API //// //////////////////////////////////////////////////////////////////////////////////////// FTab* FDockingManager::CurrentDraggingTab() const { return mCurrentDraggingTab; } FTabArea* FDockingManager::CurrentTargetArea() const { return mCurrentTargetArea; } void FDockingManager::SetLastLiftedFrom( FTabArea* iValue ) { mLastLiftedFrom = iValue; } FTabArea* FDockingManager::GetLastLiftedFrom() const { return mLastLiftedFrom; } //////////////////////////////////////////////////////////////////////////////////////// //// REGISTER API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //---------------------------------------------- Public Register API for Tabs & TabAreas void FDockingManager::RegisterTabArea( FTabArea* iTabArea ) { mTabAreaList.append( iTabArea ); } void FDockingManager::UnregisterTabArea( FTabArea* iTabArea ) { mTabAreaList.removeAll( iTabArea ); } void FDockingManager::RegisterTab( FTab* iTab ) { InitConnectionsForTab( iTab ); } void FDockingManager::UnregisterTab( FTab* iTab ) { DestroyConnectionsForTab( iTab ); } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE SIGNAL SLOTS API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //-------------------------------------------------------------- Docking Interface Slots void FDockingManager::TabLifted( FTab* iTab ) { // Processing directly after the signal was emitted // Hook the dragging tab mCurrentDraggingTab = iTab; mCurrentDraggingTab->installEventFilter( this ); // Make it Indie iTab->setParent(0); iTab->setWindowFlags( Qt::FramelessWindowHint | Qt::SubWindow ); iTab->show(); iTab->raise(); } void FDockingManager::TabDropped( FTab* iTab ) { assert( iTab == mCurrentDraggingTab ); mCurrentDraggingTab->removeEventFilter( this ); if( !mCurrentTargetArea ) { //emit TabDroppedOutisde( mCurrentDraggingTab ); auto fctptr = mCurrentDraggingTab->GetOnTabDroppedOutCB(); if( fctptr ) fctptr( mCurrentDraggingTab, mLastLiftedFrom ); } //mCurrentTargetArea = NULL; //mCurrentDraggingTab = NULL; } //////////////////////////////////////////////////////////////////////////////////////// //// PRIVATE API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //------------------------------------------------------------------ Qt Events overrides bool FDockingManager::eventFilter( QObject* obj, QEvent* event ) { // We process only mouse events of the current dragging tab. { FTab* tab = dynamic_cast< FTab* >( obj ); if( !tab ) // return false means process the event normally instead return false; assert( tab->Dragging() ); assert( tab == mCurrentDraggingTab ); } // This part allows us to cancel the dragging in case an unexpected event occured { auto eType = event->type(); if( eType == QEvent::FocusOut || eType == QEvent::Leave || eType == QEvent::HoverLeave || eType == QEvent::ContextMenu || eType == QEvent::Drop || eType == QEvent::NonClientAreaMouseButtonRelease ) { mCurrentDraggingTab->FinishDrag(); // cancel drag will emit the necessary signals to remove the event filter. event->ignore(); // explicit ignore, not sure about the effect of this. return true; // return true cancels any further event propagation & computation. } } // Actual eventFilter behaviour starts here // We process only mouse events ( most likely move events ) QMouseEvent* mouseEvent = dynamic_cast< QMouseEvent* >( event ); if( !mouseEvent ) return false; // return false means process the event normally instead // Positionning // Position of the mouse at the time of event, see also QCursor::pos() QPoint cpos = mouseEvent->globalPos(); QRect tabRec = mCurrentDraggingTab->geometry(); // Mouse Snapping when close to the Area that has been targeted. if( mCurrentTargetArea ) { QPoint globalSnap = mCurrentTargetArea->mapToGlobal(QPoint(0,0)); int h2 = mCurrentTargetArea->height() / 2; int threshold = 10; if( abs( globalSnap.y() + h2 - mouseEvent->globalPos().y() ) < threshold ) mCurrentDraggingTab->move( cpos.x() - mCurrentDraggingTab->DragShift().x(), globalSnap.y()); else mCurrentDraggingTab->move( cpos - mCurrentDraggingTab->DragShift()); } else { mCurrentDraggingTab->move( cpos - mCurrentDraggingTab->DragShift()); } // Selecting target area FTabArea* resultArea = NULL; QVector< FElligibleArea > elligibleVector; for( FTabArea* area : mTabAreaList ) { // Reset tabAreas hooks before processing the new one // This is safe to do even if there is none mCurrentDraggingTab->removeEventFilter( area ); QObject::disconnect( mCurrentDraggingTab, SIGNAL( Dropped( FTab* ) ), area, SLOT( ForeignTabDropped( FTab* ) ) ); // Computing global Region for ech tabArea /* QRegion region = area->visibleRegion().translated( area->mapToGlobal( QPoint( 0, 0 ) ) ); QRect debug = region.boundingRect(); QRect debug2 = area->geometry(); */ QRect region = MapRectToGlobal( area->parentWidget(), area->geometry() ); // If there is no intersection that means the area is not elligible // It can mean the area lost track of the tab so we proceed to a reorder if( !region.intersects( tabRec ) ) { continue; } // If we arrive here, the tabArea is elligible so we push it for further processing elligibleVector.push_back( FElligibleArea( { area, region } ) ); } switch( elligibleVector.count() ) { case 0: { resultArea = NULL; break; } case 1: { resultArea = elligibleVector[0].mArea; break; } default: { // The current dragging tab is overlapping more than one area QVector< FElligibleArea > overlappingCursorSelection; bool therAreOverlaping = false; for( FElligibleArea m : elligibleVector ) { // We chose the ones that contains the mouse cursor position if( m.mRegion.contains( cpos ) ) { overlappingCursorSelection.append( m ); therAreOverlaping = true; } } if( therAreOverlaping ) { // If there is at least one region that contains the cursor position, we select the topmost in overlappingCursorSelection QVector< FZOrderingPair > orderingVector; for( FElligibleArea m : overlappingCursorSelection ) orderingVector.append( FZOrderingPair{ GetZOrder( (HWND)m.mArea->topLevelWidget()->winId() ), m.mArea } ); qSort( orderingVector.begin(), orderingVector.end(), SortZ ); resultArea = orderingVector[0].area; } else { // Otherwise: overlapping more than one area but cursor is not in any of them, we select the topmost in elligible QVector< FZOrderingPair > orderingVector; for( FElligibleArea m : elligibleVector ) orderingVector.append( FZOrderingPair{ GetZOrder( (HWND)m.mArea->topLevelWidget()->winId() ), m.mArea } ); qSort( orderingVector.begin(), orderingVector.end(), SortZ ); resultArea = orderingVector[0].area; } } // !default } // !switch // Reject if not tag if( resultArea && resultArea->GetTag() != mCurrentDraggingTab->GetTag() ) return false; // Reorder leaving target area if( resultArea != mCurrentTargetArea && mCurrentTargetArea != NULL ) mCurrentTargetArea->Recompose(); // Can be set to NULL mCurrentTargetArea = resultArea; if( resultArea ) { mCurrentDraggingTab->installEventFilter( resultArea ); QObject::connect( mCurrentDraggingTab, SIGNAL( Dropped( FTab* ) ), resultArea, SLOT( ForeignTabDropped( FTab* ) ) ); resultArea->SetCandidateTab( mCurrentDraggingTab ); } for( FTabArea* area : mTabAreaList ) if( area != resultArea ) area->SetCandidateTab( NULL ); return false; } //-------------------------------------------------------------------------------------- //--------------------------------------------------------- Private Connection Interface void FDockingManager::InitConnectionsForTab( FTab* iTab ) { QObject::connect( iTab, SIGNAL( Lifted( FTab* ) ), this, SLOT( TabLifted( FTab* ) ) ); QObject::connect( iTab, SIGNAL( Dropped( FTab* ) ), this, SLOT( TabDropped( FTab* ) ) ); } void FDockingManager::DestroyConnectionsForTab( FTab* iTab ) { QObject::disconnect( iTab, SIGNAL( Lifted( FTab* ) ), this, SLOT( TabLifted( FTab* ) ) ); QObject::disconnect( iTab, SIGNAL( Dropped( FTab* ) ), this, SLOT( TabDropped( FTab* ) ) ); } //-------------------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////////////// //// PUBLIC SINGLETON API //// //////////////////////////////////////////////////////////////////////////////////////// //-------------------------------------------------------------------------------------- //---------------------------------------------- External Conveniency Singleton Accessor FDockingManager* DockingManager() { return FDockingManager::DockingManager(); }
32.965432
205
0.485507
Fabrice-Praxinos
5e5b7ac48008a29b994edb31e3a52d6226016709
1,545
cc
C++
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
src/desugar/test-string-cmp-desugar.cc
MrMaDGaME/Tiger
f31f73cd386b3ccb3e02abe7b23a3de09d70bd0f
[ "MIT" ]
null
null
null
/** ** Checking string comparisons desugaring. */ #include <ostream> #include <string> #include <ast/all.hh> #include <ast/libast.hh> #include <desugar/desugar-visitor.hh> #include <misc/file-library.hh> #include <parse/libparse.hh> #include <type/type-checker.hh> #include <type/types.hh> using namespace ast; using namespace desugar; const char* program_name = "test-string-cmp-desugar"; static void test_string_desugaring(const std::string& oper) { Exp* tree = parse::parse("let primitive streq(s1 : string, s2 : string) : int\n" " primitive strcmp(s1 : string, s2 : string) : int\n" "in\n" " (\"foo\" " + oper + " \"bar\")\n" "end\n"); type::TypeChecker type; type(tree); std::cout << "/* === Original tree... */\n" << *tree << '\n'; DesugarVisitor desugar(false, true); tree->accept(desugar); delete tree; tree = nullptr; std::cout << "/* === Desugared tree... */\n" << *desugar.result_get() << '\n'; delete desugar.result_get(); } int main() { // Desugaring `"foo" = "bar"' as `streq("foo", "bar")'. std::cout << "First test...\n"; test_string_desugaring("="); std::cout << std::endl; // Desugaring `"foo" <> "bar"' as `streq("foo", "bar") = 0'. std::cout << "Second test...\n"; test_string_desugaring("<>"); std::cout << std::endl; // Desugaring `"foo" >= "bar"' as `strcmp("foo", "bar") >= 0'. std::cout << "Third test...\n"; test_string_desugaring(">="); }
25.327869
72
0.565696
MrMaDGaME
5e5bc5c88129877bb07eef053149da72fc08a862
600
hpp
C++
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
Ladybug3D/Libraries/Renderer/Editor.hpp
wlsvy/Ladybug3D
9cd92843bf6cdff806aa4283c5594028a53e20b3
[ "MIT" ]
null
null
null
#pragma once #include <D3D12/D3D12_Define.hpp> #include <memory> namespace Ladybug3D { class Editor { public: static constexpr UINT EDITOR_DESCRIPTOR_SIZE = 64; void Initialize(void* hwnd, ID3D12Device* device, unsigned int frameCount); void NewFrame(); void Render(ID3D12GraphicsCommandList* cmdList); void DrawSampleWindow(); void DrawSceneGraph(); void ShutDownImGui(); ID3D12DescriptorHeap* GetDescriptorHeap(); private: std::unique_ptr<Ladybug3D::D3D12::DescriptorHeapAllocator> m_DescriptorHeap; }; }
25
84
0.68
wlsvy
5e6802193d69edc37ae030323b4f7c1d5fe5c2c9
22,188
cc
C++
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
6
2016-02-03T12:48:36.000Z
2020-09-16T15:07:51.000Z
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
4
2016-02-13T01:30:43.000Z
2020-03-30T16:59:32.000Z
wrappers/8.1.1/vtkHyperTreeGridCursorWrap.cc
axkibe/node-vtk
900ad7b5500f672519da5aa24c99aa5a96466ef3
[ "BSD-3-Clause" ]
null
null
null
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #define VTK_WRAPPING_CXX #define VTK_STREAMS_FWD_ONLY #include <nan.h> #include "vtkHyperTreeCursorWrap.h" #include "vtkHyperTreeGridCursorWrap.h" #include "vtkObjectBaseWrap.h" #include "vtkHyperTreeGridWrap.h" #include "vtkHyperTreeWrap.h" #include "vtkIdListWrap.h" #include "../../plus/plus.h" using namespace v8; extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap; Nan::Persistent<v8::FunctionTemplate> VtkHyperTreeGridCursorWrap::ptpl; VtkHyperTreeGridCursorWrap::VtkHyperTreeGridCursorWrap() { } VtkHyperTreeGridCursorWrap::VtkHyperTreeGridCursorWrap(vtkSmartPointer<vtkHyperTreeGridCursor> _native) { native = _native; } VtkHyperTreeGridCursorWrap::~VtkHyperTreeGridCursorWrap() { } void VtkHyperTreeGridCursorWrap::Init(v8::Local<v8::Object> exports) { Nan::SetAccessor(exports, Nan::New("vtkHyperTreeGridCursor").ToLocalChecked(), ConstructorGetter); Nan::SetAccessor(exports, Nan::New("HyperTreeGridCursor").ToLocalChecked(), ConstructorGetter); } void VtkHyperTreeGridCursorWrap::ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) { InitPtpl(); info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction()); } void VtkHyperTreeGridCursorWrap::InitPtpl() { if (!ptpl.IsEmpty()) return; v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New); VtkHyperTreeCursorWrap::InitPtpl( ); tpl->Inherit(Nan::New<FunctionTemplate>(VtkHyperTreeCursorWrap::ptpl)); tpl->SetClassName(Nan::New("VtkHyperTreeGridCursorWrap").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); Nan::SetPrototypeMethod(tpl, "Clone", Clone); Nan::SetPrototypeMethod(tpl, "clone", Clone); Nan::SetPrototypeMethod(tpl, "GetBounds", GetBounds); Nan::SetPrototypeMethod(tpl, "getBounds", GetBounds); Nan::SetPrototypeMethod(tpl, "GetChildIndex", GetChildIndex); Nan::SetPrototypeMethod(tpl, "getChildIndex", GetChildIndex); Nan::SetPrototypeMethod(tpl, "GetCornerCursors", GetCornerCursors); Nan::SetPrototypeMethod(tpl, "getCornerCursors", GetCornerCursors); Nan::SetPrototypeMethod(tpl, "GetCursor", GetCursor); Nan::SetPrototypeMethod(tpl, "getCursor", GetCursor); Nan::SetPrototypeMethod(tpl, "GetDimension", GetDimension); Nan::SetPrototypeMethod(tpl, "getDimension", GetDimension); Nan::SetPrototypeMethod(tpl, "GetGrid", GetGrid); Nan::SetPrototypeMethod(tpl, "getGrid", GetGrid); Nan::SetPrototypeMethod(tpl, "GetLevel", GetLevel); Nan::SetPrototypeMethod(tpl, "getLevel", GetLevel); Nan::SetPrototypeMethod(tpl, "GetNumberOfChildren", GetNumberOfChildren); Nan::SetPrototypeMethod(tpl, "getNumberOfChildren", GetNumberOfChildren); Nan::SetPrototypeMethod(tpl, "GetNumberOfCursors", GetNumberOfCursors); Nan::SetPrototypeMethod(tpl, "getNumberOfCursors", GetNumberOfCursors); Nan::SetPrototypeMethod(tpl, "GetPoint", GetPoint); Nan::SetPrototypeMethod(tpl, "getPoint", GetPoint); Nan::SetPrototypeMethod(tpl, "GetTree", GetTree); Nan::SetPrototypeMethod(tpl, "getTree", GetTree); Nan::SetPrototypeMethod(tpl, "IsEqual", IsEqual); Nan::SetPrototypeMethod(tpl, "isEqual", IsEqual); Nan::SetPrototypeMethod(tpl, "IsLeaf", IsLeaf); Nan::SetPrototypeMethod(tpl, "isLeaf", IsLeaf); Nan::SetPrototypeMethod(tpl, "IsRoot", IsRoot); Nan::SetPrototypeMethod(tpl, "isRoot", IsRoot); Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "SameTree", SameTree); Nan::SetPrototypeMethod(tpl, "sameTree", SameTree); Nan::SetPrototypeMethod(tpl, "SetGrid", SetGrid); Nan::SetPrototypeMethod(tpl, "setGrid", SetGrid); Nan::SetPrototypeMethod(tpl, "SetTree", SetTree); Nan::SetPrototypeMethod(tpl, "setTree", SetTree); Nan::SetPrototypeMethod(tpl, "ToChild", ToChild); Nan::SetPrototypeMethod(tpl, "toChild", ToChild); Nan::SetPrototypeMethod(tpl, "ToParent", ToParent); Nan::SetPrototypeMethod(tpl, "toParent", ToParent); Nan::SetPrototypeMethod(tpl, "ToRoot", ToRoot); Nan::SetPrototypeMethod(tpl, "toRoot", ToRoot); Nan::SetPrototypeMethod(tpl, "ToSameVertex", ToSameVertex); Nan::SetPrototypeMethod(tpl, "toSameVertex", ToSameVertex); #ifdef VTK_NODE_PLUS_VTKHYPERTREEGRIDCURSORWRAP_INITPTPL VTK_NODE_PLUS_VTKHYPERTREEGRIDCURSORWRAP_INITPTPL #endif ptpl.Reset( tpl ); } void VtkHyperTreeGridCursorWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) { if(!info.IsConstructCall()) { Nan::ThrowError("Constructor not called in a construct call."); return; } if(info.Length() == 0) { vtkSmartPointer<vtkHyperTreeGridCursor> native = vtkSmartPointer<vtkHyperTreeGridCursor>::New(); VtkHyperTreeGridCursorWrap* obj = new VtkHyperTreeGridCursorWrap(native); obj->Wrap(info.This()); } else { if(info[0]->ToObject() != vtkNodeJsNoWrap ) { Nan::ThrowError("Parameter Error"); return; } } info.GetReturnValue().Set(info.This()); } void VtkHyperTreeGridCursorWrap::Clone(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGridCursor * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->Clone(); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::GetBounds(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); size_t i; if(info.Length() > 0 && info[0]->IsFloat64Array()) { v8::Local<v8::Float64Array>a0(v8::Local<v8::Float64Array>::Cast(info[0]->ToObject())); if( a0->Length() < 6 ) { Nan::ThrowError("Array too short."); return; } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetBounds( (double *)(a0->Buffer()->GetContents().Data()) ); return; } else if(info.Length() > 0 && info[0]->IsArray()) { v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject())); double b0[6]; if( a0->Length() < 6 ) { Nan::ThrowError("Array too short."); return; } for( i = 0; i < 6; i++ ) { if( !a0->Get(i)->IsNumber() ) { Nan::ThrowError("Array contents invalid."); return; } b0[i] = a0->Get(i)->NumberValue(); } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetBounds( b0 ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetChildIndex(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetChildIndex(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetCornerCursors(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsUint32()) { if(info.Length() > 1 && info[1]->IsUint32()) { if(info.Length() > 2 && info[2]->IsObject() && (Nan::New(VtkIdListWrap::ptpl))->HasInstance(info[2])) { VtkIdListWrap *a2 = ObjectWrap::Unwrap<VtkIdListWrap>(info[2]->ToObject()); bool r; if(info.Length() != 3) { Nan::ThrowError("Too many parameters."); return; } r = native->GetCornerCursors( info[0]->Uint32Value(), info[1]->Uint32Value(), (vtkIdList *) a2->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } } } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetCursor(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsUint32()) { vtkHyperTreeGridCursor * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->GetCursor( info[0]->Uint32Value() ); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetDimension(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetDimension(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetGrid(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGrid * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetGrid(); VtkHyperTreeGridWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridWrap *w = new VtkHyperTreeGridWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::GetLevel(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); unsigned int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetLevel(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetNumberOfChildren(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetNumberOfChildren(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetNumberOfCursors(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); unsigned int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetNumberOfCursors(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::GetPoint(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); size_t i; if(info.Length() > 0 && info[0]->IsFloat64Array()) { v8::Local<v8::Float64Array>a0(v8::Local<v8::Float64Array>::Cast(info[0]->ToObject())); if( a0->Length() < 3 ) { Nan::ThrowError("Array too short."); return; } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetPoint( (double *)(a0->Buffer()->GetContents().Data()) ); return; } else if(info.Length() > 0 && info[0]->IsArray()) { v8::Local<v8::Array>a0(v8::Local<v8::Array>::Cast(info[0]->ToObject())); double b0[3]; if( a0->Length() < 3 ) { Nan::ThrowError("Array too short."); return; } for( i = 0; i < 3; i++ ) { if( !a0->Get(i)->IsNumber() ) { Nan::ThrowError("Array contents invalid."); return; } b0[i] = a0->Get(i)->NumberValue(); } if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->GetPoint( b0 ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::GetTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTree * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetTree(); VtkHyperTreeWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeWrap *w = new VtkHyperTreeWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::IsEqual(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); bool r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->IsEqual( (vtkHyperTreeCursor *) a0->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::IsLeaf(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); bool r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->IsLeaf(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::IsRoot(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); bool r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->IsRoot(); info.GetReturnValue().Set(Nan::New(r)); } void VtkHyperTreeGridCursorWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); vtkHyperTreeGridCursor * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->NewInstance(); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkHyperTreeGridCursorWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0])) { VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject()); vtkHyperTreeGridCursor * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SafeDownCast( (vtkObjectBase *) a0->native.GetPointer() ); VtkHyperTreeGridCursorWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkHyperTreeGridCursorWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkHyperTreeGridCursorWrap *w = new VtkHyperTreeGridCursorWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SameTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); int r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SameTree( (vtkHyperTreeCursor *) a0->native.GetPointer() ); info.GetReturnValue().Set(Nan::New(r)); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SetGrid(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeGridWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeGridWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeGridWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetGrid( (vtkHyperTreeGrid *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::SetTree(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetTree( (vtkHyperTree *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::ToChild(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->ToChild( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkHyperTreeGridCursorWrap::ToParent(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->ToParent(); } void VtkHyperTreeGridCursorWrap::ToRoot(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->ToRoot(); } void VtkHyperTreeGridCursorWrap::ToSameVertex(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkHyperTreeGridCursorWrap *wrapper = ObjectWrap::Unwrap<VtkHyperTreeGridCursorWrap>(info.Holder()); vtkHyperTreeGridCursor *native = (vtkHyperTreeGridCursor *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkHyperTreeCursorWrap::ptpl))->HasInstance(info[0])) { VtkHyperTreeCursorWrap *a0 = ObjectWrap::Unwrap<VtkHyperTreeCursorWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->ToSameVertex( (vtkHyperTreeCursor *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); }
31.833572
111
0.720119
axkibe
5e6945471a919e1b986c4a664041b61b200f2a45
482
hpp
C++
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
CreaStein !!!/Test_SDL_DirectX9.0c/cl_CustomCube.hpp
RSF-Deus/Creastein
ec5aafbf09940dd630fc329a4450e1e37a0d2f62
[ "MIT" ]
null
null
null
#pragma once #include "header_ressources.hpp" #include "cl_CustomObject.hpp" class CustomCube : public CustomObject { protected: float fRot; public: CustomCube(CustomForme* _Forme); CustomCube(CustomForme* _Forme, D3DXVECTOR3& _TranVector); CustomCube(CustomForme* _Forme, D3DXVECTOR3& _TranVector, D3DXVECTOR3& _LocalRotVector, D3DXVECTOR3& _GlobalRotVector); ~CustomCube(); virtual void GeoActions(); virtual void SpecialActions(); virtual void ObjectRendering(); };
21.909091
120
0.786307
RSF-Deus
5e6a0b26f6059777554956dff53f4f18f709f3b3
476
hpp
C++
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
6
2019-03-06T23:54:01.000Z
2020-08-24T09:18:33.000Z
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
6
2019-03-07T00:31:48.000Z
2021-01-10T13:28:41.000Z
algorithm_dtocs.hpp
jkloe/pageDistanceBasedContourGenerator
92e8768b596c98ffc09f4b5eeb7db8aafccda01a
[ "MIT" ]
8
2019-03-07T00:08:43.000Z
2021-05-13T12:14:08.000Z
#ifndef ALGORITHM_DTOCS_HPP_GF3U3S3CO1 #define ALGORITHM_DTOCS_HPP_GF3U3S3CO1 #include "algorithm_distance_map.hpp" namespace prhlt { class Algorithm_DTOCS: public Algorithm_Distance_Map{ public: Algorithm_DTOCS(cv::Mat &ex_image); protected: virtual float calculate_neighbour_value(int r1,int c1, int r2, int c2); int calculate_grey_gradient(int r1,int c1, int r2, int c2); }; } #endif /* end of include guard*/
28
83
0.701681
jkloe
5e6a3bc05fe12d35beda603fa15212b5f1a4f4b1
8,231
hh
C++
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
3
2019-07-03T14:03:31.000Z
2021-12-19T10:18:49.000Z
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
6
2020-02-17T12:01:31.000Z
2021-12-09T22:02:36.000Z
Kaskade/fem/errorest.hh
chenzongxiong/streambox
76f95780d1bf6c02731e39d8ac73937cea352b95
[ "Unlicense" ]
2
2020-12-03T04:41:18.000Z
2021-01-11T21:44:42.000Z
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the library KASKADE 7 */ /* see http://www.zib.de/projects/kaskade7-finite-element-toolbox */ /* */ /* Copyright (C) 2013-2015 Zuse Institute Berlin */ /* */ /* KASKADE 7 is distributed under the terms of the ZIB Academic License. */ /* see $KASKADE/academic.txt */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef ERROREST_HH #define ERROREST_HH #include <vector> #include <boost/fusion/include/for_each.hpp> #include <boost/utility.hpp> #include <boost/multi_array.hpp> namespace Kaskade { /** * \ingroup refcrit * \brief Base class for refinement criteria. */ class RefinementCriterion { public: /** * \brief Computes the thresholds for refinement. * \param normalizedErrors a twodimensional array containing the normalized error contribution for each cell and * each variable, i.e. normalizedErrors[i][j] contains the error contribution of cell i * to the error in variable j, divided by the tolerance, such that the sum over i * should not exceed one (for acceptance) * \returns an array containing a threshold value such that any cell i for which normalizedErrors[i][j] > return[j] * for any j is to be refined, or an empty array in case all variables are accurate enough */ std::vector<double> threshold(boost::multi_array<double,2> const& normalizedErrors) const; private: virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const = 0; }; /** * \ingroup refcrit * \brief Refines the grid according to the normalized errors and the given thresholds. */ template <class GridManager, class GridView> void markAndRefine(GridManager& gridManager, GridView const& gridView, boost::multi_array<double,2> const& normalizedErrors, std::vector<double> const& threshold) { auto end = gridView.template end<0>(); for (auto ci=gridView.template begin<0>(); ci!=end; ++ci) { auto idx = gridView.indexSet().index(*ci); for (int j=0; j<threshold.size(); ++j) if (normalizedErrors[idx][j] >= threshold[j]) { gridManager.mark(1,*ci); break; } } gridManager.adaptAtOnce(); } /** * \ingroup refcrit * \brief Fixed fraction refinement criterion. * Determines the refinement thresholds such that at least the specified fraction of the cells are * marked for refinement. This ensures that not too few cells are marked, which could lead to very many * refinement iterations, but may lead to erratic refinement if there are indeed only very local refinements * necessary. * * In very rare circumstances (namely when there are many cells with exactly the same local error estimate), * much more cells than the required fraction can be marked for refinement. */ class FixedFractionCriterion: public RefinementCriterion { public: FixedFractionCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Bulk refinement criterion. * Determines the refinement thresholds such that approximately the specified fraction of the total error * is removed by the refinement (under the unrealistically optimistic assumption that refinement eliminates * the error completely in that cell - in reality, it's only reduced by a certain factor, so the total * error is reduced somewhat less). */ class BulkCriterion: public RefinementCriterion { public: BulkCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Max value refinement criterion. * Determines the refinement thresholds such that all cells with an error contribution exceeding a certain * fraction of the maximum error contribution are refined. */ class MaxValueCriterion: public RefinementCriterion { public: MaxValueCriterion(double fraction = 0.2); private: double fraction; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; /** * \ingroup refcrit * \brief Babuska-Rheinboldt refinement criterion. * Determines the refinement thresholds such that all cells with an error contribution exceeding the * expected error contribution of the worst cell \em after refinement will be marked. This tends to * equilibrate the error contributions quite fast. * * Note that the local convergence order should be estimated (important in the vicinity of singularities) * but is here assumed to be the fixed specified order. */ class BabuskaRheinboldtCriterion: public MaxValueCriterion { public: BabuskaRheinboldtCriterion(std::vector<int> const& order); private: std::vector<int> order; virtual double computeThreshold(std::vector<double>& normalizedErrors, double totalError, int j) const; }; //--------------------------------------------------------------------------------------------- namespace ErrorestDetail { template <class GroupByCell> struct GroupedSummationCollector { GroupedSummationCollector(GroupByCell const& group_): group(group_) {} template <class Cell> int integrationOrder(Cell const& , int shapeFunctionOrder) const { return shapeFunctionOrder; } // need to define this because boost::multi_array does not perform assignment if the arrays have // different shape. GroupedSummationCollector<GroupByCell>& operator=(GroupedSummationCollector<GroupByCell> const& c) { auto shape = c.sums.shape(); sums.resize(boost::extents[shape[0]][shape[1]]); sums = c.sums; group = c.group; return *this; } template <class CellPointer, class Index, class Sequence> void operator()(CellPointer const& ci, Index idx, double weight, Sequence const& x) { if (sums.num_elements()==0) sums.resize(boost::extents[group.nGroups][boost::fusion::size(x)]); int i = 0; // for_each needs constant functor... boost::fusion::for_each(x,Add(sums,group[idx],i,weight)); } void join(GroupedSummationCollector<GroupByCell> const& c) { auto shape = c.sums.shape(); auto myshape = sums.shape(); if(c.sums.num_elements()==0) return; if (sums.num_elements()==0 || myshape[0]!=shape[0] || myshape[1]!=shape[1]) // not yet initialized { sums.resize(boost::extents[shape[0]][shape[1]]); sums = c.sums; // -> do a simple copy } else for (size_t i=0; i<shape[0]; ++i) // otherwise add up for (size_t j=0; j<shape[1]; ++j) sums[i][j] += c.sums[i][j]; } boost::multi_array<double,2> sums; private: GroupByCell group; struct Add { Add(boost::multi_array<double,2>& sums_, int idx_, int& i_, double w_): sums(sums_), idx(idx_), i(i_) , w(w_) {} template <class T> void operator()(T const& t) const { sums[idx][i++] += w*t; } private: boost::multi_array<double,2>& sums; int idx; int& i; double w; }; }; } } #endif
36.582222
127
0.598226
chenzongxiong
5e6a9a59f2c3f9c63495574ae5fed6034f7a0a04
59
cpp
C++
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
1
2018-12-17T09:33:54.000Z
2018-12-17T09:33:54.000Z
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
null
null
null
LightCubes/source/src/gl3d/sceneGraph.cpp
LeeCIT/LightCubes
35e1ec3c1447f72642ece0b602dfbd7213fe806b
[ "MIT" ]
null
null
null
#include "sceneGraph.h" namespace sceneGraphSys { };
5.363636
23
0.677966
LeeCIT
5e6ebaa91f7041a28b381a7f3c0a778d68693894
4,242
cpp
C++
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
17
2018-07-04T14:06:31.000Z
2021-11-11T20:43:38.000Z
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
null
null
null
src/MeasurementProvider.cpp
josefadamcik/RoomMonitor
77dbd9b37b47aef5a7de840ed403dd7bd0d7d58b
[ "MIT" ]
1
2019-12-26T12:59:00.000Z
2019-12-26T12:59:00.000Z
#include "MeasurementProvider.h" #define SHT21_TRIGGER_TEMP_MEASURE_NOHOLD 0xF3 #define SHT21_TRIGGER_HUMD_MEASURE_NOHOLD 0xF5 #define SHT21_TRIGGER_TEMP_MEASURE_HOLD 0xE3 #define SHT21_TRIGGER_HUMD_MEASURE_HOLD 0xE5 MeasurementProvider::MeasurementProvider( uint8_t tempSensAddr, uint8_t lightSensAddr, float analogVCCToRealCoeficient ): tempSensAddress(tempSensAddr), lightSensor(lightSensAddr), analogVCCToRealCoeficient(analogVCCToRealCoeficient) { } bool MeasurementProvider::begin() { bool lsStatus = lightSensor.begin(BH1750::ONE_TIME_HIGH_RES_MODE); //goes to sleep after measurement #ifdef USE_BMP280 bool bmpStatus = bmp.begin(0x76); return lsStatus && bmpStatus; #else return lsStatus; #endif } const MeasurementsData& MeasurementProvider::getCurrentMeasurements(){ return data; } bool MeasurementProvider::doMeasurements() { //measure battery voltage data.voltageRaw = analogRead(A0); data.voltage = analogToVoltage(data.voltageRaw); #ifdef USE_SHT30 //SHT-30 measure temp and humidity byte tempMeasureRes; int retryMeasurement = 3; do { retryMeasurement--; tempMeasureRes = measureTempSTH30(); if (tempMeasureRes != 0) { Serial.println(F("Unable to measure temperature")); Serial.println(tempMeasureRes); delay(100); } } while (tempMeasureRes != 0 && retryMeasurement > 0); if (tempMeasureRes != 0) { return false; } #endif #ifdef USE_SHT21 //SHT21 data.temperature = 0; data.humidity = 0; measureTempSTH21(); #endif #ifdef USE_BMP280 // measur pressure data.bmpTemp = bmp.readTemperature(); data.pressure = bmp.readPressure(); #else data.bmpTemp = 0; data.pressure = 0; #endif // measure lipht data.lightLevel = lightSensor.readLightLevel(); return true; } #ifdef USE_SHT30 byte MeasurementProvider::measureTempSTH30() { unsigned int data[6]; Wire.beginTransmission(tempSensAddress); // measurement command -> one shot measurement, clock stretching, high repeatability Wire.write(0x2C); Wire.write(0x06); uint8_t wireResult = Wire.endTransmission(); if (wireResult != 0) { return wireResult; } delay(500); // Request 6 bytes of data Wire.requestFrom(tempSensAddress, 6); // cTemp msb, cTemp lsb, cTemp crc, humidity msb, humidity lsb, humidity crc for (int i=0;i<6;i++) { data[i]=Wire.read(); }; delay(50); if (Wire.available() != 0) { return 20; } // Convert the data this->data.temperature = ((((data[0] * 256.0) + data[1]) * 175) / 65535.0) - 45; this->data.humidity = ((((data[3] * 256.0) + data[4]) * 100) / 65535.0); return 0; } #endif #ifdef USE_SHT21 uint8_t MeasurementProvider::measureTempSTH21() { // Convert the data this->data.humidity = (-6.0 + 125.0 / 65536.0 * readFloatSHT21(SHT21_TRIGGER_HUMD_MEASURE_HOLD)); this->data.temperature = (-46.85 + 175.72 / 65536.0 * readFloatSHT21(SHT21_TRIGGER_TEMP_MEASURE_HOLD)); return 0; } float MeasurementProvider::readFloatSHT21(uint8_t command) { uint16_t result; Wire.beginTransmission(tempSensAddress); Wire.write(command); Wire.endTransmission(); delay(100); Wire.requestFrom(tempSensAddress, 3); while(Wire.available() < 3) { delay(10); } // return result result = ((Wire.read()) << 8); result += Wire.read(); result &= ~0x0003; // clear two low bits (status bits) return (float)result; } #endif float MeasurementProvider::analogToVoltage(int analog) { return analog * analogVCCToRealCoeficient; } void MeasurementsData::printToSerial() const { Serial.print(F("temp: ")); Serial.print(temperature); Serial.print(F(" (")); Serial.print(bmpTemp); Serial.print(F(") ")); Serial.print(F(", hum: ")); Serial.print(humidity); Serial.print(F(", press: ")); Serial.print(pressure); Serial.print(F(", vcc: ")); Serial.print(voltage); Serial.print(F(", vcc raw: ")); Serial.print(voltageRaw); Serial.print(F(", light: ")); Serial.print(lightLevel); }
26.679245
107
0.657944
josefadamcik
5e763ed5f586408e8ff628f829660ee724f3b6f9
4,076
cpp
C++
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
1
2022-01-28T04:54:52.000Z
2022-01-28T04:54:52.000Z
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
null
null
null
src/main-last.cpp
j-jorge/find-simd
eb5ca42a36c5957379b133b67c12ecb2cd4e59ac
[ "Apache-2.0" ]
1
2022-01-28T04:54:57.000Z
2022-01-28T04:54:57.000Z
#include "find.hpp" #include <algorithm> #include <iostream> #include <vector> #include <cstdio> #include <chrono> #include <numeric> #include <benchmark/benchmark.h> static std::vector<int> build_ordered_vector(size_t n) { std::vector<int> values(n); std::iota(values.begin(), values.end(), 1); return values; } #define input_size \ Arg(1 << 2) \ ->Arg(1 << 4) \ ->Arg(1 << 8) \ ->Arg(1 << 9) \ ->Arg(1 << 10) \ ->Arg(1 << 11) \ ->Arg(1 << 12) \ ->Arg(1 << 13) \ ->Arg(1 << 14) \ ->Arg(1 << 15) \ ->Arg(1 << 16) \ ->Arg(1 << 17) \ ->Arg(1 << 18) \ ->Arg(1 << 19) \ ->Arg(1 << 20) \ ->Arg(1 << 21) \ ->Arg(1 << 22) \ ->Arg(1 << 23) \ ->Arg(1 << 24) \ #define declare_benchmark(impl) \ static void benchmark_ ## impl(benchmark::State& state) \ { \ const size_t n = state.range(0); \ const std::vector<int> values = build_ordered_vector(n); \ \ for (auto _ : state) \ benchmark::DoNotOptimize \ (find_int_ ## impl(values.back(), values.data(), n)); \ } \ \ BENCHMARK(benchmark_ ## impl)->input_size declare_benchmark(c); declare_benchmark(c_unrolled_8); declare_benchmark(cpp); declare_benchmark(sse2); static std::chrono::milliseconds now() { return std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::steady_clock::now().time_since_epoch()); } static int measure(int n) { std::vector<int> values(n); std::iota(values.begin(), values.end(), 1); const std::chrono::milliseconds start = now(); const size_t p_c = find_int_c(values.back(), values.data(), n); const std::chrono::milliseconds end_c = now(); const size_t p_c_unrolled = find_int_c_unrolled_8(values.back(), values.data(), n); const std::chrono::milliseconds end_c_unrolled = now(); const size_t p_cpp = find_int_cpp(values.back(), values.data(), n); const std::chrono::milliseconds end_cpp = now(); const size_t p_sse2 = find_int_sse2(values.back(), values.data(), n) ; const std::chrono::milliseconds end_sse2 = now(); std::cout << "C: " << (end_c - start).count() << " ms., " << "C unrolled: " << (end_c_unrolled - end_c).count() << " ms., " << "C++: " << (end_cpp - end_c_unrolled).count() << " ms., " << "SSE2: " << (end_sse2 - end_cpp).count() << " ms.\n"; if (p_c_unrolled != p_sse2) { std::cerr << "Mismatch: c unrolled -> " << p_c_unrolled << ", sse2 -> " << p_sse2 << '\n'; return 1; } if (p_cpp != p_sse2) { std::cerr << "Mismatch: c++ -> " << p_cpp << ", sse2 -> " << p_sse2 << '\n'; return 1; } if (p_c != p_sse2) { std::cerr << "Mismatch: c -> " << p_c << ", sse2 -> " << p_sse2 << '\n'; return 1; } return 0; } int main(int argc, char** argv) { if (argc == 2) { const int n = atoi(argv[1]); if (n > 0) return measure(n); } benchmark::Initialize(&argc, argv); benchmark::RunSpecifiedBenchmarks(); benchmark::Shutdown(); return 0; }
31.114504
77
0.418302
j-jorge
5e765b2cb378fd461aec047ec77d0e03dfdc43c1
3,256
cpp
C++
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
src/sigogl/ws_run.cpp
harsha336/rrt_sig
1afa8ad45562f20850360d691c2cc29faf18565b
[ "Apache-2.0" ]
null
null
null
/*======================================================================= Copyright (c) 2018 Marcelo Kallmann. This software is distributed under the Apache License, Version 2.0. All copies must contain the full copyright notice licence.txt located at the base folder of the distribution. =======================================================================*/ # include <stdlib.h> # include <sig/gs_string.h> # include <sigogl/ws_run.h> # include <sigogl/ws_window.h> # include <sigogl/ws_osinterface.h> //===================================== xx ================================================= struct SwTimerData { double interval; double lasttime; WsWindow* window; void (*callback) (void*); union { void* udata; int evid; }; }; static GsArray<SwTimerData> Timers; static int NumTimers=0; static double Time0=0; static double TimeCur=0; void ws_check_timers () { TimeCur = gs_time()-Time0; for ( int i=0; i<NumTimers; i++ ) { if ( TimeCur-Timers[i].lasttime > Timers[i].interval ) { if ( Timers[i].callback ) { Timers[i].callback ( Timers[i].udata ); } else { WsWindow* win = Timers[i].window; if ( !win->minimized() ) win->timer ( Timers[i].evid ); } Timers[i].lasttime = TimeCur; } } } static void add_timer ( double interval, WsWindow* win, void(*cb)(void*) ) { if ( Time0==0 ) Time0 = gs_time(); SwTimerData& t = Timers.push(); t.interval = interval; t.lasttime = TimeCur; t.window = win; t.callback = cb; NumTimers++; } void ws_add_timer ( double interval, void(*cb)(void*), void* udata ) { add_timer ( interval, 0, cb ); Timers.top().udata = udata; } void ws_add_timer ( double interval, WsWindow* win, int ev ) { add_timer ( interval, win, 0 ); Timers.top().evid = ev; } void ws_remove_timer ( void(*cb)(void*) ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].callback == cb ) { Timers[i] = Timers.pop(); NumTimers--; return; } } } void ws_remove_timer ( WsWindow* win, int ev ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].window==win && Timers[i].evid==ev ) { Timers[i] = Timers.pop(); NumTimers--; return; } } } void ws_remove_timers ( WsWindow* win ) { for ( int i=0; i<Timers.size(); i++ ) { if ( Timers[i].window==win ) { Timers[i] = Timers.pop(); NumTimers--; i--; } } } void ws_run ( int sleepms ) { if ( sleepms>0 ) { while ( wsi_check() ) { gs_sleep ( sleepms ); if ( NumTimers ) ws_check_timers (); } } else if ( sleepms<0 ) { int n=sleepms; while ( wsi_check() ) { if ( NumTimers ) ws_check_timers (); if ( ++n==0 ) { gs_sleep(1); n=sleepms; } } } else { while ( wsi_check() ) { if ( NumTimers ) ws_check_timers (); } } } void ws_check ( int sleepms ) { static int counter=0; if ( sleepms>0 ) gs_sleep ( sleepms ); else if ( sleepms<0 && ++counter%-sleepms==0 ) gs_sleep(1); if ( NumTimers ) ws_check_timers (); if ( wsi_check()==0 ) exit(0); } int ws_fast_check () { if ( NumTimers ) ws_check_timers (); return wsi_check (); } void ws_exit ( int c ) { exit ( c ); } void ws_screen_resolution ( int& w, int& h ) { wsi_screen_resolution ( w, h ); } //================================ End of File =================================================
21.281046
96
0.561732
harsha336
5e77840110b226f16cf6e0d89ebbc9b186558d67
21,028
cpp
C++
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
core/src/tile/tileManager.cpp
JungWonHyung/test2
3556db60b017dfe2313fffa0b04fc166cb19fd0e
[ "MIT" ]
null
null
null
#include "tile/tileManager.h" #include "data/tileSource.h" #include "map.h" #include "platform.h" #include "tile/tile.h" #include "tile/tileCache.h" #include "util/mapProjection.h" #include "view/view.h" #include "glm/gtx/norm.hpp" #include <algorithm> #define DBG(...) // LOGD(__VA_ARGS__) namespace Tangram { enum class TileManager::ProxyID : uint8_t { no_proxies = 0, child1 = 1 << 0, child2 = 1 << 1, child3 = 1 << 2, child4 = 1 << 3, parent = 1 << 4, parent2 = 1 << 5, }; struct TileManager::TileEntry { TileEntry(std::shared_ptr<Tile>& _tile) : tile(_tile), m_proxyCounter(0), m_proxies(0), m_visible(false) {} ~TileEntry() { clearTask(); } std::shared_ptr<Tile> tile; std::shared_ptr<TileTask> task; /* A Counter for number of tiles this tile acts a proxy for */ int32_t m_proxyCounter; /* The set of proxy tiles referenced by this tile */ uint8_t m_proxies; bool m_visible; bool isReady() { return bool(tile); } bool isInProgress() { return bool(task) && !task->isCanceled(); } bool isCanceled() { return bool(task) && task->isCanceled(); } bool needsLoading() { if (bool(tile)) { return false; } if (!task) { return true; } if (task->isCanceled()) { return false; } if (task->needsLoading()) { return true; } for (auto& subtask : task->subTasks()) { if (subtask->needsLoading()) { return true; } } return false; } // Complete task only when // - task still exists // - task has a tile ready // - tile has all rasters set bool completeTileTask() { if (bool(task) && task->isReady()) { for (auto& rTask : task->subTasks()) { if (!rTask->isReady()) { return false; } } task->complete(); tile = task->getTile(); task.reset(); return true; } return false; } void clearTask() { if (task) { for (auto& raster : task->subTasks()) { raster->cancel(); } task->subTasks().clear(); task->cancel(); task.reset(); } } /* Methods to set and get proxy counter */ int getProxyCounter() { return m_proxyCounter; } void incProxyCounter() { m_proxyCounter++; } void decProxyCounter() { m_proxyCounter = m_proxyCounter > 0 ? m_proxyCounter - 1 : 0; } void resetProxyCounter() { m_proxyCounter = 0; } bool setProxy(ProxyID id) { if ((m_proxies & static_cast<uint8_t>(id)) == 0) { m_proxies |= static_cast<uint8_t>(id); return true; } return false; } bool unsetProxy(ProxyID id) { if ((m_proxies & static_cast<uint8_t>(id)) != 0) { m_proxies &= ~static_cast<uint8_t>(id); return true; } return false; } /* Method to check whther this tile is in the current set of visible tiles * determined by view::updateTiles(). */ bool isVisible() const { return m_visible; } void setVisible(bool _visible) { m_visible = _visible; } }; TileManager::TileSet::TileSet(std::shared_ptr<TileSource> _source, bool _clientSource) : source(_source), clientTileSource(_clientSource) {} TileManager::TileSet::~TileSet() {} TileManager::TileManager(std::shared_ptr<Platform> platform, TileTaskQueue& _tileWorker) : m_workers(_tileWorker) { m_tileCache = std::unique_ptr<TileCache>(new TileCache(DEFAULT_CACHE_SIZE)); // Callback to pass task from Download-Thread to Worker-Queue m_dataCallback = TileTaskCb{[this, platform](std::shared_ptr<TileTask> task) { if (task->isReady()) { platform->requestRender(); } else if (task->hasData()) { m_workers.enqueue(task); } else { task->cancel(); } }}; } TileManager::~TileManager() { m_tileSets.clear(); } void TileManager::setTileSources(const std::vector<std::shared_ptr<TileSource>>& _sources) { m_tileCache->clear(); // Remove all (non-client datasources) sources and respective tileSets not present in the // new scene auto it = std::remove_if( m_tileSets.begin(), m_tileSets.end(), [&](auto& tileSet) { if (!tileSet.clientTileSource) { LOGN("Remove source %s", tileSet.source->name().c_str()); return true; } // Clear cache tileSet.tiles.clear(); return false; }); m_tileSets.erase(it, m_tileSets.end()); // add new sources for (const auto& source : _sources) { if (!source->generateGeometry()) { continue; } if (std::find_if(m_tileSets.begin(), m_tileSets.end(), [&](const TileSet& a) { return a.source->name() == source->name(); }) == m_tileSets.end()) { LOGN("add source %s", source->name().c_str()); m_tileSets.push_back({ source, false }); } else { LOGW("Duplicate named datasource (not added): %s", source->name().c_str()); } } } std::shared_ptr<TileSource> TileManager::getClientTileSource(int32_t sourceID) { for (const auto& tileSet : m_tileSets) { if (tileSet.clientTileSource && tileSet.source->id() == sourceID) { return tileSet.source; } } return nullptr; } void TileManager::addClientTileSource(std::shared_ptr<TileSource> _tileSource) { m_tileSets.push_back({ _tileSource, true }); } bool TileManager::removeClientTileSource(TileSource& _tileSource) { bool removed = false; for (auto it = m_tileSets.begin(); it != m_tileSets.end();) { if (it->source.get() == &_tileSource) { // Remove the textures for this tile source it->source->clearRasters(); // Remove the tile set associated with this tile source it = m_tileSets.erase(it); removed = true; } else { ++it; } } return removed; } void TileManager::clearTileSets(bool clearSourceCaches) { for (auto& tileSet : m_tileSets) { tileSet.tiles.clear(); if (clearSourceCaches) { tileSet.source->clearData(); } } m_tileCache->clear(); } void TileManager::clearTileSet(int32_t _sourceId) { for (auto& tileSet : m_tileSets) { if (tileSet.source->id() != _sourceId) { continue; } tileSet.tiles.clear(); } m_tileCache->clear(); m_tileSetChanged = true; } void TileManager::updateTileSets(const View& _view) { m_tiles.clear(); m_tilesInProgress = 0; m_tileSetChanged = false; if (!getDebugFlag(DebugFlags::freeze_tiles)) { for (auto& tileSet : m_tileSets) { tileSet.visibleTiles.clear(); } auto tileCb = [&, zoom = _view.getZoom()](TileID _tileID){ for (auto& tileSet : m_tileSets) { auto zoomBias = tileSet.source->zoomBias(); auto maxZoom = tileSet.source->maxZoom(); // Insert scaled and maxZoom mapped tileID in the visible set tileSet.visibleTiles.insert(_tileID.zoomBiasAdjusted(zoomBias).withMaxSourceZoom(maxZoom)); } }; _view.getVisibleTiles(tileCb); } for (auto& tileSet : m_tileSets) { // check if tile set is active for zoom (zoom might be below min_zoom) if (tileSet.source->isActiveForZoom(_view.getZoom())) { updateTileSet(tileSet, _view.state()); } } loadTiles(); // Make m_tiles an unique list of tiles for rendering sorted from // high to low zoom-levels. std::sort(m_tiles.begin(), m_tiles.end(), [](auto& a, auto& b) { return a->sourceID() == b->sourceID() ? a->getID() < b->getID() : a->sourceID() < b->sourceID(); } ); // Remove duplicates: Proxy tiles could have been added more than once m_tiles.erase(std::unique(m_tiles.begin(), m_tiles.end()), m_tiles.end()); } void TileManager::updateTileSet(TileSet& _tileSet, const ViewState& _view) { bool newTiles = false; if (_tileSet.sourceGeneration != _tileSet.source->generation()) { _tileSet.sourceGeneration = _tileSet.source->generation(); } // Tile load request above this zoom-level will be canceled in order to // not wait for tiles that are too small to contribute significantly to // the current view. int maxZoom = _view.zoom + 2; std::vector<TileID> removeTiles; auto& tiles = _tileSet.tiles; // Check for ready tasks, move Tile to active TileSet and unset Proxies. for (auto& it : tiles) { auto& entry = it.second; if (entry.completeTileTask()) { clearProxyTiles(_tileSet, it.first, entry, removeTiles); newTiles = true; m_tileSetChanged = true; } } const auto& visibleTiles = _tileSet.visibleTiles; // Loop over visibleTiles and add any needed tiles to tileSet auto curTilesIt = tiles.begin(); auto visTilesIt = visibleTiles.begin(); auto generation = _tileSet.source->generation(); while (visTilesIt != visibleTiles.end() || curTilesIt != tiles.end()) { auto& visTileId = visTilesIt == visibleTiles.end() ? NOT_A_TILE : *visTilesIt; auto& curTileId = curTilesIt == tiles.end() ? NOT_A_TILE : curTilesIt->first; if (visTileId == curTileId) { // tiles in both sets match assert(visTilesIt != visibleTiles.end() && curTilesIt != tiles.end()); auto& entry = curTilesIt->second; entry.setVisible(true); auto sourceGeneration = (entry.isReady()) ? entry.tile->sourceGeneration() : entry.task->sourceGeneration(); if (entry.isReady()) { m_tiles.push_back(entry.tile); if (!entry.isInProgress() && (sourceGeneration < generation)) { // Tile needs update - enqueue for loading entry.task = _tileSet.source->createTask(visTileId); enqueueTask(_tileSet, visTileId, _view); } } else if (entry.needsLoading()) { // Not yet available - enqueue for loading enqueueTask(_tileSet, visTileId, _view); } else if (entry.isCanceled() && (sourceGeneration < generation)) { // Tile needs update - enqueue for loading entry.task = _tileSet.source->createTask(visTileId); enqueueTask(_tileSet, visTileId, _view); } if (entry.isInProgress()) { m_tilesInProgress++; } if (newTiles && entry.isInProgress()) { // check again for proxies updateProxyTiles(_tileSet, visTileId, entry); } ++curTilesIt; ++visTilesIt; } else if (curTileId > visTileId) { // tileSet is missing an element present in visibleTiles // NB: if (curTileId == NOT_A_TILE) it is always > visTileId // and if curTileId > visTileId, then visTileId cannot be // NOT_A_TILE. (for the current implementation of > operator) assert(visTilesIt != visibleTiles.end()); if (!addTile(_tileSet, visTileId)) { // Not in cache - enqueue for loading enqueueTask(_tileSet, visTileId, _view); m_tilesInProgress++; } ++visTilesIt; } else { // tileSet has a tile not present in visibleTiles assert(curTilesIt != tiles.end()); auto& entry = curTilesIt->second; if (entry.getProxyCounter() > 0) { if (entry.isReady()) { m_tiles.push_back(entry.tile); } else if (curTileId.z < maxZoom) { // Cancel loading removeTiles.push_back(curTileId); } } else { removeTiles.push_back(curTileId); } entry.setVisible(false); ++curTilesIt; } } while (!removeTiles.empty()) { auto it = tiles.find(removeTiles.back()); removeTiles.pop_back(); if ((it != tiles.end()) && (!it->second.isVisible()) && (it->second.getProxyCounter() <= 0 || it->first.z >= maxZoom)) { clearProxyTiles(_tileSet, it->first, it->second, removeTiles); removeTile(_tileSet, it); } } for (auto& it : tiles) { auto& entry = it.second; #if LOG_LEVEL >= 3 size_t rasterLoading = 0; size_t rasterDone = 0; if (entry.task) { for (auto &raster : entry.task->subTasks()) { if (raster->isReady()) { rasterDone++; } else { rasterLoading++; } } } DBG("> %s - ready:%d proxy:%d/%d loading:%d rDone:%d rLoading:%d rPending:%d canceled:%d", it.first.toString().c_str(), entry.isReady(), entry.getProxyCounter(), entry.m_proxies, entry.task && !entry.task->isReady(), rasterDone, rasterLoading, entry.rastersPending(), entry.task && entry.task->isCanceled()); #endif if (entry.isInProgress()) { auto& id = it.first; auto& task = entry.task; // Update tile distance to map center for load priority. auto tileCenter = _view.mapProjection->TileCenter(id); double scaleDiv = exp2(id.z - _view.zoom); if (scaleDiv < 1) { scaleDiv = 0.1/scaleDiv; } // prefer parent tiles task->setPriority(glm::length2(tileCenter - _view.center) * scaleDiv); task->setProxyState(entry.getProxyCounter() > 0); } if (entry.isReady()) { // Mark as proxy entry.tile->setProxyState(entry.getProxyCounter() > 0); } } } void TileManager::enqueueTask(TileSet& _tileSet, const TileID& _tileID, const ViewState& _view) { // Keep the items sorted by distance auto tileCenter = _view.mapProjection->TileCenter(_tileID); double distance = glm::length2(tileCenter - _view.center); auto it = std::upper_bound(m_loadTasks.begin(), m_loadTasks.end(), distance, [](auto& distance, auto& other){ return distance < std::get<0>(other); }); m_loadTasks.insert(it, std::make_tuple(distance, &_tileSet, _tileID)); } void TileManager::loadTiles() { if (m_loadTasks.empty()) { return; } for (auto& loadTask : m_loadTasks) { auto tileId = std::get<2>(loadTask); auto& tileSet = *std::get<1>(loadTask); auto tileIt = tileSet.tiles.find(tileId); auto& entry = tileIt->second; tileSet.source->loadTileData(entry.task, m_dataCallback); } DBG("loading:%d pending:%d cache: %fMB", m_loadTasks.size(), m_loadPending, (double(m_tileCache->getMemoryUsage()) / (1024 * 1024))); m_loadTasks.clear(); } bool TileManager::addTile(TileSet& _tileSet, const TileID& _tileID) { auto tile = m_tileCache->get(_tileSet.source->id(), _tileID); if (tile) { if (tile->sourceGeneration() == _tileSet.source->generation()) { m_tiles.push_back(tile); // Reset tile on potential internal dynamic data set tile->resetState(); } else { // Clear stale tile data tile.reset(); } } // Add TileEntry to TileSet auto entry = _tileSet.tiles.emplace(_tileID, tile); if (!tile) { // Add Proxy if corresponding proxy MapTile ready updateProxyTiles(_tileSet, _tileID, entry.first->second); entry.first->second.task = _tileSet.source->createTask(_tileID); } entry.first->second.setVisible(true); return bool(tile); } void TileManager::removeTile(TileSet& _tileSet, std::map<TileID, TileEntry>::iterator& _tileIt) { auto& id = _tileIt->first; auto& entry = _tileIt->second; if (entry.isInProgress()) { entry.clearTask(); // 1. Remove from Datasource. Make sure to cancel // the network request associated with this tile. _tileSet.source->cancelLoadingTile(id); } else if (entry.isReady()) { // Add to cache auto poppedTiles = m_tileCache->put(_tileSet.source->id(), entry.tile); for (auto& tileID : poppedTiles) { _tileSet.source->clearRaster(tileID); } } // Remove rasters from this TileSource _tileSet.source->clearRaster(id); // Remove tile from set _tileIt = _tileSet.tiles.erase(_tileIt); } bool TileManager::updateProxyTile(TileSet& _tileSet, TileEntry& _tile, const TileID& _proxyTileId, const ProxyID _proxyId) { if (!_proxyTileId.isValid()) { return false; } auto& tiles = _tileSet.tiles; // check if the proxy exists in the visible tile set { const auto& it = tiles.find(_proxyTileId); if (it != tiles.end()) { auto& entry = it->second; if (!entry.isCanceled() && _tile.setProxy(_proxyId)) { entry.incProxyCounter(); if (entry.isReady()) { m_tiles.push_back(entry.tile); } // Note: No need to check the cache: When the tile is in // tileSet it would have already been fetched from cache return true; } } } // check if the proxy exists in the cache { auto proxyTile = m_tileCache->get(_tileSet.source->id(), _proxyTileId); if (proxyTile && _tile.setProxy(_proxyId)) { auto result = tiles.emplace(_proxyTileId, proxyTile); auto& entry = result.first->second; entry.incProxyCounter(); m_tiles.push_back(proxyTile); return true; } } return false; } void TileManager::updateProxyTiles(TileSet& _tileSet, const TileID& _tileID, TileEntry& _tile) { // TODO: this should be improved to use the nearest proxy tile available. // Currently it would use parent or grand*parent as proxies even if the // child proxies would be more appropriate // Try parent proxy auto zoomBias = _tileSet.source->zoomBias(); auto maxZoom = _tileSet.source->maxZoom(); auto parentID = _tileID.getParent(zoomBias); auto minZoom = _tileSet.source->minDisplayZoom(); if (minZoom <= parentID.z && updateProxyTile(_tileSet, _tile, parentID, ProxyID::parent)) { return; } // Try grandparent auto grandparentID = parentID.getParent(zoomBias); if (minZoom <= grandparentID.z && updateProxyTile(_tileSet, _tile, grandparentID, ProxyID::parent2)) { return; } // Try children if (maxZoom > _tileID.z) { for (int i = 0; i < 4; i++) { auto childID = _tileID.getChild(i, maxZoom); updateProxyTile(_tileSet, _tile, childID, static_cast<ProxyID>(1 << i)); } } } void TileManager::clearProxyTiles(TileSet& _tileSet, const TileID& _tileID, TileEntry& _tile, std::vector<TileID>& _removes) { auto& tiles = _tileSet.tiles; auto zoomBias = _tileSet.source->zoomBias(); auto maxZoom = _tileSet.source->maxZoom(); auto removeProxy = [&tiles,&_removes](TileID id) { auto it = tiles.find(id); if (it != tiles.end()) { auto& entry = it->second; entry.decProxyCounter(); if (entry.getProxyCounter() <= 0 && !entry.isVisible()) { _removes.push_back(id); } } }; // Check if grand parent proxy is present if (_tile.unsetProxy(ProxyID::parent2)) { TileID gparentID(_tileID.getParent(zoomBias).getParent(zoomBias)); removeProxy(gparentID); } // Check if parent proxy is present if (_tile.unsetProxy(ProxyID::parent)) { TileID parentID(_tileID.getParent(zoomBias)); removeProxy(parentID); } // Check if child proxies are present for (int i = 0; i < 4; i++) { if (_tile.unsetProxy(static_cast<ProxyID>(1 << i))) { TileID childID(_tileID.getChild(i, maxZoom)); removeProxy(childID); } } } void TileManager::setCacheSize(size_t _cacheSize) { m_tileCache->limitCacheSize(_cacheSize); } }
30.475362
107
0.568242
JungWonHyung
5e82b61df977500f5067014125164e44bfffa340
83,122
cpp
C++
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
5
2019-02-26T18:46:52.000Z
2022-01-27T23:48:26.000Z
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
1
2020-06-07T23:44:29.000Z
2021-04-03T18:49:54.000Z
Sources/Vulkan/erm/extensions/VkExtensions.cpp
JALB91/ERM
5d2c56db6330efc7d662c24796fdc49e43d26e40
[ "MIT" ]
null
null
null
#include "erm/extensions/VkExtensions.h" #include <assert.h> /* loaders */ /* /////////////////////////////////// */ #if VK_EXT_debug_marker static PFN_vkDebugMarkerSetObjectTagEXT pfn_vkDebugMarkerSetObjectTagEXT = 0; static PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT = 0; static PFN_vkCmdDebugMarkerBeginEXT pfn_vkCmdDebugMarkerBeginEXT = 0; static PFN_vkCmdDebugMarkerEndEXT pfn_vkCmdDebugMarkerEndEXT = 0; static PFN_vkCmdDebugMarkerInsertEXT pfn_vkCmdDebugMarkerInsertEXT = 0; # if defined(ERM_OSX) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wall" # pragma clang diagnostic ignored "-pedantic-errors" # pragma clang diagnostic ignored "-pedantic" # pragma clang diagnostic ignored "-Wextra" # endif VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo) { assert(pfn_vkDebugMarkerSetObjectTagEXT); return pfn_vkDebugMarkerSetObjectTagEXT(device, pTagInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo) { assert(pfn_vkDebugMarkerSetObjectNameEXT); return pfn_vkDebugMarkerSetObjectNameEXT(device, pNameInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT( VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { assert(pfn_vkCmdDebugMarkerBeginEXT); pfn_vkCmdDebugMarkerBeginEXT(commandBuffer, pMarkerInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT( VkCommandBuffer commandBuffer) { assert(pfn_vkCmdDebugMarkerEndEXT); pfn_vkCmdDebugMarkerEndEXT(commandBuffer); } VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo) { assert(pfn_vkCmdDebugMarkerInsertEXT); pfn_vkCmdDebugMarkerInsertEXT(commandBuffer, pMarkerInfo); } int has_VK_EXT_debug_marker = 0; int load_VK_EXT_debug_marker(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkDebugMarkerSetObjectTagEXT = (PFN_vkDebugMarkerSetObjectTagEXT)getDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT"); pfn_vkDebugMarkerSetObjectNameEXT = (PFN_vkDebugMarkerSetObjectNameEXT)getDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT"); pfn_vkCmdDebugMarkerBeginEXT = (PFN_vkCmdDebugMarkerBeginEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT"); pfn_vkCmdDebugMarkerEndEXT = (PFN_vkCmdDebugMarkerEndEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT"); pfn_vkCmdDebugMarkerInsertEXT = (PFN_vkCmdDebugMarkerInsertEXT)getDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT"); int success = 1; success = success && (pfn_vkDebugMarkerSetObjectTagEXT != 0); success = success && (pfn_vkDebugMarkerSetObjectNameEXT != 0); success = success && (pfn_vkCmdDebugMarkerBeginEXT != 0); success = success && (pfn_vkCmdDebugMarkerEndEXT != 0); success = success && (pfn_vkCmdDebugMarkerInsertEXT != 0); has_VK_EXT_debug_marker = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkGetMemoryWin32HandleKHR pfn_vkGetMemoryWin32HandleKHR = 0; static PFN_vkGetMemoryWin32HandlePropertiesKHR pfn_vkGetMemoryWin32HandlePropertiesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR( VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetMemoryWin32HandleKHR); return pfn_vkGetMemoryWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties) { assert(pfn_vkGetMemoryWin32HandlePropertiesKHR); return pfn_vkGetMemoryWin32HandlePropertiesKHR(device, handleType, handle, pMemoryWin32HandleProperties); } int has_VK_KHR_external_memory_win32 = 0; int load_VK_KHR_external_memory_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetMemoryWin32HandleKHR = (PFN_vkGetMemoryWin32HandleKHR)getDeviceProcAddr(device, "vkGetMemoryWin32HandleKHR"); pfn_vkGetMemoryWin32HandlePropertiesKHR = (PFN_vkGetMemoryWin32HandlePropertiesKHR)getDeviceProcAddr(device, "vkGetMemoryWin32HandlePropertiesKHR"); int success = 1; success = success && (pfn_vkGetMemoryWin32HandleKHR != 0); success = success && (pfn_vkGetMemoryWin32HandlePropertiesKHR != 0); has_VK_KHR_external_memory_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_memory_fd static PFN_vkGetMemoryFdKHR pfn_vkGetMemoryFdKHR = 0; static PFN_vkGetMemoryFdPropertiesKHR pfn_vkGetMemoryFdPropertiesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR( VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd) { assert(pfn_vkGetMemoryFdKHR); return pfn_vkGetMemoryFdKHR(device, pGetFdInfo, pFd); } VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR( VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR* pMemoryFdProperties) { assert(pfn_vkGetMemoryFdPropertiesKHR); return pfn_vkGetMemoryFdPropertiesKHR(device, handleType, fd, pMemoryFdProperties); } int has_VK_KHR_external_memory_fd = 0; int load_VK_KHR_external_memory_fd(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetMemoryFdKHR = (PFN_vkGetMemoryFdKHR)getDeviceProcAddr(device, "vkGetMemoryFdKHR"); pfn_vkGetMemoryFdPropertiesKHR = (PFN_vkGetMemoryFdPropertiesKHR)getDeviceProcAddr(device, "vkGetMemoryFdPropertiesKHR"); int success = 1; success = success && (pfn_vkGetMemoryFdKHR != 0); success = success && (pfn_vkGetMemoryFdPropertiesKHR != 0); has_VK_KHR_external_memory_fd = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkImportSemaphoreWin32HandleKHR pfn_vkImportSemaphoreWin32HandleKHR = 0; static PFN_vkGetSemaphoreWin32HandleKHR pfn_vkGetSemaphoreWin32HandleKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR( VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo) { assert(pfn_vkImportSemaphoreWin32HandleKHR); return pfn_vkImportSemaphoreWin32HandleKHR(device, pImportSemaphoreWin32HandleInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetSemaphoreWin32HandleKHR); return pfn_vkGetSemaphoreWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } int has_VK_KHR_external_semaphore_win32 = 0; int load_VK_KHR_external_semaphore_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportSemaphoreWin32HandleKHR = (PFN_vkImportSemaphoreWin32HandleKHR)getDeviceProcAddr(device, "vkImportSemaphoreWin32HandleKHR"); pfn_vkGetSemaphoreWin32HandleKHR = (PFN_vkGetSemaphoreWin32HandleKHR)getDeviceProcAddr(device, "vkGetSemaphoreWin32HandleKHR"); int success = 1; success = success && (pfn_vkImportSemaphoreWin32HandleKHR != 0); success = success && (pfn_vkGetSemaphoreWin32HandleKHR != 0); has_VK_KHR_external_semaphore_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_semaphore_fd static PFN_vkImportSemaphoreFdKHR pfn_vkImportSemaphoreFdKHR = 0; static PFN_vkGetSemaphoreFdKHR pfn_vkGetSemaphoreFdKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR( VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo) { assert(pfn_vkImportSemaphoreFdKHR); return pfn_vkImportSemaphoreFdKHR(device, pImportSemaphoreFdInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR( VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd) { assert(pfn_vkGetSemaphoreFdKHR); return pfn_vkGetSemaphoreFdKHR(device, pGetFdInfo, pFd); } int has_VK_KHR_external_semaphore_fd = 0; int load_VK_KHR_external_semaphore_fd(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportSemaphoreFdKHR = (PFN_vkImportSemaphoreFdKHR)getDeviceProcAddr(device, "vkImportSemaphoreFdKHR"); pfn_vkGetSemaphoreFdKHR = (PFN_vkGetSemaphoreFdKHR)getDeviceProcAddr(device, "vkGetSemaphoreFdKHR"); int success = 1; success = success && (pfn_vkImportSemaphoreFdKHR != 0); success = success && (pfn_vkGetSemaphoreFdKHR != 0); has_VK_KHR_external_semaphore_fd = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_push_descriptor static PFN_vkCmdPushDescriptorSetKHR pfn_vkCmdPushDescriptorSetKHR = 0; static PFN_vkCmdPushDescriptorSetWithTemplateKHR pfn_vkCmdPushDescriptorSetWithTemplateKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites) { assert(pfn_vkCmdPushDescriptorSetKHR); pfn_vkCmdPushDescriptorSetKHR(commandBuffer, pipelineBindPoint, layout, set, descriptorWriteCount, pDescriptorWrites); } VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplate descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData) { assert(pfn_vkCmdPushDescriptorSetWithTemplateKHR); pfn_vkCmdPushDescriptorSetWithTemplateKHR(commandBuffer, descriptorUpdateTemplate, layout, set, pData); } int has_VK_KHR_push_descriptor = 0; int load_VK_KHR_push_descriptor(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdPushDescriptorSetKHR = (PFN_vkCmdPushDescriptorSetKHR)getDeviceProcAddr(device, "vkCmdPushDescriptorSetKHR"); pfn_vkCmdPushDescriptorSetWithTemplateKHR = (PFN_vkCmdPushDescriptorSetWithTemplateKHR)getDeviceProcAddr(device, "vkCmdPushDescriptorSetWithTemplateKHR"); int success = 1; success = success && (pfn_vkCmdPushDescriptorSetKHR != 0); success = success && (pfn_vkCmdPushDescriptorSetWithTemplateKHR != 0); has_VK_KHR_push_descriptor = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_create_renderpass2 static PFN_vkCreateRenderPass2KHR pfn_vkCreateRenderPass2KHR = 0; static PFN_vkCmdBeginRenderPass2KHR pfn_vkCmdBeginRenderPass2KHR = 0; static PFN_vkCmdNextSubpass2KHR pfn_vkCmdNextSubpass2KHR = 0; static PFN_vkCmdEndRenderPass2KHR pfn_vkCmdEndRenderPass2KHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2KHR( VkDevice device, const VkRenderPassCreateInfo2KHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass) { assert(pfn_vkCreateRenderPass2KHR); return pfn_vkCreateRenderPass2KHR(device, pCreateInfo, pAllocator, pRenderPass); } VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2KHR( VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfoKHR* pSubpassBeginInfo) { assert(pfn_vkCmdBeginRenderPass2KHR); pfn_vkCmdBeginRenderPass2KHR(commandBuffer, pRenderPassBegin, pSubpassBeginInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2KHR( VkCommandBuffer commandBuffer, const VkSubpassBeginInfoKHR* pSubpassBeginInfo, const VkSubpassEndInfoKHR* pSubpassEndInfo) { assert(pfn_vkCmdNextSubpass2KHR); pfn_vkCmdNextSubpass2KHR(commandBuffer, pSubpassBeginInfo, pSubpassEndInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR( VkCommandBuffer commandBuffer, const VkSubpassEndInfoKHR* pSubpassEndInfo) { assert(pfn_vkCmdEndRenderPass2KHR); pfn_vkCmdEndRenderPass2KHR(commandBuffer, pSubpassEndInfo); } int has_VK_KHR_create_renderpass2 = 0; int load_VK_KHR_create_renderpass2(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateRenderPass2KHR = (PFN_vkCreateRenderPass2KHR)getDeviceProcAddr(device, "vkCreateRenderPass2KHR"); pfn_vkCmdBeginRenderPass2KHR = (PFN_vkCmdBeginRenderPass2KHR)getDeviceProcAddr(device, "vkCmdBeginRenderPass2KHR"); pfn_vkCmdNextSubpass2KHR = (PFN_vkCmdNextSubpass2KHR)getDeviceProcAddr(device, "vkCmdNextSubpass2KHR"); pfn_vkCmdEndRenderPass2KHR = (PFN_vkCmdEndRenderPass2KHR)getDeviceProcAddr(device, "vkCmdEndRenderPass2KHR"); int success = 1; success = success && (pfn_vkCreateRenderPass2KHR != 0); success = success && (pfn_vkCmdBeginRenderPass2KHR != 0); success = success && (pfn_vkCmdNextSubpass2KHR != 0); success = success && (pfn_vkCmdEndRenderPass2KHR != 0); has_VK_KHR_create_renderpass2 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) static PFN_vkImportFenceWin32HandleKHR pfn_vkImportFenceWin32HandleKHR = 0; static PFN_vkGetFenceWin32HandleKHR pfn_vkGetFenceWin32HandleKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR( VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo) { assert(pfn_vkImportFenceWin32HandleKHR); return pfn_vkImportFenceWin32HandleKHR(device, pImportFenceWin32HandleInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle) { assert(pfn_vkGetFenceWin32HandleKHR); return pfn_vkGetFenceWin32HandleKHR(device, pGetWin32HandleInfo, pHandle); } int has_VK_KHR_external_fence_win32 = 0; int load_VK_KHR_external_fence_win32(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkImportFenceWin32HandleKHR = (PFN_vkImportFenceWin32HandleKHR)getDeviceProcAddr(device, "vkImportFenceWin32HandleKHR"); pfn_vkGetFenceWin32HandleKHR = (PFN_vkGetFenceWin32HandleKHR)getDeviceProcAddr(device, "vkGetFenceWin32HandleKHR"); int success = 1; success = success && (pfn_vkImportFenceWin32HandleKHR != 0); success = success && (pfn_vkGetFenceWin32HandleKHR != 0); has_VK_KHR_external_fence_win32 = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_debug_utils static PFN_vkSetDebugUtilsObjectNameEXT pfn_vkSetDebugUtilsObjectNameEXT = 0; static PFN_vkSetDebugUtilsObjectTagEXT pfn_vkSetDebugUtilsObjectTagEXT = 0; static PFN_vkQueueBeginDebugUtilsLabelEXT pfn_vkQueueBeginDebugUtilsLabelEXT = 0; static PFN_vkQueueEndDebugUtilsLabelEXT pfn_vkQueueEndDebugUtilsLabelEXT = 0; static PFN_vkQueueInsertDebugUtilsLabelEXT pfn_vkQueueInsertDebugUtilsLabelEXT = 0; static PFN_vkCmdBeginDebugUtilsLabelEXT pfn_vkCmdBeginDebugUtilsLabelEXT = 0; static PFN_vkCmdEndDebugUtilsLabelEXT pfn_vkCmdEndDebugUtilsLabelEXT = 0; static PFN_vkCmdInsertDebugUtilsLabelEXT pfn_vkCmdInsertDebugUtilsLabelEXT = 0; static PFN_vkCreateDebugUtilsMessengerEXT pfn_vkCreateDebugUtilsMessengerEXT = 0; static PFN_vkDestroyDebugUtilsMessengerEXT pfn_vkDestroyDebugUtilsMessengerEXT = 0; static PFN_vkSubmitDebugUtilsMessageEXT pfn_vkSubmitDebugUtilsMessageEXT = 0; VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT( VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo) { assert(pfn_vkSetDebugUtilsObjectNameEXT); return pfn_vkSetDebugUtilsObjectNameEXT(device, pNameInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectTagEXT( VkDevice device, const VkDebugUtilsObjectTagInfoEXT* pTagInfo) { assert(pfn_vkSetDebugUtilsObjectTagEXT); return pfn_vkSetDebugUtilsObjectTagEXT(device, pTagInfo); } VKAPI_ATTR void VKAPI_CALL vkQueueBeginDebugUtilsLabelEXT( VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkQueueBeginDebugUtilsLabelEXT); pfn_vkQueueBeginDebugUtilsLabelEXT(queue, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkQueueEndDebugUtilsLabelEXT( VkQueue queue) { assert(pfn_vkQueueEndDebugUtilsLabelEXT); pfn_vkQueueEndDebugUtilsLabelEXT(queue); } VKAPI_ATTR void VKAPI_CALL vkQueueInsertDebugUtilsLabelEXT( VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkQueueInsertDebugUtilsLabelEXT); pfn_vkQueueInsertDebugUtilsLabelEXT(queue, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT( VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkCmdBeginDebugUtilsLabelEXT); pfn_vkCmdBeginDebugUtilsLabelEXT(commandBuffer, pLabelInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT( VkCommandBuffer commandBuffer) { assert(pfn_vkCmdEndDebugUtilsLabelEXT); pfn_vkCmdEndDebugUtilsLabelEXT(commandBuffer); } VKAPI_ATTR void VKAPI_CALL vkCmdInsertDebugUtilsLabelEXT( VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo) { assert(pfn_vkCmdInsertDebugUtilsLabelEXT); pfn_vkCmdInsertDebugUtilsLabelEXT(commandBuffer, pLabelInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT( VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger) { assert(pfn_vkCreateDebugUtilsMessengerEXT); return pfn_vkCreateDebugUtilsMessengerEXT(instance, pCreateInfo, pAllocator, pMessenger); } VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT( VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyDebugUtilsMessengerEXT); pfn_vkDestroyDebugUtilsMessengerEXT(instance, messenger, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT( VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData) { assert(pfn_vkSubmitDebugUtilsMessageEXT); pfn_vkSubmitDebugUtilsMessageEXT(instance, messageSeverity, messageTypes, pCallbackData); } int has_VK_EXT_debug_utils = 0; int load_VK_EXT_debug_utils(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkSetDebugUtilsObjectNameEXT = (PFN_vkSetDebugUtilsObjectNameEXT)getDeviceProcAddr(device, "vkSetDebugUtilsObjectNameEXT"); pfn_vkSetDebugUtilsObjectTagEXT = (PFN_vkSetDebugUtilsObjectTagEXT)getDeviceProcAddr(device, "vkSetDebugUtilsObjectTagEXT"); pfn_vkQueueBeginDebugUtilsLabelEXT = (PFN_vkQueueBeginDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueBeginDebugUtilsLabelEXT"); pfn_vkQueueEndDebugUtilsLabelEXT = (PFN_vkQueueEndDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueEndDebugUtilsLabelEXT"); pfn_vkQueueInsertDebugUtilsLabelEXT = (PFN_vkQueueInsertDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkQueueInsertDebugUtilsLabelEXT"); pfn_vkCmdBeginDebugUtilsLabelEXT = (PFN_vkCmdBeginDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdBeginDebugUtilsLabelEXT"); pfn_vkCmdEndDebugUtilsLabelEXT = (PFN_vkCmdEndDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdEndDebugUtilsLabelEXT"); pfn_vkCmdInsertDebugUtilsLabelEXT = (PFN_vkCmdInsertDebugUtilsLabelEXT)getDeviceProcAddr(device, "vkCmdInsertDebugUtilsLabelEXT"); pfn_vkCreateDebugUtilsMessengerEXT = (PFN_vkCreateDebugUtilsMessengerEXT)getInstanceProcAddr(instance, "vkCreateDebugUtilsMessengerEXT"); pfn_vkDestroyDebugUtilsMessengerEXT = (PFN_vkDestroyDebugUtilsMessengerEXT)getInstanceProcAddr(instance, "vkDestroyDebugUtilsMessengerEXT"); pfn_vkSubmitDebugUtilsMessageEXT = (PFN_vkSubmitDebugUtilsMessageEXT)getInstanceProcAddr(instance, "vkSubmitDebugUtilsMessageEXT"); int success = 1; success = success && (pfn_vkSetDebugUtilsObjectNameEXT != 0); success = success && (pfn_vkSetDebugUtilsObjectTagEXT != 0); success = success && (pfn_vkQueueBeginDebugUtilsLabelEXT != 0); success = success && (pfn_vkQueueEndDebugUtilsLabelEXT != 0); success = success && (pfn_vkQueueInsertDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdBeginDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdEndDebugUtilsLabelEXT != 0); success = success && (pfn_vkCmdInsertDebugUtilsLabelEXT != 0); success = success && (pfn_vkCreateDebugUtilsMessengerEXT != 0); success = success && (pfn_vkDestroyDebugUtilsMessengerEXT != 0); success = success && (pfn_vkSubmitDebugUtilsMessageEXT != 0); has_VK_EXT_debug_utils = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_sample_locations static PFN_vkCmdSetSampleLocationsEXT pfn_vkCmdSetSampleLocationsEXT = 0; static PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = 0; VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEXT( VkCommandBuffer commandBuffer, const VkSampleLocationsInfoEXT* pSampleLocationsInfo) { assert(pfn_vkCmdSetSampleLocationsEXT); pfn_vkCmdSetSampleLocationsEXT(commandBuffer, pSampleLocationsInfo); } VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT( VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples, VkMultisamplePropertiesEXT* pMultisampleProperties) { assert(pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT); pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT(physicalDevice, samples, pMultisampleProperties); } int has_VK_EXT_sample_locations = 0; int load_VK_EXT_sample_locations(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdSetSampleLocationsEXT = (PFN_vkCmdSetSampleLocationsEXT)getDeviceProcAddr(device, "vkCmdSetSampleLocationsEXT"); pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = (PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)getDeviceProcAddr(device, "vkGetPhysicalDeviceMultisamplePropertiesEXT"); int success = 1; success = success && (pfn_vkCmdSetSampleLocationsEXT != 0); success = success && (pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT != 0); has_VK_EXT_sample_locations = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_acceleration_structure static PFN_vkCreateAccelerationStructureKHR pfn_vkCreateAccelerationStructureKHR = 0; static PFN_vkDestroyAccelerationStructureKHR pfn_vkDestroyAccelerationStructureKHR = 0; static PFN_vkCmdBuildAccelerationStructuresKHR pfn_vkCmdBuildAccelerationStructuresKHR = 0; static PFN_vkCmdBuildAccelerationStructuresIndirectKHR pfn_vkCmdBuildAccelerationStructuresIndirectKHR = 0; static PFN_vkBuildAccelerationStructuresKHR pfn_vkBuildAccelerationStructuresKHR = 0; static PFN_vkCopyAccelerationStructureKHR pfn_vkCopyAccelerationStructureKHR = 0; static PFN_vkCopyAccelerationStructureToMemoryKHR pfn_vkCopyAccelerationStructureToMemoryKHR = 0; static PFN_vkCopyMemoryToAccelerationStructureKHR pfn_vkCopyMemoryToAccelerationStructureKHR = 0; static PFN_vkWriteAccelerationStructuresPropertiesKHR pfn_vkWriteAccelerationStructuresPropertiesKHR = 0; static PFN_vkCmdCopyAccelerationStructureKHR pfn_vkCmdCopyAccelerationStructureKHR = 0; static PFN_vkCmdCopyAccelerationStructureToMemoryKHR pfn_vkCmdCopyAccelerationStructureToMemoryKHR = 0; static PFN_vkCmdCopyMemoryToAccelerationStructureKHR pfn_vkCmdCopyMemoryToAccelerationStructureKHR = 0; static PFN_vkGetAccelerationStructureDeviceAddressKHR pfn_vkGetAccelerationStructureDeviceAddressKHR = 0; static PFN_vkCmdWriteAccelerationStructuresPropertiesKHR pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = 0; static PFN_vkGetDeviceAccelerationStructureCompatibilityKHR pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = 0; static PFN_vkGetAccelerationStructureBuildSizesKHR pfn_vkGetAccelerationStructureBuildSizesKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureKHR( VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureKHR* pAccelerationStructure) { assert(pfn_vkCreateAccelerationStructureKHR); return pfn_vkCreateAccelerationStructureKHR(device, pCreateInfo, pAllocator, pAccelerationStructure); } VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureKHR( VkDevice device, VkAccelerationStructureKHR accelerationStructure, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyAccelerationStructureKHR); pfn_vkDestroyAccelerationStructureKHR(device, accelerationStructure, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresKHR( VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos) { assert(pfn_vkCmdBuildAccelerationStructuresKHR); pfn_vkCmdBuildAccelerationStructuresKHR(commandBuffer, infoCount, pInfos, ppBuildRangeInfos); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresIndirectKHR( VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkDeviceAddress* pIndirectDeviceAddresses, const uint32_t* pIndirectStrides, const uint32_t* const* ppMaxPrimitiveCounts) { assert(pfn_vkCmdBuildAccelerationStructuresIndirectKHR); pfn_vkCmdBuildAccelerationStructuresIndirectKHR(commandBuffer, infoCount, pInfos, pIndirectDeviceAddresses, pIndirectStrides, ppMaxPrimitiveCounts); } VKAPI_ATTR VkResult VKAPI_CALL vkBuildAccelerationStructuresKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos) { assert(pfn_vkBuildAccelerationStructuresKHR); return pfn_vkBuildAccelerationStructuresKHR(device, deferredOperation, infoCount, pInfos, ppBuildRangeInfos); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCopyAccelerationStructureKHR); return pfn_vkCopyAccelerationStructureKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureToMemoryKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo) { assert(pfn_vkCopyAccelerationStructureToMemoryKHR); return pfn_vkCopyAccelerationStructureToMemoryKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToAccelerationStructureKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCopyMemoryToAccelerationStructureKHR); return pfn_vkCopyMemoryToAccelerationStructureKHR(device, deferredOperation, pInfo); } VKAPI_ATTR VkResult VKAPI_CALL vkWriteAccelerationStructuresPropertiesKHR( VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, size_t dataSize, void* pData, size_t stride) { assert(pfn_vkWriteAccelerationStructuresPropertiesKHR); return pfn_vkWriteAccelerationStructuresPropertiesKHR(device, accelerationStructureCount, pAccelerationStructures, queryType, dataSize, pData, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureKHR( VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCmdCopyAccelerationStructureKHR); pfn_vkCmdCopyAccelerationStructureKHR(commandBuffer, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureToMemoryKHR( VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo) { assert(pfn_vkCmdCopyAccelerationStructureToMemoryKHR); pfn_vkCmdCopyAccelerationStructureToMemoryKHR(commandBuffer, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToAccelerationStructureKHR( VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo) { assert(pfn_vkCmdCopyMemoryToAccelerationStructureKHR); pfn_vkCmdCopyMemoryToAccelerationStructureKHR(commandBuffer, pInfo); } VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetAccelerationStructureDeviceAddressKHR( VkDevice device, const VkAccelerationStructureDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetAccelerationStructureDeviceAddressKHR); return pfn_vkGetAccelerationStructureDeviceAddressKHR(device, pInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesKHR( VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) { assert(pfn_vkCmdWriteAccelerationStructuresPropertiesKHR); pfn_vkCmdWriteAccelerationStructuresPropertiesKHR(commandBuffer, accelerationStructureCount, pAccelerationStructures, queryType, queryPool, firstQuery); } VKAPI_ATTR void VKAPI_CALL vkGetDeviceAccelerationStructureCompatibilityKHR( VkDevice device, const VkAccelerationStructureVersionInfoKHR* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility) { assert(pfn_vkGetDeviceAccelerationStructureCompatibilityKHR); pfn_vkGetDeviceAccelerationStructureCompatibilityKHR(device, pVersionInfo, pCompatibility); } VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureBuildSizesKHR( VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR* pBuildInfo, const uint32_t* pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo) { assert(pfn_vkGetAccelerationStructureBuildSizesKHR); pfn_vkGetAccelerationStructureBuildSizesKHR(device, buildType, pBuildInfo, pMaxPrimitiveCounts, pSizeInfo); } int has_VK_KHR_acceleration_structure = 0; int load_VK_KHR_acceleration_structure(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateAccelerationStructureKHR = (PFN_vkCreateAccelerationStructureKHR)getDeviceProcAddr(device, "vkCreateAccelerationStructureKHR"); pfn_vkDestroyAccelerationStructureKHR = (PFN_vkDestroyAccelerationStructureKHR)getDeviceProcAddr(device, "vkDestroyAccelerationStructureKHR"); pfn_vkCmdBuildAccelerationStructuresKHR = (PFN_vkCmdBuildAccelerationStructuresKHR)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresKHR"); pfn_vkCmdBuildAccelerationStructuresIndirectKHR = (PFN_vkCmdBuildAccelerationStructuresIndirectKHR)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructuresIndirectKHR"); pfn_vkBuildAccelerationStructuresKHR = (PFN_vkBuildAccelerationStructuresKHR)getDeviceProcAddr(device, "vkBuildAccelerationStructuresKHR"); pfn_vkCopyAccelerationStructureKHR = (PFN_vkCopyAccelerationStructureKHR)getDeviceProcAddr(device, "vkCopyAccelerationStructureKHR"); pfn_vkCopyAccelerationStructureToMemoryKHR = (PFN_vkCopyAccelerationStructureToMemoryKHR)getDeviceProcAddr(device, "vkCopyAccelerationStructureToMemoryKHR"); pfn_vkCopyMemoryToAccelerationStructureKHR = (PFN_vkCopyMemoryToAccelerationStructureKHR)getDeviceProcAddr(device, "vkCopyMemoryToAccelerationStructureKHR"); pfn_vkWriteAccelerationStructuresPropertiesKHR = (PFN_vkWriteAccelerationStructuresPropertiesKHR)getDeviceProcAddr(device, "vkWriteAccelerationStructuresPropertiesKHR"); pfn_vkCmdCopyAccelerationStructureKHR = (PFN_vkCmdCopyAccelerationStructureKHR)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureKHR"); pfn_vkCmdCopyAccelerationStructureToMemoryKHR = (PFN_vkCmdCopyAccelerationStructureToMemoryKHR)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureToMemoryKHR"); pfn_vkCmdCopyMemoryToAccelerationStructureKHR = (PFN_vkCmdCopyMemoryToAccelerationStructureKHR)getDeviceProcAddr(device, "vkCmdCopyMemoryToAccelerationStructureKHR"); pfn_vkGetAccelerationStructureDeviceAddressKHR = (PFN_vkGetAccelerationStructureDeviceAddressKHR)getDeviceProcAddr(device, "vkGetAccelerationStructureDeviceAddressKHR"); pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = (PFN_vkCmdWriteAccelerationStructuresPropertiesKHR)getDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesKHR"); pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = (PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)getDeviceProcAddr(device, "vkGetDeviceAccelerationStructureCompatibilityKHR"); pfn_vkGetAccelerationStructureBuildSizesKHR = (PFN_vkGetAccelerationStructureBuildSizesKHR)getDeviceProcAddr(device, "vkGetAccelerationStructureBuildSizesKHR"); int success = 1; success = success && (pfn_vkCreateAccelerationStructureKHR != 0); success = success && (pfn_vkDestroyAccelerationStructureKHR != 0); success = success && (pfn_vkCmdBuildAccelerationStructuresKHR != 0); success = success && (pfn_vkCmdBuildAccelerationStructuresIndirectKHR != 0); success = success && (pfn_vkBuildAccelerationStructuresKHR != 0); success = success && (pfn_vkCopyAccelerationStructureKHR != 0); success = success && (pfn_vkCopyAccelerationStructureToMemoryKHR != 0); success = success && (pfn_vkCopyMemoryToAccelerationStructureKHR != 0); success = success && (pfn_vkWriteAccelerationStructuresPropertiesKHR != 0); success = success && (pfn_vkCmdCopyAccelerationStructureKHR != 0); success = success && (pfn_vkCmdCopyAccelerationStructureToMemoryKHR != 0); success = success && (pfn_vkCmdCopyMemoryToAccelerationStructureKHR != 0); success = success && (pfn_vkGetAccelerationStructureDeviceAddressKHR != 0); success = success && (pfn_vkCmdWriteAccelerationStructuresPropertiesKHR != 0); success = success && (pfn_vkGetDeviceAccelerationStructureCompatibilityKHR != 0); success = success && (pfn_vkGetAccelerationStructureBuildSizesKHR != 0); has_VK_KHR_acceleration_structure = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_ray_tracing_pipeline static PFN_vkCmdTraceRaysKHR pfn_vkCmdTraceRaysKHR = 0; static PFN_vkCreateRayTracingPipelinesKHR pfn_vkCreateRayTracingPipelinesKHR = 0; static PFN_vkGetRayTracingShaderGroupHandlesKHR pfn_vkGetRayTracingShaderGroupHandlesKHR = 0; static PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = 0; static PFN_vkCmdTraceRaysIndirectKHR pfn_vkCmdTraceRaysIndirectKHR = 0; static PFN_vkGetRayTracingShaderGroupStackSizeKHR pfn_vkGetRayTracingShaderGroupStackSizeKHR = 0; static PFN_vkCmdSetRayTracingPipelineStackSizeKHR pfn_vkCmdSetRayTracingPipelineStackSizeKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysKHR( VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width, uint32_t height, uint32_t depth) { assert(pfn_vkCmdTraceRaysKHR); pfn_vkCmdTraceRaysKHR(commandBuffer, pRaygenShaderBindingTable, pMissShaderBindingTable, pHitShaderBindingTable, pCallableShaderBindingTable, width, height, depth); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesKHR( VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) { assert(pfn_vkCreateRayTracingPipelinesKHR); return pfn_vkCreateRayTracingPipelinesKHR(device, deferredOperation, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesKHR( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingShaderGroupHandlesKHR); return pfn_vkGetRayTracingShaderGroupHandlesKHR(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingCaptureReplayShaderGroupHandlesKHR( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR); return pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirectKHR( VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) { assert(pfn_vkCmdTraceRaysIndirectKHR); pfn_vkCmdTraceRaysIndirectKHR(commandBuffer, pRaygenShaderBindingTable, pMissShaderBindingTable, pHitShaderBindingTable, pCallableShaderBindingTable, indirectDeviceAddress); } VKAPI_ATTR VkDeviceSize VKAPI_CALL vkGetRayTracingShaderGroupStackSizeKHR( VkDevice device, VkPipeline pipeline, uint32_t group, VkShaderGroupShaderKHR groupShader) { assert(pfn_vkGetRayTracingShaderGroupStackSizeKHR); return pfn_vkGetRayTracingShaderGroupStackSizeKHR(device, pipeline, group, groupShader); } VKAPI_ATTR void VKAPI_CALL vkCmdSetRayTracingPipelineStackSizeKHR( VkCommandBuffer commandBuffer, uint32_t pipelineStackSize) { assert(pfn_vkCmdSetRayTracingPipelineStackSizeKHR); pfn_vkCmdSetRayTracingPipelineStackSizeKHR(commandBuffer, pipelineStackSize); } int has_VK_KHR_ray_tracing_pipeline = 0; int load_VK_KHR_ray_tracing_pipeline(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdTraceRaysKHR = (PFN_vkCmdTraceRaysKHR)getDeviceProcAddr(device, "vkCmdTraceRaysKHR"); pfn_vkCreateRayTracingPipelinesKHR = (PFN_vkCreateRayTracingPipelinesKHR)getDeviceProcAddr(device, "vkCreateRayTracingPipelinesKHR"); pfn_vkGetRayTracingShaderGroupHandlesKHR = (PFN_vkGetRayTracingShaderGroupHandlesKHR)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesKHR"); pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = (PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)getDeviceProcAddr(device, "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR"); pfn_vkCmdTraceRaysIndirectKHR = (PFN_vkCmdTraceRaysIndirectKHR)getDeviceProcAddr(device, "vkCmdTraceRaysIndirectKHR"); pfn_vkGetRayTracingShaderGroupStackSizeKHR = (PFN_vkGetRayTracingShaderGroupStackSizeKHR)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupStackSizeKHR"); pfn_vkCmdSetRayTracingPipelineStackSizeKHR = (PFN_vkCmdSetRayTracingPipelineStackSizeKHR)getDeviceProcAddr(device, "vkCmdSetRayTracingPipelineStackSizeKHR"); int success = 1; success = success && (pfn_vkCmdTraceRaysKHR != 0); success = success && (pfn_vkCreateRayTracingPipelinesKHR != 0); success = success && (pfn_vkGetRayTracingShaderGroupHandlesKHR != 0); success = success && (pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR != 0); success = success && (pfn_vkCmdTraceRaysIndirectKHR != 0); success = success && (pfn_vkGetRayTracingShaderGroupStackSizeKHR != 0); success = success && (pfn_vkCmdSetRayTracingPipelineStackSizeKHR != 0); has_VK_KHR_ray_tracing_pipeline = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_shading_rate_image static PFN_vkCmdBindShadingRateImageNV pfn_vkCmdBindShadingRateImageNV = 0; static PFN_vkCmdSetViewportShadingRatePaletteNV pfn_vkCmdSetViewportShadingRatePaletteNV = 0; static PFN_vkCmdSetCoarseSampleOrderNV pfn_vkCmdSetCoarseSampleOrderNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdBindShadingRateImageNV( VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout) { assert(pfn_vkCmdBindShadingRateImageNV); pfn_vkCmdBindShadingRateImageNV(commandBuffer, imageView, imageLayout); } VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportShadingRatePaletteNV( VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkShadingRatePaletteNV* pShadingRatePalettes) { assert(pfn_vkCmdSetViewportShadingRatePaletteNV); pfn_vkCmdSetViewportShadingRatePaletteNV(commandBuffer, firstViewport, viewportCount, pShadingRatePalettes); } VKAPI_ATTR void VKAPI_CALL vkCmdSetCoarseSampleOrderNV( VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, const VkCoarseSampleOrderCustomNV* pCustomSampleOrders) { assert(pfn_vkCmdSetCoarseSampleOrderNV); pfn_vkCmdSetCoarseSampleOrderNV(commandBuffer, sampleOrderType, customSampleOrderCount, pCustomSampleOrders); } int has_VK_NV_shading_rate_image = 0; int load_VK_NV_shading_rate_image(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdBindShadingRateImageNV = (PFN_vkCmdBindShadingRateImageNV)getDeviceProcAddr(device, "vkCmdBindShadingRateImageNV"); pfn_vkCmdSetViewportShadingRatePaletteNV = (PFN_vkCmdSetViewportShadingRatePaletteNV)getDeviceProcAddr(device, "vkCmdSetViewportShadingRatePaletteNV"); pfn_vkCmdSetCoarseSampleOrderNV = (PFN_vkCmdSetCoarseSampleOrderNV)getDeviceProcAddr(device, "vkCmdSetCoarseSampleOrderNV"); int success = 1; success = success && (pfn_vkCmdBindShadingRateImageNV != 0); success = success && (pfn_vkCmdSetViewportShadingRatePaletteNV != 0); success = success && (pfn_vkCmdSetCoarseSampleOrderNV != 0); has_VK_NV_shading_rate_image = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_ray_tracing static PFN_vkCreateAccelerationStructureNV pfn_vkCreateAccelerationStructureNV = 0; static PFN_vkDestroyAccelerationStructureNV pfn_vkDestroyAccelerationStructureNV = 0; static PFN_vkGetAccelerationStructureMemoryRequirementsNV pfn_vkGetAccelerationStructureMemoryRequirementsNV = 0; static PFN_vkBindAccelerationStructureMemoryNV pfn_vkBindAccelerationStructureMemoryNV = 0; static PFN_vkCmdBuildAccelerationStructureNV pfn_vkCmdBuildAccelerationStructureNV = 0; static PFN_vkCmdCopyAccelerationStructureNV pfn_vkCmdCopyAccelerationStructureNV = 0; static PFN_vkCmdTraceRaysNV pfn_vkCmdTraceRaysNV = 0; static PFN_vkCreateRayTracingPipelinesNV pfn_vkCreateRayTracingPipelinesNV = 0; static PFN_vkGetRayTracingShaderGroupHandlesNV pfn_vkGetRayTracingShaderGroupHandlesNV = 0; static PFN_vkGetAccelerationStructureHandleNV pfn_vkGetAccelerationStructureHandleNV = 0; static PFN_vkCmdWriteAccelerationStructuresPropertiesNV pfn_vkCmdWriteAccelerationStructuresPropertiesNV = 0; static PFN_vkCompileDeferredNV pfn_vkCompileDeferredNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureNV( VkDevice device, const VkAccelerationStructureCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureNV* pAccelerationStructure) { assert(pfn_vkCreateAccelerationStructureNV); return pfn_vkCreateAccelerationStructureNV(device, pCreateInfo, pAllocator, pAccelerationStructure); } VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureNV( VkDevice device, VkAccelerationStructureNV accelerationStructure, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyAccelerationStructureNV); pfn_vkDestroyAccelerationStructureNV(device, accelerationStructure, pAllocator); } VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureMemoryRequirementsNV( VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements) { assert(pfn_vkGetAccelerationStructureMemoryRequirementsNV); pfn_vkGetAccelerationStructureMemoryRequirementsNV(device, pInfo, pMemoryRequirements); } VKAPI_ATTR VkResult VKAPI_CALL vkBindAccelerationStructureMemoryNV( VkDevice device, uint32_t bindInfoCount, const VkBindAccelerationStructureMemoryInfoNV* pBindInfos) { assert(pfn_vkBindAccelerationStructureMemoryNV); return pfn_vkBindAccelerationStructureMemoryNV(device, bindInfoCount, pBindInfos); } VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureNV( VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo, VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkBuffer scratch, VkDeviceSize scratchOffset) { assert(pfn_vkCmdBuildAccelerationStructureNV); pfn_vkCmdBuildAccelerationStructureNV(commandBuffer, pInfo, instanceData, instanceOffset, update, dst, src, scratch, scratchOffset); } VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureNV( VkCommandBuffer commandBuffer, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkCopyAccelerationStructureModeNV mode) { assert(pfn_vkCmdCopyAccelerationStructureNV); pfn_vkCmdCopyAccelerationStructureNV(commandBuffer, dst, src, mode); } VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysNV( VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, uint32_t width, uint32_t height, uint32_t depth) { assert(pfn_vkCmdTraceRaysNV); pfn_vkCmdTraceRaysNV(commandBuffer, raygenShaderBindingTableBuffer, raygenShaderBindingOffset, missShaderBindingTableBuffer, missShaderBindingOffset, missShaderBindingStride, hitShaderBindingTableBuffer, hitShaderBindingOffset, hitShaderBindingStride, callableShaderBindingTableBuffer, callableShaderBindingOffset, callableShaderBindingStride, width, height, depth); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesNV( VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoNV* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines) { assert(pfn_vkCreateRayTracingPipelinesNV); return pfn_vkCreateRayTracingPipelinesNV(device, pipelineCache, createInfoCount, pCreateInfos, pAllocator, pPipelines); } VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesNV( VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData) { assert(pfn_vkGetRayTracingShaderGroupHandlesNV); return pfn_vkGetRayTracingShaderGroupHandlesNV(device, pipeline, firstGroup, groupCount, dataSize, pData); } VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureHandleNV( VkDevice device, VkAccelerationStructureNV accelerationStructure, size_t dataSize, void* pData) { assert(pfn_vkGetAccelerationStructureHandleNV); return pfn_vkGetAccelerationStructureHandleNV(device, accelerationStructure, dataSize, pData); } VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesNV( VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) { assert(pfn_vkCmdWriteAccelerationStructuresPropertiesNV); pfn_vkCmdWriteAccelerationStructuresPropertiesNV(commandBuffer, accelerationStructureCount, pAccelerationStructures, queryType, queryPool, firstQuery); } VKAPI_ATTR VkResult VKAPI_CALL vkCompileDeferredNV( VkDevice device, VkPipeline pipeline, uint32_t shader) { assert(pfn_vkCompileDeferredNV); return pfn_vkCompileDeferredNV(device, pipeline, shader); } int has_VK_NV_ray_tracing = 0; int load_VK_NV_ray_tracing(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCreateAccelerationStructureNV = (PFN_vkCreateAccelerationStructureNV)getDeviceProcAddr(device, "vkCreateAccelerationStructureNV"); pfn_vkDestroyAccelerationStructureNV = (PFN_vkDestroyAccelerationStructureNV)getDeviceProcAddr(device, "vkDestroyAccelerationStructureNV"); pfn_vkGetAccelerationStructureMemoryRequirementsNV = (PFN_vkGetAccelerationStructureMemoryRequirementsNV)getDeviceProcAddr(device, "vkGetAccelerationStructureMemoryRequirementsNV"); pfn_vkBindAccelerationStructureMemoryNV = (PFN_vkBindAccelerationStructureMemoryNV)getDeviceProcAddr(device, "vkBindAccelerationStructureMemoryNV"); pfn_vkCmdBuildAccelerationStructureNV = (PFN_vkCmdBuildAccelerationStructureNV)getDeviceProcAddr(device, "vkCmdBuildAccelerationStructureNV"); pfn_vkCmdCopyAccelerationStructureNV = (PFN_vkCmdCopyAccelerationStructureNV)getDeviceProcAddr(device, "vkCmdCopyAccelerationStructureNV"); pfn_vkCmdTraceRaysNV = (PFN_vkCmdTraceRaysNV)getDeviceProcAddr(device, "vkCmdTraceRaysNV"); pfn_vkCreateRayTracingPipelinesNV = (PFN_vkCreateRayTracingPipelinesNV)getDeviceProcAddr(device, "vkCreateRayTracingPipelinesNV"); pfn_vkGetRayTracingShaderGroupHandlesNV = (PFN_vkGetRayTracingShaderGroupHandlesNV)getDeviceProcAddr(device, "vkGetRayTracingShaderGroupHandlesNV"); pfn_vkGetAccelerationStructureHandleNV = (PFN_vkGetAccelerationStructureHandleNV)getDeviceProcAddr(device, "vkGetAccelerationStructureHandleNV"); pfn_vkCmdWriteAccelerationStructuresPropertiesNV = (PFN_vkCmdWriteAccelerationStructuresPropertiesNV)getDeviceProcAddr(device, "vkCmdWriteAccelerationStructuresPropertiesNV"); pfn_vkCompileDeferredNV = (PFN_vkCompileDeferredNV)getDeviceProcAddr(device, "vkCompileDeferredNV"); int success = 1; success = success && (pfn_vkCreateAccelerationStructureNV != 0); success = success && (pfn_vkDestroyAccelerationStructureNV != 0); success = success && (pfn_vkGetAccelerationStructureMemoryRequirementsNV != 0); success = success && (pfn_vkBindAccelerationStructureMemoryNV != 0); success = success && (pfn_vkCmdBuildAccelerationStructureNV != 0); success = success && (pfn_vkCmdCopyAccelerationStructureNV != 0); success = success && (pfn_vkCmdTraceRaysNV != 0); success = success && (pfn_vkCreateRayTracingPipelinesNV != 0); success = success && (pfn_vkGetRayTracingShaderGroupHandlesNV != 0); success = success && (pfn_vkGetAccelerationStructureHandleNV != 0); success = success && (pfn_vkCmdWriteAccelerationStructuresPropertiesNV != 0); success = success && (pfn_vkCompileDeferredNV != 0); has_VK_NV_ray_tracing = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_draw_indirect_count static PFN_vkCmdDrawIndirectCountKHR pfn_vkCmdDrawIndirectCountKHR = 0; static PFN_vkCmdDrawIndexedIndirectCountKHR pfn_vkCmdDrawIndexedIndirectCountKHR = 0; VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountKHR( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawIndirectCountKHR); pfn_vkCmdDrawIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawIndexedIndirectCountKHR); pfn_vkCmdDrawIndexedIndirectCountKHR(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } int has_VK_KHR_draw_indirect_count = 0; int load_VK_KHR_draw_indirect_count(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdDrawIndirectCountKHR = (PFN_vkCmdDrawIndirectCountKHR)getDeviceProcAddr(device, "vkCmdDrawIndirectCountKHR"); pfn_vkCmdDrawIndexedIndirectCountKHR = (PFN_vkCmdDrawIndexedIndirectCountKHR)getDeviceProcAddr(device, "vkCmdDrawIndexedIndirectCountKHR"); int success = 1; success = success && (pfn_vkCmdDrawIndirectCountKHR != 0); success = success && (pfn_vkCmdDrawIndexedIndirectCountKHR != 0); has_VK_KHR_draw_indirect_count = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_calibrated_timestamps static PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = 0; static PFN_vkGetCalibratedTimestampsEXT pfn_vkGetCalibratedTimestampsEXT = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainEXT* pTimeDomains) { assert(pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT); return pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT(physicalDevice, pTimeDomainCount, pTimeDomains); } VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT( VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation) { assert(pfn_vkGetCalibratedTimestampsEXT); return pfn_vkGetCalibratedTimestampsEXT(device, timestampCount, pTimestampInfos, pTimestamps, pMaxDeviation); } int has_VK_EXT_calibrated_timestamps = 0; int load_VK_EXT_calibrated_timestamps(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)getDeviceProcAddr(device, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT"); pfn_vkGetCalibratedTimestampsEXT = (PFN_vkGetCalibratedTimestampsEXT)getDeviceProcAddr(device, "vkGetCalibratedTimestampsEXT"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT != 0); success = success && (pfn_vkGetCalibratedTimestampsEXT != 0); has_VK_EXT_calibrated_timestamps = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_mesh_shader static PFN_vkCmdDrawMeshTasksNV pfn_vkCmdDrawMeshTasksNV = 0; static PFN_vkCmdDrawMeshTasksIndirectNV pfn_vkCmdDrawMeshTasksIndirectNV = 0; static PFN_vkCmdDrawMeshTasksIndirectCountNV pfn_vkCmdDrawMeshTasksIndirectCountNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksNV( VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask) { assert(pfn_vkCmdDrawMeshTasksNV); pfn_vkCmdDrawMeshTasksNV(commandBuffer, taskCount, firstTask); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectNV( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride) { assert(pfn_vkCmdDrawMeshTasksIndirectNV); pfn_vkCmdDrawMeshTasksIndirectNV(commandBuffer, buffer, offset, drawCount, stride); } VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride) { assert(pfn_vkCmdDrawMeshTasksIndirectCountNV); pfn_vkCmdDrawMeshTasksIndirectCountNV(commandBuffer, buffer, offset, countBuffer, countBufferOffset, maxDrawCount, stride); } int has_VK_NV_mesh_shader = 0; int load_VK_NV_mesh_shader(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdDrawMeshTasksNV = (PFN_vkCmdDrawMeshTasksNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksNV"); pfn_vkCmdDrawMeshTasksIndirectNV = (PFN_vkCmdDrawMeshTasksIndirectNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectNV"); pfn_vkCmdDrawMeshTasksIndirectCountNV = (PFN_vkCmdDrawMeshTasksIndirectCountNV)getDeviceProcAddr(device, "vkCmdDrawMeshTasksIndirectCountNV"); int success = 1; success = success && (pfn_vkCmdDrawMeshTasksNV != 0); success = success && (pfn_vkCmdDrawMeshTasksIndirectNV != 0); success = success && (pfn_vkCmdDrawMeshTasksIndirectCountNV != 0); has_VK_NV_mesh_shader = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_scissor_exclusive static PFN_vkCmdSetExclusiveScissorNV pfn_vkCmdSetExclusiveScissorNV = 0; VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors) { assert(pfn_vkCmdSetExclusiveScissorNV); pfn_vkCmdSetExclusiveScissorNV(commandBuffer, firstExclusiveScissor, exclusiveScissorCount, pExclusiveScissors); } int has_VK_NV_scissor_exclusive = 0; int load_VK_NV_scissor_exclusive(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkCmdSetExclusiveScissorNV = (PFN_vkCmdSetExclusiveScissorNV)getDeviceProcAddr(device, "vkCmdSetExclusiveScissorNV"); int success = 1; success = success && (pfn_vkCmdSetExclusiveScissorNV != 0); has_VK_NV_scissor_exclusive = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_buffer_device_address static PFN_vkGetBufferDeviceAddressEXT pfn_vkGetBufferDeviceAddressEXT = 0; VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressEXT( VkDevice device, const VkBufferDeviceAddressInfoEXT* pInfo) { assert(pfn_vkGetBufferDeviceAddressEXT); return pfn_vkGetBufferDeviceAddressEXT(device, pInfo); } int has_VK_EXT_buffer_device_address = 0; int load_VK_EXT_buffer_device_address(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetBufferDeviceAddressEXT = (PFN_vkGetBufferDeviceAddressEXT)getDeviceProcAddr(device, "vkGetBufferDeviceAddressEXT"); int success = 1; success = success && (pfn_vkGetBufferDeviceAddressEXT != 0); has_VK_EXT_buffer_device_address = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_cooperative_matrix static PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesNV( VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesNV* pProperties) { assert(pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV); return pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV(physicalDevice, pPropertyCount, pProperties); } int has_VK_NV_cooperative_matrix = 0; int load_VK_NV_cooperative_matrix(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = (PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)getDeviceProcAddr(device, "vkGetPhysicalDeviceCooperativeMatrixPropertiesNV"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV != 0); has_VK_NV_cooperative_matrix = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_coverage_reduction_mode static PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV( VkPhysicalDevice physicalDevice, uint32_t* pCombinationCount, VkFramebufferMixedSamplesCombinationNV* pCombinations) { assert(pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV); return pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV(physicalDevice, pCombinationCount, pCombinations); } int has_VK_NV_coverage_reduction_mode = 0; int load_VK_NV_coverage_reduction_mode(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = (PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)getDeviceProcAddr(device, "vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV"); int success = 1; success = success && (pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV != 0); has_VK_NV_coverage_reduction_mode = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_buffer_device_address static PFN_vkGetBufferDeviceAddressKHR pfn_vkGetBufferDeviceAddressKHR = 0; static PFN_vkGetBufferOpaqueCaptureAddressKHR pfn_vkGetBufferOpaqueCaptureAddressKHR = 0; static PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = 0; VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressKHR( VkDevice device, const VkBufferDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetBufferDeviceAddressKHR); return pfn_vkGetBufferDeviceAddressKHR(device, pInfo); } VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddressKHR( VkDevice device, const VkBufferDeviceAddressInfoKHR* pInfo) { assert(pfn_vkGetBufferOpaqueCaptureAddressKHR); return pfn_vkGetBufferOpaqueCaptureAddressKHR(device, pInfo); } VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddressKHR( VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfoKHR* pInfo) { assert(pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR); return pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR(device, pInfo); } int has_VK_KHR_buffer_device_address = 0; int load_VK_KHR_buffer_device_address(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetBufferDeviceAddressKHR = (PFN_vkGetBufferDeviceAddressKHR)getDeviceProcAddr(device, "vkGetBufferDeviceAddressKHR"); pfn_vkGetBufferOpaqueCaptureAddressKHR = (PFN_vkGetBufferOpaqueCaptureAddressKHR)getDeviceProcAddr(device, "vkGetBufferOpaqueCaptureAddressKHR"); pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = (PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)getDeviceProcAddr(device, "vkGetDeviceMemoryOpaqueCaptureAddressKHR"); int success = 1; success = success && (pfn_vkGetBufferDeviceAddressKHR != 0); success = success && (pfn_vkGetBufferOpaqueCaptureAddressKHR != 0); success = success && (pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR != 0); has_VK_KHR_buffer_device_address = success; return success; } #endif /* /////////////////////////////////// */ #if VK_EXT_host_query_reset static PFN_vkResetQueryPoolEXT pfn_vkResetQueryPoolEXT = 0; VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT( VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount) { assert(pfn_vkResetQueryPoolEXT); pfn_vkResetQueryPoolEXT(device, queryPool, firstQuery, queryCount); } int has_VK_EXT_host_query_reset = 0; int load_VK_EXT_host_query_reset(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkResetQueryPoolEXT = (PFN_vkResetQueryPoolEXT)getDeviceProcAddr(device, "vkResetQueryPoolEXT"); int success = 1; success = success && (pfn_vkResetQueryPoolEXT != 0); has_VK_EXT_host_query_reset = success; return success; } #endif /* /////////////////////////////////// */ #if VK_KHR_pipeline_executable_properties static PFN_vkGetPipelineExecutablePropertiesKHR pfn_vkGetPipelineExecutablePropertiesKHR = 0; static PFN_vkGetPipelineExecutableStatisticsKHR pfn_vkGetPipelineExecutableStatisticsKHR = 0; static PFN_vkGetPipelineExecutableInternalRepresentationsKHR pfn_vkGetPipelineExecutableInternalRepresentationsKHR = 0; VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutablePropertiesKHR( VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, uint32_t* pExecutableCount, VkPipelineExecutablePropertiesKHR* pProperties) { assert(pfn_vkGetPipelineExecutablePropertiesKHR); return pfn_vkGetPipelineExecutablePropertiesKHR(device, pPipelineInfo, pExecutableCount, pProperties); } VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableStatisticsKHR( VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pStatisticCount, VkPipelineExecutableStatisticKHR* pStatistics) { assert(pfn_vkGetPipelineExecutableStatisticsKHR); return pfn_vkGetPipelineExecutableStatisticsKHR(device, pExecutableInfo, pStatisticCount, pStatistics); } VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR( VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pInternalRepresentationCount, VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations) { assert(pfn_vkGetPipelineExecutableInternalRepresentationsKHR); return pfn_vkGetPipelineExecutableInternalRepresentationsKHR(device, pExecutableInfo, pInternalRepresentationCount, pInternalRepresentations); } int has_VK_KHR_pipeline_executable_properties = 0; int load_VK_KHR_pipeline_executable_properties(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetPipelineExecutablePropertiesKHR = (PFN_vkGetPipelineExecutablePropertiesKHR)getDeviceProcAddr(device, "vkGetPipelineExecutablePropertiesKHR"); pfn_vkGetPipelineExecutableStatisticsKHR = (PFN_vkGetPipelineExecutableStatisticsKHR)getDeviceProcAddr(device, "vkGetPipelineExecutableStatisticsKHR"); pfn_vkGetPipelineExecutableInternalRepresentationsKHR = (PFN_vkGetPipelineExecutableInternalRepresentationsKHR)getDeviceProcAddr(device, "vkGetPipelineExecutableInternalRepresentationsKHR"); int success = 1; success = success && (pfn_vkGetPipelineExecutablePropertiesKHR != 0); success = success && (pfn_vkGetPipelineExecutableStatisticsKHR != 0); success = success && (pfn_vkGetPipelineExecutableInternalRepresentationsKHR != 0); has_VK_KHR_pipeline_executable_properties = success; return success; } #endif /* /////////////////////////////////// */ #if VK_NV_device_generated_commands static PFN_vkGetGeneratedCommandsMemoryRequirementsNV pfn_vkGetGeneratedCommandsMemoryRequirementsNV = 0; static PFN_vkCmdPreprocessGeneratedCommandsNV pfn_vkCmdPreprocessGeneratedCommandsNV = 0; static PFN_vkCmdExecuteGeneratedCommandsNV pfn_vkCmdExecuteGeneratedCommandsNV = 0; static PFN_vkCmdBindPipelineShaderGroupNV pfn_vkCmdBindPipelineShaderGroupNV = 0; static PFN_vkCreateIndirectCommandsLayoutNV pfn_vkCreateIndirectCommandsLayoutNV = 0; static PFN_vkDestroyIndirectCommandsLayoutNV pfn_vkDestroyIndirectCommandsLayoutNV = 0; VKAPI_ATTR void VKAPI_CALL vkGetGeneratedCommandsMemoryRequirementsNV( VkDevice device, const VkGeneratedCommandsMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2* pMemoryRequirements) { assert(pfn_vkGetGeneratedCommandsMemoryRequirementsNV); pfn_vkGetGeneratedCommandsMemoryRequirementsNV(device, pInfo, pMemoryRequirements); } VKAPI_ATTR void VKAPI_CALL vkCmdPreprocessGeneratedCommandsNV( VkCommandBuffer commandBuffer, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo) { assert(pfn_vkCmdPreprocessGeneratedCommandsNV); pfn_vkCmdPreprocessGeneratedCommandsNV(commandBuffer, pGeneratedCommandsInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdExecuteGeneratedCommandsNV( VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo) { assert(pfn_vkCmdExecuteGeneratedCommandsNV); pfn_vkCmdExecuteGeneratedCommandsNV(commandBuffer, isPreprocessed, pGeneratedCommandsInfo); } VKAPI_ATTR void VKAPI_CALL vkCmdBindPipelineShaderGroupNV( VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, uint32_t groupIndex) { assert(pfn_vkCmdBindPipelineShaderGroupNV); pfn_vkCmdBindPipelineShaderGroupNV(commandBuffer, pipelineBindPoint, pipeline, groupIndex); } VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNV( VkDevice device, const VkIndirectCommandsLayoutCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNV* pIndirectCommandsLayout) { assert(pfn_vkCreateIndirectCommandsLayoutNV); return pfn_vkCreateIndirectCommandsLayoutNV(device, pCreateInfo, pAllocator, pIndirectCommandsLayout); } VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNV( VkDevice device, VkIndirectCommandsLayoutNV indirectCommandsLayout, const VkAllocationCallbacks* pAllocator) { assert(pfn_vkDestroyIndirectCommandsLayoutNV); pfn_vkDestroyIndirectCommandsLayoutNV(device, indirectCommandsLayout, pAllocator); } int has_VK_NV_device_generated_commands = 0; int load_VK_NV_device_generated_commands(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { pfn_vkGetGeneratedCommandsMemoryRequirementsNV = (PFN_vkGetGeneratedCommandsMemoryRequirementsNV)getDeviceProcAddr(device, "vkGetGeneratedCommandsMemoryRequirementsNV"); pfn_vkCmdPreprocessGeneratedCommandsNV = (PFN_vkCmdPreprocessGeneratedCommandsNV)getDeviceProcAddr(device, "vkCmdPreprocessGeneratedCommandsNV"); pfn_vkCmdExecuteGeneratedCommandsNV = (PFN_vkCmdExecuteGeneratedCommandsNV)getDeviceProcAddr(device, "vkCmdExecuteGeneratedCommandsNV"); pfn_vkCmdBindPipelineShaderGroupNV = (PFN_vkCmdBindPipelineShaderGroupNV)getDeviceProcAddr(device, "vkCmdBindPipelineShaderGroupNV"); pfn_vkCreateIndirectCommandsLayoutNV = (PFN_vkCreateIndirectCommandsLayoutNV)getDeviceProcAddr(device, "vkCreateIndirectCommandsLayoutNV"); pfn_vkDestroyIndirectCommandsLayoutNV = (PFN_vkDestroyIndirectCommandsLayoutNV)getDeviceProcAddr(device, "vkDestroyIndirectCommandsLayoutNV"); int success = 1; success = success && (pfn_vkGetGeneratedCommandsMemoryRequirementsNV != 0); success = success && (pfn_vkCmdPreprocessGeneratedCommandsNV != 0); success = success && (pfn_vkCmdExecuteGeneratedCommandsNV != 0); success = success && (pfn_vkCmdBindPipelineShaderGroupNV != 0); success = success && (pfn_vkCreateIndirectCommandsLayoutNV != 0); success = success && (pfn_vkDestroyIndirectCommandsLayoutNV != 0); has_VK_NV_device_generated_commands = success; return success; } #endif /* super load/reset */ void load_VK_EXTENSION_SUBSET(VkInstance instance, PFN_vkGetInstanceProcAddr getInstanceProcAddr, VkDevice device, PFN_vkGetDeviceProcAddr getDeviceProcAddr) { #if VK_EXT_debug_marker load_VK_EXT_debug_marker(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_memory_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_memory_fd load_VK_KHR_external_memory_fd(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_semaphore_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_semaphore_fd load_VK_KHR_external_semaphore_fd(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_push_descriptor load_VK_KHR_push_descriptor(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_create_renderpass2 load_VK_KHR_create_renderpass2(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) load_VK_KHR_external_fence_win32(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_debug_utils load_VK_EXT_debug_utils(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_sample_locations load_VK_EXT_sample_locations(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_acceleration_structure load_VK_KHR_acceleration_structure(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_ray_tracing_pipeline load_VK_KHR_ray_tracing_pipeline(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_shading_rate_image load_VK_NV_shading_rate_image(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_ray_tracing load_VK_NV_ray_tracing(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_draw_indirect_count load_VK_KHR_draw_indirect_count(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_calibrated_timestamps load_VK_EXT_calibrated_timestamps(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_mesh_shader load_VK_NV_mesh_shader(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_scissor_exclusive load_VK_NV_scissor_exclusive(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_buffer_device_address load_VK_EXT_buffer_device_address(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_cooperative_matrix load_VK_NV_cooperative_matrix(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_coverage_reduction_mode load_VK_NV_coverage_reduction_mode(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_buffer_device_address load_VK_KHR_buffer_device_address(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_EXT_host_query_reset load_VK_EXT_host_query_reset(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_KHR_pipeline_executable_properties load_VK_KHR_pipeline_executable_properties(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif #if VK_NV_device_generated_commands load_VK_NV_device_generated_commands(instance, getInstanceProcAddr, device, getDeviceProcAddr); #endif } void reset_VK_EXTENSION_SUBSET() { #if VK_EXT_debug_marker has_VK_EXT_debug_marker = 0; PFN_vkDebugMarkerSetObjectTagEXT pfn_vkDebugMarkerSetObjectTagEXT = 0; PFN_vkDebugMarkerSetObjectNameEXT pfn_vkDebugMarkerSetObjectNameEXT = 0; PFN_vkCmdDebugMarkerBeginEXT pfn_vkCmdDebugMarkerBeginEXT = 0; PFN_vkCmdDebugMarkerEndEXT pfn_vkCmdDebugMarkerEndEXT = 0; PFN_vkCmdDebugMarkerInsertEXT pfn_vkCmdDebugMarkerInsertEXT = 0; #endif #if VK_KHR_external_memory_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_memory_win32 = 0; PFN_vkGetMemoryWin32HandleKHR pfn_vkGetMemoryWin32HandleKHR = 0; PFN_vkGetMemoryWin32HandlePropertiesKHR pfn_vkGetMemoryWin32HandlePropertiesKHR = 0; #endif #if VK_KHR_external_memory_fd has_VK_KHR_external_memory_fd = 0; PFN_vkGetMemoryFdKHR pfn_vkGetMemoryFdKHR = 0; PFN_vkGetMemoryFdPropertiesKHR pfn_vkGetMemoryFdPropertiesKHR = 0; #endif #if VK_KHR_external_semaphore_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_semaphore_win32 = 0; PFN_vkImportSemaphoreWin32HandleKHR pfn_vkImportSemaphoreWin32HandleKHR = 0; PFN_vkGetSemaphoreWin32HandleKHR pfn_vkGetSemaphoreWin32HandleKHR = 0; #endif #if VK_KHR_external_semaphore_fd has_VK_KHR_external_semaphore_fd = 0; PFN_vkImportSemaphoreFdKHR pfn_vkImportSemaphoreFdKHR = 0; PFN_vkGetSemaphoreFdKHR pfn_vkGetSemaphoreFdKHR = 0; #endif #if VK_KHR_push_descriptor has_VK_KHR_push_descriptor = 0; PFN_vkCmdPushDescriptorSetKHR pfn_vkCmdPushDescriptorSetKHR = 0; PFN_vkCmdPushDescriptorSetWithTemplateKHR pfn_vkCmdPushDescriptorSetWithTemplateKHR = 0; #endif #if VK_KHR_create_renderpass2 has_VK_KHR_create_renderpass2 = 0; PFN_vkCreateRenderPass2KHR pfn_vkCreateRenderPass2KHR = 0; PFN_vkCmdBeginRenderPass2KHR pfn_vkCmdBeginRenderPass2KHR = 0; PFN_vkCmdNextSubpass2KHR pfn_vkCmdNextSubpass2KHR = 0; PFN_vkCmdEndRenderPass2KHR pfn_vkCmdEndRenderPass2KHR = 0; #endif #if VK_KHR_external_fence_win32 && defined(VK_USE_PLATFORM_WIN32_KHR) has_VK_KHR_external_fence_win32 = 0; PFN_vkImportFenceWin32HandleKHR pfn_vkImportFenceWin32HandleKHR = 0; PFN_vkGetFenceWin32HandleKHR pfn_vkGetFenceWin32HandleKHR = 0; #endif #if VK_EXT_debug_utils has_VK_EXT_debug_utils = 0; PFN_vkSetDebugUtilsObjectNameEXT pfn_vkSetDebugUtilsObjectNameEXT = 0; PFN_vkSetDebugUtilsObjectTagEXT pfn_vkSetDebugUtilsObjectTagEXT = 0; PFN_vkQueueBeginDebugUtilsLabelEXT pfn_vkQueueBeginDebugUtilsLabelEXT = 0; PFN_vkQueueEndDebugUtilsLabelEXT pfn_vkQueueEndDebugUtilsLabelEXT = 0; PFN_vkQueueInsertDebugUtilsLabelEXT pfn_vkQueueInsertDebugUtilsLabelEXT = 0; PFN_vkCmdBeginDebugUtilsLabelEXT pfn_vkCmdBeginDebugUtilsLabelEXT = 0; PFN_vkCmdEndDebugUtilsLabelEXT pfn_vkCmdEndDebugUtilsLabelEXT = 0; PFN_vkCmdInsertDebugUtilsLabelEXT pfn_vkCmdInsertDebugUtilsLabelEXT = 0; PFN_vkCreateDebugUtilsMessengerEXT pfn_vkCreateDebugUtilsMessengerEXT = 0; PFN_vkDestroyDebugUtilsMessengerEXT pfn_vkDestroyDebugUtilsMessengerEXT = 0; PFN_vkSubmitDebugUtilsMessageEXT pfn_vkSubmitDebugUtilsMessageEXT = 0; #endif #if VK_EXT_sample_locations has_VK_EXT_sample_locations = 0; PFN_vkCmdSetSampleLocationsEXT pfn_vkCmdSetSampleLocationsEXT = 0; PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT pfn_vkGetPhysicalDeviceMultisamplePropertiesEXT = 0; #endif #if VK_KHR_acceleration_structure has_VK_KHR_acceleration_structure = 0; PFN_vkCreateAccelerationStructureKHR pfn_vkCreateAccelerationStructureKHR = 0; PFN_vkDestroyAccelerationStructureKHR pfn_vkDestroyAccelerationStructureKHR = 0; PFN_vkCmdBuildAccelerationStructuresKHR pfn_vkCmdBuildAccelerationStructuresKHR = 0; PFN_vkCmdBuildAccelerationStructuresIndirectKHR pfn_vkCmdBuildAccelerationStructuresIndirectKHR = 0; PFN_vkBuildAccelerationStructuresKHR pfn_vkBuildAccelerationStructuresKHR = 0; PFN_vkCopyAccelerationStructureKHR pfn_vkCopyAccelerationStructureKHR = 0; PFN_vkCopyAccelerationStructureToMemoryKHR pfn_vkCopyAccelerationStructureToMemoryKHR = 0; PFN_vkCopyMemoryToAccelerationStructureKHR pfn_vkCopyMemoryToAccelerationStructureKHR = 0; PFN_vkWriteAccelerationStructuresPropertiesKHR pfn_vkWriteAccelerationStructuresPropertiesKHR = 0; PFN_vkCmdCopyAccelerationStructureKHR pfn_vkCmdCopyAccelerationStructureKHR = 0; PFN_vkCmdCopyAccelerationStructureToMemoryKHR pfn_vkCmdCopyAccelerationStructureToMemoryKHR = 0; PFN_vkCmdCopyMemoryToAccelerationStructureKHR pfn_vkCmdCopyMemoryToAccelerationStructureKHR = 0; PFN_vkGetAccelerationStructureDeviceAddressKHR pfn_vkGetAccelerationStructureDeviceAddressKHR = 0; PFN_vkCmdWriteAccelerationStructuresPropertiesKHR pfn_vkCmdWriteAccelerationStructuresPropertiesKHR = 0; PFN_vkGetDeviceAccelerationStructureCompatibilityKHR pfn_vkGetDeviceAccelerationStructureCompatibilityKHR = 0; PFN_vkGetAccelerationStructureBuildSizesKHR pfn_vkGetAccelerationStructureBuildSizesKHR = 0; #endif #if VK_KHR_ray_tracing_pipeline has_VK_KHR_ray_tracing_pipeline = 0; PFN_vkCmdTraceRaysKHR pfn_vkCmdTraceRaysKHR = 0; PFN_vkCreateRayTracingPipelinesKHR pfn_vkCreateRayTracingPipelinesKHR = 0; PFN_vkGetRayTracingShaderGroupHandlesKHR pfn_vkGetRayTracingShaderGroupHandlesKHR = 0; PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR pfn_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR = 0; PFN_vkCmdTraceRaysIndirectKHR pfn_vkCmdTraceRaysIndirectKHR = 0; PFN_vkGetRayTracingShaderGroupStackSizeKHR pfn_vkGetRayTracingShaderGroupStackSizeKHR = 0; PFN_vkCmdSetRayTracingPipelineStackSizeKHR pfn_vkCmdSetRayTracingPipelineStackSizeKHR = 0; #endif #if VK_NV_shading_rate_image has_VK_NV_shading_rate_image = 0; PFN_vkCmdBindShadingRateImageNV pfn_vkCmdBindShadingRateImageNV = 0; PFN_vkCmdSetViewportShadingRatePaletteNV pfn_vkCmdSetViewportShadingRatePaletteNV = 0; PFN_vkCmdSetCoarseSampleOrderNV pfn_vkCmdSetCoarseSampleOrderNV = 0; #endif #if VK_NV_ray_tracing has_VK_NV_ray_tracing = 0; PFN_vkCreateAccelerationStructureNV pfn_vkCreateAccelerationStructureNV = 0; PFN_vkDestroyAccelerationStructureNV pfn_vkDestroyAccelerationStructureNV = 0; PFN_vkGetAccelerationStructureMemoryRequirementsNV pfn_vkGetAccelerationStructureMemoryRequirementsNV = 0; PFN_vkBindAccelerationStructureMemoryNV pfn_vkBindAccelerationStructureMemoryNV = 0; PFN_vkCmdBuildAccelerationStructureNV pfn_vkCmdBuildAccelerationStructureNV = 0; PFN_vkCmdCopyAccelerationStructureNV pfn_vkCmdCopyAccelerationStructureNV = 0; PFN_vkCmdTraceRaysNV pfn_vkCmdTraceRaysNV = 0; PFN_vkCreateRayTracingPipelinesNV pfn_vkCreateRayTracingPipelinesNV = 0; PFN_vkGetRayTracingShaderGroupHandlesNV pfn_vkGetRayTracingShaderGroupHandlesNV = 0; PFN_vkGetAccelerationStructureHandleNV pfn_vkGetAccelerationStructureHandleNV = 0; PFN_vkCmdWriteAccelerationStructuresPropertiesNV pfn_vkCmdWriteAccelerationStructuresPropertiesNV = 0; PFN_vkCompileDeferredNV pfn_vkCompileDeferredNV = 0; #endif #if VK_KHR_draw_indirect_count has_VK_KHR_draw_indirect_count = 0; PFN_vkCmdDrawIndirectCountKHR pfn_vkCmdDrawIndirectCountKHR = 0; PFN_vkCmdDrawIndexedIndirectCountKHR pfn_vkCmdDrawIndexedIndirectCountKHR = 0; #endif #if VK_EXT_calibrated_timestamps has_VK_EXT_calibrated_timestamps = 0; PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT pfn_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT = 0; PFN_vkGetCalibratedTimestampsEXT pfn_vkGetCalibratedTimestampsEXT = 0; #endif #if VK_NV_mesh_shader has_VK_NV_mesh_shader = 0; PFN_vkCmdDrawMeshTasksNV pfn_vkCmdDrawMeshTasksNV = 0; PFN_vkCmdDrawMeshTasksIndirectNV pfn_vkCmdDrawMeshTasksIndirectNV = 0; PFN_vkCmdDrawMeshTasksIndirectCountNV pfn_vkCmdDrawMeshTasksIndirectCountNV = 0; #endif #if VK_NV_scissor_exclusive has_VK_NV_scissor_exclusive = 0; PFN_vkCmdSetExclusiveScissorNV pfn_vkCmdSetExclusiveScissorNV = 0; #endif #if VK_EXT_buffer_device_address has_VK_EXT_buffer_device_address = 0; PFN_vkGetBufferDeviceAddressEXT pfn_vkGetBufferDeviceAddressEXT = 0; #endif #if VK_NV_cooperative_matrix has_VK_NV_cooperative_matrix = 0; PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV pfn_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV = 0; #endif #if VK_NV_coverage_reduction_mode has_VK_NV_coverage_reduction_mode = 0; PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV pfn_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV = 0; #endif #if VK_KHR_buffer_device_address has_VK_KHR_buffer_device_address = 0; PFN_vkGetBufferDeviceAddressKHR pfn_vkGetBufferDeviceAddressKHR = 0; PFN_vkGetBufferOpaqueCaptureAddressKHR pfn_vkGetBufferOpaqueCaptureAddressKHR = 0; PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR pfn_vkGetDeviceMemoryOpaqueCaptureAddressKHR = 0; #endif #if VK_EXT_host_query_reset has_VK_EXT_host_query_reset = 0; PFN_vkResetQueryPoolEXT pfn_vkResetQueryPoolEXT = 0; #endif #if VK_KHR_pipeline_executable_properties has_VK_KHR_pipeline_executable_properties = 0; PFN_vkGetPipelineExecutablePropertiesKHR pfn_vkGetPipelineExecutablePropertiesKHR = 0; PFN_vkGetPipelineExecutableStatisticsKHR pfn_vkGetPipelineExecutableStatisticsKHR = 0; PFN_vkGetPipelineExecutableInternalRepresentationsKHR pfn_vkGetPipelineExecutableInternalRepresentationsKHR = 0; #endif #if VK_NV_device_generated_commands has_VK_NV_device_generated_commands = 0; PFN_vkGetGeneratedCommandsMemoryRequirementsNV pfn_vkGetGeneratedCommandsMemoryRequirementsNV = 0; PFN_vkCmdPreprocessGeneratedCommandsNV pfn_vkCmdPreprocessGeneratedCommandsNV = 0; PFN_vkCmdExecuteGeneratedCommandsNV pfn_vkCmdExecuteGeneratedCommandsNV = 0; PFN_vkCmdBindPipelineShaderGroupNV pfn_vkCmdBindPipelineShaderGroupNV = 0; PFN_vkCreateIndirectCommandsLayoutNV pfn_vkCreateIndirectCommandsLayoutNV = 0; PFN_vkDestroyIndirectCommandsLayoutNV pfn_vkDestroyIndirectCommandsLayoutNV = 0; #endif } #if defined(ERM_OSX) # pragma clang diagnostic pop #endif
47.634384
367
0.862479
JALB91
5e85639fac693539d79a0ea70f2d78fb56224e58
3,489
cpp
C++
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
qipmsg/trunk/src/dir_dialog.cpp
cuibo10/feige_src
1bfd47eaa046d401f83dfae5715b5487283ba343
[ "MIT" ]
null
null
null
// This file is part of QIpMsg. // // QIpMsg is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // QIpMsg is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with QIpMsg. If not, see <http://www.gnu.org/licenses/>. // #include "dir_dialog.h" #include "global.h" #include "preferences.h" #include "send_file_model.h" #include <QtGui> #include <QtCore> DirDialog::DirDialog(SendFileModel *sendFileModel, QWidget *parent) : QDialog(parent), m_sendFileModel(sendFileModel) { // Delete when close setAttribute(Qt::WA_DeleteOnClose, true); QStringList nameFilter; model = new QDirModel(nameFilter, QDir::Dirs | QDir::Readable | QDir::NoDotAndDotDot, QDir::Name); tree = new QTreeView; tree->setModel(model); tree->hideColumn(1); // Hide size column tree->hideColumn(2); // Hide type column tree->hideColumn(3); // Hide time column tree->header()->hide(); // Hide header selectionModel = new QItemSelectionModel(model); tree->setSelectionModel(selectionModel); // Expanded to the last send directory expandTree(); // Scroll to last dir path tree->verticalScrollBar() ->setValue(model->index(Global::preferences->lastSendDirPath).row()); // Set the default selected directory selectionModel->select(model->index(Global::preferences->lastSendDirPath), QItemSelectionModel::Select | QItemSelectionModel::Rows); QLabel *label = new QLabel(tr("Select folder to send")); createButtonLayout(); createConnections(); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget(label); mainLayout->addSpacing(10); mainLayout->addWidget(tree); mainLayout->addSpacing(10); mainLayout->addLayout(buttonsLayout); setLayout(mainLayout); setWindowTitle(tr("Browser Folders")); adjustSize(); } QSize DirDialog::sizeHint() const { return QSize(400, 480); } void DirDialog::selectDir() { QModelIndexList modelIndexList = selectionModel->selectedRows(0); foreach (QModelIndex ix, modelIndexList) { QFileInfo fi = model->fileInfo(ix); QString filePath = fi.absoluteFilePath(); m_sendFileModel->addFile(filePath); Global::preferences->lastSendDirPath = fi.absoluteFilePath(); } emit dirSelected(); close(); } void DirDialog::createConnections() { connect(okButton, SIGNAL(clicked()), this, SLOT(selectDir())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); } void DirDialog::createButtonLayout() { okButton = new QPushButton(tr("Ok")); cancelButton = new QPushButton(tr("Cancel")); buttonsLayout = new QHBoxLayout; buttonsLayout->addStretch(); buttonsLayout->addWidget(okButton); buttonsLayout->addSpacing(20); buttonsLayout->addWidget(cancelButton); } void DirDialog::expandTree() { QDir dir(Global::preferences->lastSendDirPath); while (dir.cdUp()) { tree->expand(model->index(dir.absolutePath())); } }
28.137097
78
0.685583
cuibo10
5e8675ab6269e5b629c34db078715762012c3017
2,239
cpp
C++
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
Regex_match.cpp
Foxitute/RegexOnC-
2c6124a2221352ac2e8aa85d025541f10f52f2f2
[ "MIT" ]
null
null
null
#include <iostream> #include <string> #include <regex> void regex_match(std::string str) { // regex_match // ([a-z ]){0, 99999} \\w - for letters, \\s - space std::cmatch result; std::regex regular("([\\w-]+)" "(@)" "([\\w-]+)" "(\.)" "(\\w{2,5})"); // 2-5 symbols // Convert to c-string if (std::regex_match(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_search1(std::string str) { //regex_search std::cmatch result; std::regex regular( "([\\w-]+:\\s)" // word, ':'sign with space "([\\w-]+)" // can be letter, number and '-'sign "(@)" // '@'sign "([\\w-]+)" // can be letter, number and '-'sign "\." // '.'sign "(\\w{2,5})");// can be letter (2-5 length) if (std::regex_search(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_search2(std::string str) { std::cmatch result; std::regex regular( "(: )" "([.]*[^\.]+)" // any quantity of any symbols| before '.'sing "(\.)"); if (std::regex_search(str.c_str(), result, regular)) { for (int i = 0; i < result.size(); i++) { std::cout << result[i] << std::endl; } } } void regex_replace(std::string str) { std::regex regular("(: )" "([.]*[^\.]+)" "(\.)"); std::string result = regex_replace(str.c_str(), regular, " ---lulz--- "); std::cout << result << std::endl; } int main() { std::cout << "REGEX_MATCH" << std::endl; std::string email = "[email protected]"; regex_match(email); std::cout << "\nREGEX_SEARCH\nFirst Example" << std::endl; std::string strWithEmail = "MyEmail: [email protected] LOL11!!!"; regex_search1(strWithEmail); std::cout << "\nREGEX_SEARCH\nSecond Example" << std::endl; std::string str2WithEmail = "MyEmail: [email protected] LOL11!!!"; regex_search2(str2WithEmail); std::cout << "\nREGEX_REPLACE" << std::endl; std::string str3WithEmail = "MyEmail: [email protected] LOL11!!!"; regex_replace(str3WithEmail); }
23.568421
75
0.528808
Foxitute
5e897dbaaf5357c6b8f92d02714b43f492512ad3
1,965
cpp
C++
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
BehaviroalPatterns/state/cardrivethrough.cpp
enuguru/design_patterns
7b5a70d65811c39d15cbfa8b7a0603a16a851265
[ "MIT" ]
null
null
null
#include <iostream> #include <ctime> #include <cstdlib> using namespace std; class FSM { class State* current; public: FSM(); void setCurrent( State* s ) { current = s; } void suckUpMoney( int ); void carDrivesThrough(); }; class State { int total; protected: int getTotal() { return total; } public: State() { total = 0; } virtual void suckUpMoney( int in, FSM* fsm ) { total += in; cout << "total is " << total << '\n'; } virtual void carDrivesThrough( FSM* fsm ) = 0; }; class GreenLight : public State { public: GreenLight() { cout << "GREEN light\n"; } void suckUpMoney( int in, FSM* fsm ) { cout << " You're an idiot, "; State::suckUpMoney( in, fsm ); } void carDrivesThrough( FSM* fsm ); }; class RedLight : public State { public: RedLight() { cout << "RED light\n"; } void suckUpMoney( int in, FSM* fsm ) { cout << " "; State::suckUpMoney( in, fsm ); if (getTotal() >= 50) { fsm->setCurrent( new GreenLight ); delete this; } } void carDrivesThrough( FSM* fsm ) { cout << "Sirens!! Heat-seeking missile!! Confiscate net worth!!\n"; fsm->setCurrent( new RedLight ); delete this; } }; FSM::FSM() { current = new RedLight(); } void FSM::suckUpMoney( int in ) { current->suckUpMoney( in, this ); } void FSM::carDrivesThrough() { current->carDrivesThrough( this ); } void GreenLight::carDrivesThrough( FSM* fsm ) { cout << "Good-bye sucker!!\n"; fsm->setCurrent( new RedLight ); delete this; } int getCoin() { static int choices[3] = { 5, 10, 25 }; return choices[rand() % 3]; } int main( void ) { srand( time(0) ); FSM fsm; int ans; while (true) { cout << " Shell out (1), Drive thru (2), Exit (0): "; cin >> ans; if (ans == 1) fsm.suckUpMoney( getCoin() ); else if (ans == 2) fsm.carDrivesThrough(); else break; } return 0; }
22.329545
75
0.572519
enuguru
5e8f1f723a9de1c53eade71fb46968a8a6219c8c
1,502
cpp
C++
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
1
2020-09-18T22:33:37.000Z
2020-09-18T22:33:37.000Z
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
null
null
null
source/rcnn/modeling/rpn/utils.cpp
conanhung/maskrcnn_benchmark.cpp
eab9787d3140e003662a31a8e01f7ae39469e9a0
[ "MIT" ]
null
null
null
#include "rpn/utils.h" #include <cassert> #include <iostream> #include <cat.h> namespace rcnn{ namespace modeling{ torch::Tensor PermuteAndFlatten(torch::Tensor& layer, int64_t N, int64_t A, int64_t C, int64_t H, int64_t W){ layer = layer.view({N, -1, C, H, W}); layer = layer.permute({0, 3, 4, 1, 2}); layer = layer.reshape({N, -1, C}); return layer; } std::pair<torch::Tensor, torch::Tensor> ConcatBoxPredictionLayers(std::vector<torch::Tensor>& box_cls, std::vector<torch::Tensor>& box_regression){ std::vector<torch::Tensor> box_cls_flattened; box_cls_flattened.reserve(box_cls.size()); std::vector<torch::Tensor> box_regression_flattened; box_regression_flattened.reserve(box_cls.size()); int64_t C; assert(box_cls.size() == box_regression.size()); for(int i = 0; i < box_cls.size(); ++i){ int64_t N = box_cls[i].size(0), AxC = box_cls[i].size(1), H = box_cls[i].size(2), W = box_cls[i].size(3); int64_t Ax4 = box_regression[i].size(1); int64_t A = static_cast<int64_t> (Ax4 / 4); C = static_cast<int64_t> (AxC / A); //box_cls_per_level box_cls_flattened.push_back( std::move(PermuteAndFlatten(box_cls[i], N, A, C, H, W)) ); box_regression_flattened.push_back( std::move(PermuteAndFlatten(box_regression[i], N, A, 4, H, W)) ); } return std::make_pair(rcnn::layers::cat(box_cls_flattened, /*dim=*/1).reshape({-1, C}), rcnn::layers::cat(box_regression_flattened, /*dim=*/1).reshape({-1, 4})); } } }
31.957447
147
0.66245
conanhung
5e907214b76edb4ed4c8a811738b4be0da904e38
8,996
cpp
C++
3rdparty/kdl_parser/src/kdl_parser.cpp
rocos-sia/rocos-app
83aa8aa31dd303d77693cfc5ad48055d051fa4bc
[ "MIT" ]
3
2021-12-06T15:30:58.000Z
2022-03-29T13:21:40.000Z
3rdparty/kdl_parser/src/kdl_parser.cpp
thinkexist1989/rocos-app
7d6ab256c8212504b0a8bbe1ec1dea0c41ea3ff2
[ "MIT" ]
null
null
null
3rdparty/kdl_parser/src/kdl_parser.cpp
thinkexist1989/rocos-app
7d6ab256c8212504b0a8bbe1ec1dea0c41ea3ff2
[ "MIT" ]
null
null
null
/********************************************************************* * Software License Agreement (BSD License) * * Copyright (c) 2008, Willow Garage, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of the Willow Garage nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. *********************************************************************/ /* Author: Wim Meeussen */ #include "kdl_parser/kdl_parser.hpp" #include <string> #include <vector> #include <urdf_model/model.h> #include <urdf_parser/urdf_parser.h> #include <kdl/frames_io.hpp> #ifdef HAS_ROS #include <ros/console.h> #else // forward ROS warnings and errors to stderr #define ROS_DEBUG(...) fprintf(stdout, __VA_ARGS__); #define ROS_ERROR(...) fprintf(stderr, __VA_ARGS__); #define ROS_WARN(...) fprintf(stderr, __VA_ARGS__); #endif #ifdef HAS_URDF #include <urdf/model.h> #include <urdf/urdfdom_compatibility.h> #endif namespace kdl_parser { // construct vector KDL::Vector toKdl(urdf::Vector3 v) { return KDL::Vector(v.x, v.y, v.z); } // construct rotation KDL::Rotation toKdl(urdf::Rotation r) { return KDL::Rotation::Quaternion(r.x, r.y, r.z, r.w); } // construct pose KDL::Frame toKdl(urdf::Pose p) { return KDL::Frame(toKdl(p.rotation), toKdl(p.position)); } // construct joint KDL::Joint toKdl(urdf::JointSharedPtr jnt) { KDL::Frame F_parent_jnt = toKdl(jnt->parent_to_joint_origin_transform); switch (jnt->type) { case urdf::Joint::FIXED: { return KDL::Joint(jnt->name, KDL::Joint::None); } case urdf::Joint::REVOLUTE: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::RotAxis); } case urdf::Joint::CONTINUOUS: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::RotAxis); } case urdf::Joint::PRISMATIC: { KDL::Vector axis = toKdl(jnt->axis); return KDL::Joint(jnt->name, F_parent_jnt.p, F_parent_jnt.M * axis, KDL::Joint::TransAxis); } default: { ROS_WARN("Converting unknown joint type of joint '%s' into a fixed joint", jnt->name.c_str()); return KDL::Joint(jnt->name, KDL::Joint::None); } } return KDL::Joint(); } // construct inertia KDL::RigidBodyInertia toKdl(urdf::InertialSharedPtr i) { KDL::Frame origin = toKdl(i->origin); // the mass is frame independent double kdl_mass = i->mass; // kdl and urdf both specify the com position in the reference frame of the link KDL::Vector kdl_com = origin.p; // kdl specifies the inertia matrix in the reference frame of the link, // while the urdf specifies the inertia matrix in the inertia reference frame KDL::RotationalInertia urdf_inertia = KDL::RotationalInertia(i->ixx, i->iyy, i->izz, i->ixy, i->ixz, i->iyz); // Rotation operators are not defined for rotational inertia, // so we use the RigidBodyInertia operators (with com = 0) as a workaround KDL::RigidBodyInertia kdl_inertia_wrt_com_workaround = origin.M * KDL::RigidBodyInertia(0, KDL::Vector::Zero(), urdf_inertia); // Note that the RigidBodyInertia constructor takes the 3d inertia wrt the com // while the getRotationalInertia method returns the 3d inertia wrt the frame origin // (but having com = Vector::Zero() in kdl_inertia_wrt_com_workaround they match) KDL::RotationalInertia kdl_inertia_wrt_com = kdl_inertia_wrt_com_workaround.getRotationalInertia(); return KDL::RigidBodyInertia(kdl_mass, kdl_com, kdl_inertia_wrt_com); } // recursive function to walk through tree bool addChildrenToTree(urdf::LinkConstSharedPtr root, KDL::Tree &tree) { std::vector<urdf::LinkSharedPtr> children = root->child_links; printf("Link %s had %zu children\n", root->name.c_str(), children.size()); // constructs the optional inertia KDL::RigidBodyInertia inert(0); if (root->inertial) { inert = toKdl(root->inertial); } // constructs the kdl joint KDL::Joint jnt = toKdl(root->parent_joint); // construct the kdl segment KDL::Segment sgm(root->name, jnt, toKdl(root->parent_joint->parent_to_joint_origin_transform), inert); // add segment to tree tree.addSegment(sgm, root->parent_joint->parent_link_name); // recurslively add all children for (size_t i = 0; i < children.size(); i++) { if (!addChildrenToTree(children[i], tree)) { return false; } } return true; } bool treeFromFile(const std::string &file, KDL::Tree &tree) { const urdf::ModelInterfaceSharedPtr robot_model = urdf::parseURDFFile(file); return kdl_parser::treeFromUrdfModel(*robot_model, tree); } bool treeFromParam(const std::string &param, KDL::Tree &tree) { #if defined(HAS_ROS) && defined(HAS_URDF) urdf::Model robot_model; if (!robot_model.initParam(param)) { ROS_ERROR("Could not generate robot model"); return false; } return treeFromUrdfModel(robot_model, tree); #else return false; #endif } bool treeFromString(const std::string &xml, KDL::Tree &tree) { const urdf::ModelInterfaceSharedPtr robot_model = urdf::parseURDF(xml); if (!robot_model) { ROS_ERROR("Could not generate robot model"); return false; } return kdl_parser::treeFromUrdfModel(*robot_model, tree); } bool treeFromXml(const tinyxml2::XMLDocument *xml_doc, KDL::Tree &tree) { if (!xml_doc) { ROS_ERROR("Could not parse the xml document"); return false; } tinyxml2::XMLPrinter printer; xml_doc->Print(&printer); return treeFromString(printer.CStr(), tree); } bool treeFromXml(TiXmlDocument *xml_doc, KDL::Tree &tree) { if (!xml_doc) { ROS_ERROR("Could not parse the xml document"); return false; } std::stringstream ss; ss << *xml_doc; return treeFromString(ss.str(), tree); } bool treeFromUrdfModel(const urdf::ModelInterface &robot_model, KDL::Tree &tree) { if (!robot_model.getRoot()) { return false; } tree = KDL::Tree(robot_model.getRoot()->name); // warn if root link has inertia. KDL does not support this if (robot_model.getRoot()->inertial) { ROS_WARN("The root link %s has an inertia specified in the URDF, but KDL does not " "support a root link with an inertia. As a workaround, you can add an extra " "dummy link to your URDF.", robot_model.getRoot()->name.c_str()); } // add all children for (size_t i = 0; i < robot_model.getRoot()->child_links.size(); i++) { if (!addChildrenToTree(robot_model.getRoot()->child_links[i], tree)) { return false; } } return true; } } // namespace kdl_parser
33.318519
110
0.618608
rocos-sia
5e94f2286108eb672682e36f876c6d7120ac124f
4,569
cp
C++
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
12
2015-04-21T16:10:43.000Z
2021-11-05T13:41:46.000Z
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
2
2015-11-02T13:32:11.000Z
2019-07-10T21:11:21.000Z
Linux/Sources/Support/JXMultiImageCheckbox.cp
mulberry-mail/mulberry4-client
cdaae15c51dd759110b4fbdb2063d0e3d5202103
[ "ECL-2.0", "Apache-2.0" ]
6
2015-01-12T08:49:12.000Z
2021-03-27T09:11:10.000Z
/* Copyright (c) 2007 Cyrus Daboo. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "JXMultiImageCheckbox.h" #include "CDrawUtils.h" #include "CIconLoader.h" #include <JXWindowPainter.h> #include <JXImage.h> #include <JXColormap.h> #include <jAssert.h> #include <jXPainterUtil.h> /****************************************************************************** Constructor ******************************************************************************/ JXMultiImageCheckbox::JXMultiImageCheckbox ( JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h ) : JXCheckbox(enclosure, hSizing, vSizing, x,y, w,h), itsOffImageID(0), itsOffPushedImageID(0), itsOnImageID(0), itsOnPushedImageID(0) { // Our 3D buttons have 3-pixel border SetBorderWidth(3); } /****************************************************************************** Destructor ******************************************************************************/ JXMultiImageCheckbox::~JXMultiImageCheckbox() { } /****************************************************************************** SetImage ******************************************************************************/ void JXMultiImageCheckbox::SetImage(ResIDT offImageID) { itsOffImageID = offImageID; itsOffPushedImageID = offImageID; itsOnImageID = offImageID; itsOnPushedImageID = offImageID; Refresh(); } /****************************************************************************** SetImages ******************************************************************************/ void JXMultiImageCheckbox::SetImages(ResIDT offImageID, ResIDT offpushedImageID, ResIDT onImageID, ResIDT onpushedImageID) { itsOffImageID = offImageID; itsOnImageID = onImageID ? onImageID : offImageID; itsOffPushedImageID = offpushedImageID ? offpushedImageID : onImageID; itsOnPushedImageID = onpushedImageID ? onpushedImageID : offImageID; Refresh(); } /****************************************************************************** Draw (virtual protected) ******************************************************************************/ void JXMultiImageCheckbox::Draw ( JXWindowPainter& p, const JRect& rect ) { unsigned long bkgnd = 0x00FFFFFF; JColorIndex bkgnd_index = GetColormap()->Get3DShadeColor(); if (IsActive() && DrawChecked()) bkgnd_index = GetColormap()->Get3DShadeColor(); else bkgnd_index = GetColormap()->GetDefaultBackColor(); { JSize r, g, b; GetColormap()->GetRGB(bkgnd_index, &r, &g, &b); bkgnd = ((r & 0xFF00) << 8) | (g & 0xFF00) | ((b & 0xFF00) >> 8); } ResIDT iconID = 0; bool disabled = false; JXImage* draw_me = NULL; JRect actual_rect(GetBounds()); if (IsActive()) { if (IsChecked()) iconID = DrawChecked() ? itsOnImageID : itsOnPushedImageID; else iconID = !DrawChecked() ? itsOffImageID : itsOffPushedImageID; } else { iconID = itsOffImageID; disabled = true; } draw_me = CIconLoader::GetIcon(iconID, this, actual_rect.width() >= 32 ? 32 : 16, bkgnd, disabled ? CIconLoader::eDisabled : CIconLoader::eNormal); // Center icon in button area int hoffset = (GetBoundsWidth() - draw_me->GetBounds().width())/2; int voffset = (GetBoundsHeight() - draw_me->GetBounds().height())/2; p.JPainter::Image(*draw_me, draw_me->GetBounds(), actual_rect.left + hoffset, actual_rect.top + voffset); } void JXMultiImageCheckbox::DrawBackground(JXWindowPainter& p, const JRect& frame) { bool selected = DrawChecked(); bool enabled = IsActive(); bool use_frame = GetBorderWidth(); CDrawUtils::DrawBackground(p, frame, selected && use_frame, enabled); } void JXMultiImageCheckbox::DrawBorder(JXWindowPainter& p, const JRect& frame) { bool selected = DrawChecked(); bool enabled = IsActive(); bool use_frame = GetBorderWidth(); if (use_frame) CDrawUtils::Draw3DBorder(p, frame, selected, enabled); }
28.030675
148
0.591814
mulberry-mail
5e96838dc84f050a83b3cff06f613681a0ba0b70
2,482
cpp
C++
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
5
2015-10-11T10:22:39.000Z
2019-07-24T10:09:13.000Z
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
src/core/subsystem/replay/ReplayUtility.cpp
Robograde/Robograde
2c9a7d0b8250ec240102d504127f5c54532cb2b0
[ "Zlib" ]
null
null
null
/************************************************** Copyright 2015 Daniel "MonzUn" Bengtsson ***************************************************/ #include "ReplayUtility.h" #include <messaging/GameMessages.h> using namespace SerializationUtility; ReplayFrame::ReplayFrame( ) {} ReplayFrame::~ReplayFrame( ) { for ( int i = 0; i < Messages.size( ); ++i ) tDelete( Messages[i] ); } ReplayFrame::ReplayFrame( const ReplayFrame& rhs ) { this->ID = rhs.ID; this->Hash = rhs.Hash; this->RandomCounter = rhs.RandomCounter; for ( int i = 0; i < rhs.Messages.size( ); ++i ) this->Messages.push_back( rhs.Messages[i]->Clone( ) ); } unsigned int ReplayFrame::GetSerializationSize( ) const { unsigned int size = static_cast<unsigned int>(sizeof(unsigned int)* 4); // ID, Hash, RandomCounter, and vector size for ( auto& message : Messages ) size += message->GetSerializationSize(); return size; } void ReplayFrame::Serialize( Byte*& buffer ) const { // Serialize ID and Hash CopyAndIncrementDestination( buffer, &ID, sizeof(unsigned int) ); CopyAndIncrementDestination( buffer, &Hash, sizeof(unsigned int) ); CopyAndIncrementDestination( buffer, &RandomCounter, sizeof(unsigned int) ); // Serialize all messages for the current frame unsigned int recordedMessagesCount = static_cast<unsigned int>(Messages.size( )); CopyAndIncrementDestination( buffer, &recordedMessagesCount, sizeof(unsigned int) ); for ( auto& message : Messages ) message->Serialize( buffer ); } void ReplayFrame::Deserialize( const Byte*& buffer ) { // Deserialize ID and Hash CopyAndIncrementSource( &ID, buffer, sizeof(unsigned int) ); CopyAndIncrementSource( &Hash, buffer, sizeof(unsigned int) ); CopyAndIncrementSource( &RandomCounter, buffer, sizeof(unsigned int) ); // Deserialize all messages for the current frame unsigned int recordedMessagesCount; CopyAndIncrementSource( &recordedMessagesCount, buffer, sizeof(unsigned int) ); Messages.reserve( recordedMessagesCount ); for ( unsigned int i = 0; i < recordedMessagesCount; ++i ) { MessageTypes::MessageType messageType; memcpy( &messageType, buffer, sizeof( MESSAGE_TYPE_ENUM_UNDELYING_TYPE ) ); // Deserialize the message type Message* message = Messages::GetDefaultMessage( messageType ); // Use the type to run the specific message types constructor message->Deserialize( buffer ); // Read the specific data for this message Messages.push_back( message ); // Add it to this frames recorded messages } }
35.457143
126
0.711523
Robograde
5e9c9565c604f811f449f55c1b7b13ebadb983c3
8,621
cc
C++
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
S0006E-Graphics/lab-env-master/projects/GrafikLabb/code/Graphics.cc
miraz12/Projects
ae24a4caa347f74f7ccc36014e8f7b0f801d47db
[ "MIT" ]
null
null
null
#include "config.h" #include "Graphics.h" #include <cstring> #include <chrono> #include "MeshResource.h" #include "GraphicsNode.h" #include "JointsStructure.h" #define PI 3.14159265 //#define true false using namespace Display; namespace Labb2 { Graphics::Graphics() { } Graphics::~Graphics() { } bool Graphics::Open() { App::Open(); this->window = new Display::Window; this->window->SetSize(600, 600); camera.setValues(0, 0, 4); origin.setValues(0, 0, 0); headUp.setValues(0, 1, 0); camFront.setValues(0.0f, 0.0f, 1.0f); yaw = -90.0f; // Yaw is initialized to -90.0 degrees since a yaw of 0.0 results in a direction vector pointing to the right (due to how Eular angles work) so we initially rotate a bit to the left. pitch = 0.0f; oldPosX = 300; oldPosY = 300; window->SetKeyPressFunction([this](int32 key, int32, int32, int32) { float camSpeed = 0.05f; if (GLFW_KEY_E == key) { if (mouseLocked == false) { glfwSetInputMode(this->window->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); mouseLocked = true; } } if (GLFW_KEY_R == key) { glfwSetInputMode(this->window->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); mouseLocked = false; } if (GLFW_KEY_1 == key) { this->clipIndex = 0; } if (GLFW_KEY_2 == key) { this->clipIndex = 1; } if (GLFW_KEY_3 == key) { this->clipIndex = 2; } if (GLFW_KEY_4 == key) { this->clipIndex = 3; } if (GLFW_KEY_5 == key) { this->clipIndex = 4; } if (GLFW_KEY_6 == key) { this->clipIndex = 5; } if (GLFW_KEY_7 == key) { this->clipIndex = 6; } if (GLFW_KEY_8 == key) { this->clipIndex = 7; } if (GLFW_KEY_ESCAPE == key) { this->window->Close(); } if (GLFW_KEY_COMMA == key) { this->skeleIndex++; } if (GLFW_KEY_PERIOD == key) { this->skeleIndex--; } if (GLFW_KEY_W == key) { if (!mouseLocked) { this->y += 0.1f; } else { camera[0] -= (camFront * camSpeed)[0]; camera[1] -= (camFront * camSpeed)[1]; camera[2] -= (camFront * camSpeed)[2]; } //this->y += 0.1f; //camera[1] += 0.1f; } if (GLFW_KEY_A == key) { if (!mouseLocked) { this->x += 0.1f; } else { camera[0] -= (camFront.cross(headUp).normalizeRe() * camSpeed)[0]; camera[1] -= (camFront.cross(headUp).normalizeRe() * camSpeed)[1]; camera[2] -= ((camFront.cross(headUp).normalizeRe()) * camSpeed)[2]; } //camera[0] -= 0.1f; } if (GLFW_KEY_S == key) { if (!mouseLocked) { this->y -= 0.1f; } else { camera[0] += (camFront * camSpeed)[0]; camera[1] += (camFront * camSpeed)[1]; camera[2] += (camFront * camSpeed)[2]; } //camera[1] -= 0.1f; } if (GLFW_KEY_D == key) { if (!mouseLocked) { this->x -= 0.1f; } else { camera[0] += (camFront.cross(headUp).normalizeRe() * camSpeed)[0]; camera[1] += (camFront.cross(headUp).normalizeRe() * camSpeed)[1]; camera[2] += ((camFront.cross(headUp).normalizeRe()) * camSpeed)[2]; } //camera[0] += 0.1f; } }); window->SetMousePressFunction([this](int32 key, int32 state , int32) { if (key == GLFW_MOUSE_BUTTON_LEFT && state == GLFW_PRESS) { mousePressedLeft = true; } if (key == GLFW_MOUSE_BUTTON_LEFT && state == GLFW_RELEASE) { mousePressedLeft = false; } if (key == GLFW_MOUSE_BUTTON_RIGHT && state == GLFW_PRESS) { mousePressed = true; if (vertexINT == 0) { v1.setXY(mX, mY); vertexINT++; } else if (vertexINT == 1) { v2.setXY(mX, mY); vertexINT++; } else if (vertexINT == 2) { v3.setXY(mX, mY); vertexINT++; } } if (key == GLFW_MOUSE_BUTTON_RIGHT && state == GLFW_RELEASE) { mousePressed = false; } }); window->SetMouseScrollFunction([this](float64 x, float64 y) { scrollX += 0.1f * y; }); window->SetMouseMoveFunction([this](float64 xpos, float64 ypos) { if (mousePressedLeft) { posX = (xpos - oldPosX); posY = (ypos - oldPosY); } if (mouseLocked == false || mousePressed != true ) { oldPosX = xpos; oldPosY = ypos; return; } if(firstM) { oldPosX = xpos; oldPosY = ypos; firstM = false; } GLfloat xoffset = xpos - oldPosX; GLfloat yoffset = oldPosY - ypos; oldPosX = xpos; oldPosY = ypos; float sensitivity = 0.05; xoffset *= sensitivity; yoffset *= sensitivity; yaw += xoffset; pitch -= yoffset; if(pitch > 89.0f) pitch = 89.0f; if(pitch < -89.0f) pitch = -89.0f; vector3D front; front[0] = (cos(rad(yaw)) * cos(rad(pitch))); front[1] = (sin(rad(pitch))); front[2] = -(sin(rad(yaw)) * cos(rad(pitch))); camFront = front.normalizeRe(); mX = xpos; mY = 300 - ypos; oldPosX = xpos; oldPosY = ypos; }); if (this->window->Open()) { glClearColor(0.1f, 0.1f, 0.1f, 1.0f); return true; } return false; } void Graphics::Run() { /* SoftRender s; s.lambdaPixels = [](SoftRender::Vertex v, unsigned char *image) { SoftRender::Color c; vector3D PL(50.0f, 2.0f, 1.0f); vector3D vec(v.nx, v.ny, v.nz); PL.normalize(); float intens = vec.dott(PL)-4; if (intens < 0) { intens = 0; } if (intens > 1) { intens = 1; } int teX = (v.U * 300); int teY = (v.V * 300); int index = (teY * 300 + teX) * 4; c.R = image[index] * intens; c.G = image[index + 1] * intens; c.B = image[index + 2] * intens; return c; }; TextureResource tex; s.loadTexture("frooog.jpg"); s.draw(300, 300); s.drawQuad(); GraphicsNode graph; texture = std::make_shared<TextureResource>(); texture->loadFromRaz(s); texture->bind(); graph.setTexture(texture); */ JointsStructure a; GraphicsNode graph; matrix4D mvp; matrix4D projection; matrix4D view; glEnable(GL_DEPTH_TEST); //a.createSkeleton(); projection = (projection.setPerspective(45.0f, (600.0f / 600.0f), 0.1f, 100.0f)); //view = view.LookAtRH(camera, origin, headUp); a.createInverseOriginal(); typedef std::chrono::system_clock Clock; auto start = Clock::now(); static int keyclip = 0; while (this->window->IsOpen()) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); this->window->Update(); //Rotate camera: //float radius = 5.0f; //float camX = sin(glfwGetTime()) * radius; //float camZ = cos(glfwGetTime()) * radius; model = model.transform(x, y, 0) * model.rot_x(-posY ) * model.rot_y(-posX ); //model = model.transform(x * 100, y * 100, (scrollX + 5) * 100) * model.rot_x(posY / 10.0f) * model.rot_y(-posX / 10.0f); //camera[2] = (float)(scrollX - 2); view = view.LookAtRH(camera, camera+camFront, headUp); //Rotate camera: //camera.setValues(camX, 0.0, camZ); //view = view.LookAtRH(camera, origin, headUp); posY = 0.0f; posX = 0.0f; //matrix4D rotmaty = model.rot_x(-posY * 100 ) * model.rot_y(-posX *100 ) ;// rotmaty.rot_y(2); //matrix4D rotmatx = rotmaty.rot_z(5); static int r = 0; if (a.an->animClips[clipIndex].keyDuration <= (ushort)std::chrono::duration_cast<std::chrono::milliseconds> (Clock::now()-start).count()) { if ( r >= a.an->animClips[clipIndex].numKeys) { r = 0; } a.PlayAnimation(r++, clipIndex); start = Clock::now(); } //graph.draw(model); a.drawSkeleton(); //mvp = projection * view * model; matrix4D pv = projection * view; graph.drawAnim(model, pv, a.bones); this->window->SwapBuffers(); } } float Graphics::rad(float d) { float rad = (PI/180) * d; return rad; } } // namespace Example
21.825316
201
0.519545
miraz12
5ea1ba69aa45b824e72a50c7fd3bb59c7b96a9b8
3,445
cpp
C++
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
9
2016-05-27T01:00:39.000Z
2021-04-01T08:54:46.000Z
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
1
2016-03-03T22:54:08.000Z
2016-03-03T22:54:08.000Z
Test/Qosh/src/stak.cpp
mfaithfull/QOR
0fa51789344da482e8c2726309265d56e7271971
[ "BSL-1.0" ]
4
2016-05-27T01:00:43.000Z
2018-08-19T08:47:49.000Z
/* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1992 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany * * Sccsid @(#)stak.c 1.5 (gritter) 6/15/05 */ /* from OpenSolaris "stak.c 1.10 05/06/08 SMI" */ /* * UNIX shell */ #include "defs.h" /* ======== storage allocation ======== */ unsigned char * getstak ( /* allocate requested stack */ intptr_t asize ) { register unsigned char *oldstak; register int size; size = round((intptr_t)asize, BYTESPERWORD); oldstak = stakbot; staktop = stakbot += size; if (staktop >= brkend) growstak(staktop); return(oldstak); } /* * set up stack for local use * should be followed by `endstak' */ unsigned char * locstak(void) { if (brkend - stakbot < BRKINCR) { if (setbrk(brkincr) == (unsigned char *)-1) error((const unsigned char*)nostack); if (brkincr < BRKMAX) brkincr += 256; } return(stakbot); } void growstak(unsigned char *newtop) { register uintptr_t incr; incr = (uintptr_t)round(newtop - brkend + 1, BYTESPERWORD); if (brkincr > incr) incr = brkincr; if (setbrk(incr) == (unsigned char *)-1) error((const unsigned char*)nospace); } unsigned char * savstak(void) { assert(staktop == stakbot); return(stakbot); } unsigned char * endstak ( /* tidy up after `locstak' */ register unsigned char *argp ) { register unsigned char *oldstak; if (argp >= brkend) growstak(argp); *argp++ = 0; oldstak = stakbot; stakbot = staktop = (unsigned char *)round(argp, BYTESPERWORD); if (staktop >= brkend) growstak(staktop); return(oldstak); } void tdystak ( /* try to bring stack back to x */ register unsigned char *x ) { while ((unsigned char *)stakbsy > x) { free(stakbsy); stakbsy = stakbsy->word; } staktop = stakbot = max(x, stakbas); rmtemp((struct ionod *)x); } void stakchk(void) { if ((brkend - stakbas) > BRKINCR + BRKINCR) setbrk(-BRKINCR); } unsigned char * cpystak(unsigned char *x) { return(endstak(movstrstak(x, locstak()))); } unsigned char * movstrstak(register const unsigned char *a, register unsigned char *b) { do { if (b >= brkend) growstak(b); } while (*b++ = *a++); return(--b); } /* * Copy s2 to s1, always copy n bytes. * Return s1 */ unsigned char * memcpystak(register unsigned char *s1, register const unsigned char *s2, register int n) { register unsigned char *os1 = s1; while (--n >= 0) { if (s1 >= brkend) growstak(s1); *s1++ = *s2++; } return (os1); }
20.264706
72
0.666183
mfaithfull
5ea331084ee6c9a229ac38ecefc976f5dec7e688
2,319
cpp
C++
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
PC_Aula_15_DFS_03-nov-2021/make_a_large_island.cpp
MisaelVM/ProgComp2021B
6134ae425a4c1a4f087bc1e14615d1f06979beff
[ "BSD-3-Clause" ]
null
null
null
#include <iostream> #include <vector> #include <set> int floodFill(std::vector<std::vector<int>>& grid, int i, int j, int mark) { if (grid[i][j] != 1) return 0; grid[i][j] = mark; int area = 1; if (i > 0) area += floodFill(grid, i - 1, j, mark); if (i < grid.size() - 1) area += floodFill(grid, i + 1, j, mark); if (j > 0) area += floodFill(grid, i, j - 1, mark); if (j < grid.size() - 1) area += floodFill(grid, i, j + 1, mark); return area; } std::set<int> get_neighbouring_islands(const std::vector<std::vector<int>>& grid, int i, int j) { std::set<int> neighbouring_islands; if (i > 0 && grid[i - 1][j]) neighbouring_islands.insert(grid[i - 1][j]); if (i < grid.size() - 1 && grid[i + 1][j]) neighbouring_islands.insert(grid[i + 1][j]); if (j > 0 && grid[i][j - 1]) neighbouring_islands.insert(grid[i][j - 1]); if (j < grid[0].size() - 1 && grid[i][j + 1]) neighbouring_islands.insert(grid[i][j + 1]); return neighbouring_islands; } int largestIsland(std::vector<std::vector<int>>& grid) { int max_area = 0; std::vector<int> islands_areas; int island_count = 0; for (int i = 0; i < grid.size(); ++i) for (int j = 0; j < grid[0].size(); ++j) if (grid[i][j] == 1) { int area = floodFill(grid, i, j, island_count + 2); islands_areas.push_back(area); max_area = std::max(max_area, area); ++island_count; } for (int i = 0; i < grid.size(); ++i) for (int j = 0; j < grid[0].size(); ++j) if (!grid[i][j]) { std::set<int> neighbouring_islands = get_neighbouring_islands(grid, i, j); int large_island_area = 1; for (auto& island_mark : neighbouring_islands) large_island_area += islands_areas[island_mark - 2]; max_area = std::max(max_area, large_island_area); } return max_area; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::vector<std::vector<int>> G; // Caso de prueba 1 // Entrada: // 1 0 // 0 1 // Salida: // 3 G = { { 1, 0 }, { 0, 1 } }; std::cout << largestIsland(G) << "\n"; // Caso de prueba 2 // Entrada: // 1 1 // 1 0 // Salida: // 4 G = { { 1, 1 }, { 0, 1 } }; std::cout << largestIsland(G) << "\n"; // Caso de prueba 3 // Entrada: // 1 1 // 1 1 // Salida: // 4 G = { { 1, 1 }, { 1, 1 } }; std::cout << largestIsland(G) << "\n"; return 0; }
22.960396
97
0.575679
MisaelVM
5ea37dd78a2b63f728f4d3a92db6b9d1b6ebca7d
98,088
hpp
C++
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
4
2018-04-11T13:31:10.000Z
2018-11-13T09:59:39.000Z
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
null
null
null
AarbitraryWindowedGuidedImageFilter/GaussianFilterSpectralRecursive.hpp
norishigefukushima/AarbitraryWindowedGuidedImageFilter
d6c88c65c7f2521c6728024e12e7cbb36ad095b1
[ "BSD-3-Clause" ]
2
2018-04-11T02:09:08.000Z
2018-06-03T07:43:56.000Z
#pragma once #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> using namespace cv; using namespace std; #define ___MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3, out4, out5, out6, out7, __in0, __in1, __in2, __in3, __in4, __in5, __in6, __in7, __out0, __out1, __out2, __out3, __out4, __out5, __out6, __out7, __tmp0, __tmp1, __tmp2, __tmp3, __tmp4, __tmp5, __tmp6, __tmp7, __tmpp0, __tmpp1, __tmpp2, __tmpp3, __tmpp4, __tmpp5, __tmpp6, __tmpp7) \ do { \ __m256 __in0 = (in0), __in1 = (in1), __in2 = (in2), __in3 = (in3), __in4 = (in4), __in5 = (in5), __in6 = (in6), __in7 = (in7); \ __m256 __tmp0, __tmp1, __tmp2, __tmp3, __tmp4, __tmp5, __tmp6, __tmp7; \ __m256 __tmpp0, __tmpp1, __tmpp2, __tmpp3, __tmpp4, __tmpp5, __tmpp6, __tmpp7; \ __m256 __out0, __out1, __out2, __out3, __out4, __out5, __out6, __out7; \ __tmp0 = _mm256_unpacklo_ps(__in0, __in1); \ __tmp1 = _mm256_unpackhi_ps(__in0, __in1); \ __tmp2 = _mm256_unpacklo_ps(__in2, __in3); \ __tmp3 = _mm256_unpackhi_ps(__in2, __in3); \ __tmp4 = _mm256_unpacklo_ps(__in4, __in5); \ __tmp5 = _mm256_unpackhi_ps(__in4, __in5); \ __tmp6 = _mm256_unpacklo_ps(__in6, __in7); \ __tmp7 = _mm256_unpackhi_ps(__in6, __in7); \ __tmpp0 = _mm256_shuffle_ps(__tmp0, __tmp2, 0x44); \ __tmpp1 = _mm256_shuffle_ps(__tmp0, __tmp2, 0xEE); \ __tmpp2 = _mm256_shuffle_ps(__tmp1, __tmp3, 0x44); \ __tmpp3 = _mm256_shuffle_ps(__tmp1, __tmp3, 0xEE); \ __tmpp4 = _mm256_shuffle_ps(__tmp4, __tmp6, 0x44); \ __tmpp5 = _mm256_shuffle_ps(__tmp4, __tmp6, 0xEE); \ __tmpp6 = _mm256_shuffle_ps(__tmp5, __tmp7, 0x44); \ __tmpp7 = _mm256_shuffle_ps(__tmp5, __tmp7, 0xEE); \ __out0 = _mm256_permute2f128_ps(__tmpp0, __tmpp4, 0x20); \ __out1 = _mm256_permute2f128_ps(__tmpp1, __tmpp5, 0x20); \ __out2 = _mm256_permute2f128_ps(__tmpp2, __tmpp6, 0x20); \ __out3 = _mm256_permute2f128_ps(__tmpp3, __tmpp7, 0x20); \ __out4 = _mm256_permute2f128_ps(__tmpp0, __tmpp4, 0x31); \ __out5 = _mm256_permute2f128_ps(__tmpp1, __tmpp5, 0x31); \ __out6 = _mm256_permute2f128_ps(__tmpp2, __tmpp6, 0x31); \ __out7 = _mm256_permute2f128_ps(__tmpp3, __tmpp7, 0x31); \ (out0) = __out0, (out1) = __out1, (out2) = __out2, (out3) = __out3, (out4) = __out4, (out5) = __out5, (out6) = __out6, (out7) = __out7; \ } while (0) #define _MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7) \ ___MM256_TRANSPOSE8_PS(in0, in1, in2, in3, in4, in5, in6, in7, in0, in1, in2, in3, in4, in5, in6, in7, \ __in0##__LINE__, __in1##__LINE__, __in2##__LINE__, __in3##__LINE__, __in4##__LINE__, __in5##__LINE__, __in6##__LINE__, __in7##__LINE__, \ __out0##__LINE__, __out1##__LINE__, __out2##__LINE__, __out3##__LINE__, __out4##__LINE__, __out5##__LINE__, __out6##__LINE__, __out7##__LINE__, \ __tmp0##__LINE__, __tmp1##__LINE__, __tmp2##__LINE__, __tmp3##__LINE__, __tmp4##__LINE__, __tmp5##__LINE__, __tmp6##__LINE__, __tmp7##__LINE__, \ __tmpp0##__LINE__, __tmpp1##__LINE__, __tmpp2##__LINE__, __tmpp3##__LINE__, __tmpp4##__LINE__, __tmpp5##__LINE__, __tmpp6##__LINE__, __tmpp7##__LINE__) #define ___MM256_TRANSPOSE4_PD(in0, in1, in2, in3, out0, out1, out2, out3, __in0, __in1, __in2, __in3, __out0, __out1, __out2, __out3, __tmp0, __tmp1, __tmp2, __tmp3) \ do { \ __m256d __in0 = (in0), __in1 = (in1), __in2 = (in2), __in3 = (in3); \ __m256d __tmp0, __tmp1, __tmp2, __tmp3; \ __m256d __out0, __out1, __out2, __out3; \ __tmp0 = _mm256_shuffle_pd(__in0, __in1, 0x0); \ __tmp1 = _mm256_shuffle_pd(__in0, __in1, 0xf); \ __tmp2 = _mm256_shuffle_pd(__in2, __in3, 0x0); \ __tmp3 = _mm256_shuffle_pd(__in2, __in3, 0xf); \ __out0 = _mm256_permute2f128_pd(__tmp0, __tmp2, 0x20); \ __out1 = _mm256_permute2f128_pd(__tmp1, __tmp3, 0x20); \ __out2 = _mm256_permute2f128_pd(__tmp0, __tmp2, 0x31); \ __out3 = _mm256_permute2f128_pd(__tmp1, __tmp3, 0x31); \ (out0) = __out0, (out1) = __out1, (out2) = __out2, (out3) = __out3; \ } while (0) #define _MM256_TRANSPOSE4_PD(in0, in1, in2, in3) \ ___MM256_TRANSPOSE4_PD(in0, in1, in2, in3, in0, in1, in2, in3, \ __in0##__LINE__, __in1##__LINE__, __in2##__LINE__, __in3##__LINE__, \ __out0##__LINE__, __out1##__LINE__, __out2##__LINE__, __out3##__LINE__, \ __tmp0##__LINE__, __tmp1##__LINE__, __tmp2##__LINE__, __tmp3##__LINE__) //spectral recursive Gaussian Filter //K. Sugimoto and S. Kamata: "Fast Gaussian filter with second-order shift property of DCT-5", Proc. IEEE Int. Conf. on Image Process. (ICIP2013), pp.514-518 (Sep. 2013). namespace spectral_recursive_filter { #define USE_BORDER_REPLICATE 1 //BORDER_REPLICATE = 1, //!< `aaaaaa|abcdefgh|hhhhhhh` //#define USE_BORDER_REFLECT 1 //BORDER_REFLECT = 2, //!< `fedcba|abcdefgh|hgfedcb` //#define USE_BORDER_REFLECT_101 1 //BORDER_REFLECT_101 = 4, //!< `gfedcb|abcdefgh|gfedcba` //extrapolation functions //(atE() and atS() require variables w and h in their scope respectively) #ifdef USE_BORDER_REPLICATE #define atW(x) (std::max(x,0)) #define atN(y) (std::max(y,0)) #define atE(x) (std::min(x,w-1)) #define atS(y) (std::min(y,h-1)) #elif USE_BORDER_REFLECT #define atW(x) ( x < 0 ? std::abs(x+1) : std::abs(x)) #define atN(y) ( y < 0 ? std::abs(y+1) : std::abs(y)) #define atE(x) ( x < w ? w-1-std::abs(w-1-(x)) : w-std::abs(w-1-(x))) #define atS(y) ( y < h ? h-1-std::abs(h-1-(y)) : h-std::abs(h-1-(y))) //#define atE(x) ( x < w ? w-1-std::abs(w-1-(x)) : w-2-std::abs(w-1-(x))) //#define atS(y) ( y < h ? h-1-std::abs(h-1-(y)) : h-2-std::abs(h-1-(y))) #elif USE_BORDER_REFLECT_101 #define atW(x) (std::abs(x)) #define atN(y) (std::abs(y)) #define atE(x) (w-1-std::abs(w-1-(x))) #define atS(y) (h-1-std::abs(h-1-(y))) #endif class gauss { private: static const int K = 2; //order of approximation (do not change!) private: double sx, sy; //scale of Gaussian int rx, ry; //kernel radius std::vector<double> spectX, spectY; std::vector<double> tableX, tableY; //look-up tables public: gauss(double sx, double sy) :sx(sx), sy(sy) { if (sx < 0.0 || sy < 0.0) throw std::invalid_argument("\'sx\' and \'sy\' should be nonnegative!"); rx = estimate_radius(sx); ry = estimate_radius(sy); spectX = gen_spectrum(sx, rx); spectY = gen_spectrum(sy, ry); tableX = build_lookup_table(rx, spectX); tableY = build_lookup_table(ry, spectY); } ~gauss() {} private: static inline double phase(int r) { return 2.0*CV_PI / (r + 1 + r); //DCT/DST-5 } static inline int estimate_radius(double s) { //return (s<4.0) ? int(3.3333*s-0.3333+0.5) : int(3.4113*s-0.6452+0.5); //K==3 return (s < 4.0) ? int(3.0000*s - 0.2000 + 0.5) : int(3.0000*s + 0.5); //K==2 } static inline std::vector<double> gen_spectrum(double s, int r) { const double phi = phase(r); std::vector<double> spect(K); for (int k = 1; k <= K; k++) spect[k - 1] = 2.0*exp(-0.5*s*s*phi*phi*k*k); return spect; } static inline std::vector<double> build_lookup_table(int r, std::vector<double>& spect) { assert(spect.size() == K); const double phi = phase(r); std::vector<double> table(K*(1 + r)); for (int u = 0; u <= r; ++u) for (int k = 1; k <= K; ++k) table[K*u + k - 1] = cos(k*phi*u)*spect[k - 1]; return table; } template <typename T> inline void filter_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_sse_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_sse_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_h(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_v(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_h_OMP(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } template <typename T> inline void filter_avx_v_OMP(int w, int h, T* src, T* dst) { throw std::invalid_argument("Unsupported element type!"); } public: template <typename T> void filter(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_v<T>(w, h, src, dst); else if (sy == 0.0) filter_h<T>(w, h, src, dst); else { filter_v<T>(w, h, src, dst); filter_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_sse(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_sse_v<T>(w, h, src, dst); else if (sy == 0.0) filter_sse_h<T>(w, h, src, dst); else { filter_sse_v<T>(w, h, src, dst); filter_sse_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_avx(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_avx_v<T>(w, h, src, dst); else if (sy == 0.0) filter_avx_h<T>(w, h, src, dst); else { filter_avx_v<T>(w, h, src, dst); filter_avx_h<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } template <typename T> void filter_avxOMP(int w, int h, T* src, T* dst) { if (w <= 4.0*sx || h <= 4.0*sy) throw std::invalid_argument("\'sx\' and \'sy\' should be less than about w/4 or h/4!"); //filtering is skipped if s==0.0 if (sx == 0.0 && sy == 0.0) return; else if (sx == 0.0) filter_avx_v_OMP<T>(w, h, src, dst); else if (sy == 0.0) filter_avx_h_OMP<T>(w, h, src, dst); else { filter_avx_v_OMP<T>(w, h, src, dst); filter_avx_h_OMP<T>(w, h, dst, dst); //only filter_h() allows src==dst. } } void filter(const cv::Mat& src, cv::Mat& dst) { //checking the format of input/output images if (src.size() != dst.size()) throw std::invalid_argument("\'src\' and \'dst\' should have the same size!"); if (src.type() != dst.type()) throw std::invalid_argument("\'src\' and \'dst\' should have the same element type!"); if (src.channels() != 1 || dst.channels() != 1) throw std::invalid_argument("Multi-channel images are unsupported!"); if (src.isSubmatrix() || dst.isSubmatrix()) throw std::invalid_argument("Subimages are unsupported!"); switch (src.type()) { case CV_32FC1: filter_avx<float>(src.cols, src.rows, reinterpret_cast<float*>(src.data), reinterpret_cast<float*>(dst.data)); break; case CV_64FC1: filter_avx<double>(src.cols, src.rows, reinterpret_cast<double*>(src.data), reinterpret_cast<double*>(dst.data)); break; default: throw std::invalid_argument("Unsupported element type!"); break; } } }; //************************************************************************************************* template<> inline void gauss::filter_h<float>(int w, int h, float* src, float* dst) { const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; float sum, a1, a2, b1, b2; float dA, dB, delta; std::vector<float> buf(w); //to allow for src==dst for (int y = 0; y < h; ++y) { std::copy(&src[w*y], &src[w*y + w], buf.begin()); sum = buf[0]; a1 = buf[0] * table[0]; b1 = buf[1] * table[0]; a2 = buf[0] * table[1]; b2 = buf[1] * table[1]; for (int u = 1; u <= r; ++u) { const float sumA = buf[atW(0 - u)] + buf[0 + u]; const float sumB = buf[atW(1 - u)] + buf[1 + u]; sum += sumA; a1 += sumA*table[K*u + 0]; b1 += sumB*table[K*u + 0]; a2 += sumA*table[K*u + 1]; b2 += sumB*table[K*u + 1]; } //the first pixel (x=0) float* q = &dst[w*y]; q[0] = norm*(sum + a1 + a2); dA = buf[atE(0 + r + 1)] - buf[atW(0 - r)]; sum += dA; //the other pixels (0<x<w) int x = 1; while (true) //four-length ring buffers { q[x] = norm*(sum + b1 + b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 + cfR1*delta; a2 += -cf12*b2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - a1 - a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 + cfR1*delta; b2 += +cf12*a2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - b1 - b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 - cfR1*delta; a2 += -cf12*b2 - cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum + a1 + a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 - cfR1*delta; b2 += +cf12*a2 - cfR2*delta; x++; if (w <= x) break; } } } template<> inline void gauss::filter_v<float>(int w, int h, float* src, float* dst) { const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning std::vector<float> workspace((2 * K + 1)*w); //calculating the first and second terms for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; ws[0] = src[x]; ws[1] = src[x + w] * table[0]; ws[2] = src[x] * table[0]; ws[3] = src[x + w] * table[1]; ws[4] = src[x] * table[1]; } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w; ++x) { const float sum0 = src[x + w*atN(0 - v)] + src[x + w*(0 + v)]; const float sum1 = src[x + w*atN(1 - v)] + src[x + w*(1 + v)]; float* ws = &workspace[(2 * K + 1)*x]; ws[0] += sum0; ws[1] += sum1*table[K*v + 0]; ws[2] += sum0*table[K*v + 0]; ws[3] += sum1*table[K*v + 1]; ws[4] += sum0*table[K*v + 1]; } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; float *q, *p0N, *p0S, *p1N, *p1S; for (int y = 0; y < 1; ++y) //the first line (y=0) { q = &dst[w*y]; p1N = &src[w*atN(0 - r)]; p1S = &src[w*atS(0 + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); ws[0] += p1S[x] - p1N[x]; } } for (int y = 1; y < h; ++y) //remaining lines (with two-length ring buffers) { q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[1] + ws[3]); const float d0 = p0S[x] - p0N[x]; const float d1 = p1S[x] - p1N[x]; const float delta = d1 - d0; ws[0] += d1; ws[2] = cfR1*delta + cf11*ws[1] - ws[2]; ws[4] = cfR2*delta + cf12*ws[3] - ws[4]; } y++; if (h <= y) break; //to the next line q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { float* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); const float d0 = p0S[x] - p0N[x]; const float d1 = p1S[x] - p1N[x]; const float delta = d1 - d0; ws[0] += d1; ws[1] = cfR1*delta + cf11*ws[2] - ws[1]; ws[3] = cfR2*delta + cf12*ws[4] - ws[3]; } } } template<> inline void gauss::filter_sse_h<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m128) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<float> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m128 pv0 = _mm_set_ps(buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m128 pv1 = _mm_set_ps(buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m128 sum = pv0; __m128 a1 = _mm_mul_ps(_mm_set1_ps(table[0]), pv0); __m128 b1 = _mm_mul_ps(_mm_set1_ps(table[0]), pv1); __m128 a2 = _mm_mul_ps(_mm_set1_ps(table[1]), pv0); __m128 b2 = _mm_mul_ps(_mm_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m128 pv0M = _mm_set_ps(p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m128 pv1M = _mm_set_ps(p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m128 pv0P = _mm_set_ps(p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m128 pv1P = _mm_set_ps(p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m128 sumA = _mm_add_ps(pv0M, pv0P); __m128 sumB = _mm_add_ps(pv1M, pv1P); sum = _mm_add_ps(sum, sumA); a1 = _mm_add_ps(a1, _mm_mul_ps(_mm_set1_ps(table[K*u + 0]), sumA)); b1 = _mm_add_ps(b1, _mm_mul_ps(_mm_set1_ps(table[K*u + 0]), sumB)); a2 = _mm_add_ps(a2, _mm_mul_ps(_mm_set1_ps(table[K*u + 1]), sumA)); b2 = _mm_add_ps(b2, _mm_mul_ps(_mm_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m128 pvA, pvB; __m128 dvA, dvB, delta; __m128 qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); sum = _mm_add_ps(sum, dvA); //b1=_mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1),delta),_mm_mul_ps(_mm_set1_ps(cf11),a1)),b1); //b2=_mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2),delta),_mm_mul_ps(_mm_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE4_PS(qv[0], qv[1], qv[2], qv[3]); _mm_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm_storeu_ps(&dst[w*(y + 3)], qv[3]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvA, dvB); sum = _mm_add_ps(sum, dvA); b1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), b1); b2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(sum, _mm_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm_set_ps(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm_set_ps(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm_sub_ps(pvB, pvA); delta = _mm_sub_ps(dvB, dvA); sum = _mm_add_ps(sum, dvB); a1 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), b1)), a1); a2 = _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE4_PS(qv[0], qv[1], qv[2], qv[3]); _mm_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm_storeu_ps(&dst[w*(y + 3) + x], qv[3]); } } } template<> inline void gauss::filter_sse_v<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m128) == 0); const int B = sizeof(__m128) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m128))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m128 p0 = _mm_load_ps(&src[x]); __m128 p1 = _mm_load_ps(&src[x + w]); _mm_store_ps(&ws[B * 0], p0); _mm_store_ps(&ws[B * 1], _mm_mul_ps(p1, _mm_set1_ps(table[0]))); _mm_store_ps(&ws[B * 2], _mm_mul_ps(p0, _mm_set1_ps(table[0]))); _mm_store_ps(&ws[B * 3], _mm_mul_ps(p1, _mm_set1_ps(table[1]))); _mm_store_ps(&ws[B * 4], _mm_mul_ps(p0, _mm_set1_ps(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m128 sum0 = _mm_add_ps(_mm_load_ps(&src[x + w*atN(0 - v)]), _mm_load_ps(&src[x + w*(0 + v)])); __m128 sum1 = _mm_add_ps(_mm_load_ps(&src[x + w*atN(1 - v)]), _mm_load_ps(&src[x + w*(1 + v)])); _mm_store_ps(&ws[B * 0], _mm_add_ps(_mm_load_ps(&ws[B * 0]), sum0)); _mm_store_ps(&ws[B * 1], _mm_add_ps(_mm_load_ps(&ws[B * 1]), _mm_mul_ps(sum1, _mm_set1_ps(table[K*v + 0])))); _mm_store_ps(&ws[B * 2], _mm_add_ps(_mm_load_ps(&ws[B * 2]), _mm_mul_ps(sum0, _mm_set1_ps(table[K*v + 0])))); _mm_store_ps(&ws[B * 3], _mm_add_ps(_mm_load_ps(&ws[B * 3]), _mm_mul_ps(sum1, _mm_set1_ps(table[K*v + 1])))); _mm_store_ps(&ws[B * 4], _mm_add_ps(_mm_load_ps(&ws[B * 4]), _mm_mul_ps(sum0, _mm_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m128 a0 = _mm_load_ps(&ws[B * 0]); const __m128 a2 = _mm_load_ps(&ws[B * 2]); const __m128 a4 = _mm_load_ps(&ws[B * 4]); _mm_store_ps(&q[x], _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(a0, _mm_add_ps(a2, a4)))); const __m128 d = _mm_sub_ps(_mm_load_ps(&p1S[x]), _mm_load_ps(&p1N[x])); _mm_store_ps(&ws[B * 0], _mm_add_ps(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m128 a0 = _mm_load_ps(&ws[B * 0]); const __m128 a1 = _mm_load_ps(&ws[B * 1]); const __m128 a3 = _mm_load_ps(&ws[B * 3]); _mm_store_ps(&q[x], _mm_mul_ps(_mm_set1_ps(norm), _mm_add_ps(a0, _mm_add_ps(a1, a3)))); const __m128 d0 = _mm_sub_ps(_mm_load_ps(&p0S[x]), _mm_load_ps(&p0N[x])); const __m128 d1 = _mm_sub_ps(_mm_load_ps(&p1S[x]), _mm_load_ps(&p1N[x])); const __m128 delta = _mm_sub_ps(d1, d0); _mm_store_ps(&ws[B * 0], _mm_add_ps(a0, d1)); _mm_store_ps(&ws[B * 1], _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR1), delta), _mm_mul_ps(_mm_set1_ps(cf11), a1)), _mm_load_ps(&ws[B * 2]))); _mm_store_ps(&ws[B * 2], a1); _mm_store_ps(&ws[B * 3], _mm_sub_ps(_mm_add_ps(_mm_mul_ps(_mm_set1_ps(cfR2), delta), _mm_mul_ps(_mm_set1_ps(cf12), a3)), _mm_load_ps(&ws[B * 4]))); _mm_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_h_OMP<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m256) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; assert(h%B == 0); #pragma omp parallel for for (int y = 0; y < h / B*B; y += B) { //to allow for src==dst std::vector<float> buf(B*w); std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256 pv0 = _mm256_set_ps(buf[w * 7 + 0], buf[w * 6 + 0], buf[w * 5 + 0], buf[w * 4 + 0], buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256 pv1 = _mm256_set_ps(buf[w * 7 + 1], buf[w * 6 + 1], buf[w * 5 + 1], buf[w * 4 + 1], buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256 sum = pv0; __m256 a1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv0); __m256 b1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv1); __m256 a2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv0); __m256 b2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m256 pv0M = _mm256_set_ps(p0M[w * 7], p0M[w * 6], p0M[w * 5], p0M[w * 4], p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256 pv1M = _mm256_set_ps(p1M[w * 7], p1M[w * 6], p1M[w * 5], p1M[w * 4], p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256 pv0P = _mm256_set_ps(p0P[w * 7], p0P[w * 6], p0P[w * 5], p0P[w * 4], p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256 pv1P = _mm256_set_ps(p1P[w * 7], p1P[w * 6], p1P[w * 5], p1P[w * 4], p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256 sumA = _mm256_add_ps(pv0M, pv0P); __m256 sumB = _mm256_add_ps(pv1M, pv1P); sum = _mm256_add_ps(sum, sumA); a1 = _mm256_add_ps(a1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumA)); b1 = _mm256_add_ps(b1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumB)); a2 = _mm256_add_ps(a2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumA)); b2 = _mm256_add_ps(b2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m256 pvA, pvB; __m256 dvA, dvB, delta; __m256 qv[B]; //the first eight pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); sum = _mm256_add_ps(sum, dvA); //b1=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1),delta),_mm256_mul_ps(_mm256_set1_ps(cf11),a1)),b1); //b2=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2),delta),_mm256_mul_ps(_mm256_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3)], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4)], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5)], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6)], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7)], qv[7]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //eight-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3) + x], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4) + x], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5) + x], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6) + x], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7) + x], qv[7]); } } } template<> inline void gauss::filter_avx_h<float>(int w, int h, float* src, float* dst) { const int B = sizeof(__m256) / sizeof(float); const int r = rx; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableX[t]); const float cf11 = float(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<float> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256 pv0 = _mm256_set_ps(buf[w * 7 + 0], buf[w * 6 + 0], buf[w * 5 + 0], buf[w * 4 + 0], buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256 pv1 = _mm256_set_ps(buf[w * 7 + 1], buf[w * 6 + 1], buf[w * 5 + 1], buf[w * 4 + 1], buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256 sum = pv0; __m256 a1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv0); __m256 b1 = _mm256_mul_ps(_mm256_set1_ps(table[0]), pv1); __m256 a2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv0); __m256 b2 = _mm256_mul_ps(_mm256_set1_ps(table[1]), pv1); for (int u = 1; u <= r; ++u) { const float* p0M = &buf[atW(0 - u)]; const float* p1M = &buf[atW(1 - u)]; const float* p0P = &buf[(0 + u)]; const float* p1P = &buf[(1 + u)]; __m256 pv0M = _mm256_set_ps(p0M[w * 7], p0M[w * 6], p0M[w * 5], p0M[w * 4], p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256 pv1M = _mm256_set_ps(p1M[w * 7], p1M[w * 6], p1M[w * 5], p1M[w * 4], p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256 pv0P = _mm256_set_ps(p0P[w * 7], p0P[w * 6], p0P[w * 5], p0P[w * 4], p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256 pv1P = _mm256_set_ps(p1P[w * 7], p1P[w * 6], p1P[w * 5], p1P[w * 4], p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256 sumA = _mm256_add_ps(pv0M, pv0P); __m256 sumB = _mm256_add_ps(pv1M, pv1P); sum = _mm256_add_ps(sum, sumA); a1 = _mm256_add_ps(a1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumA)); b1 = _mm256_add_ps(b1, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 0]), sumB)); a2 = _mm256_add_ps(a2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumA)); b2 = _mm256_add_ps(b2, _mm256_mul_ps(_mm256_set1_ps(table[K*u + 1]), sumB)); } //sliding convolution float *pA, *pB; __m256 pvA, pvB; __m256 dvA, dvB, delta; __m256 qv[B]; //the first eight pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); sum = _mm256_add_ps(sum, dvA); //b1=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1),delta),_mm256_mul_ps(_mm256_set1_ps(cf11),a1)),b1); //b2=_mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2),delta),_mm256_mul_ps(_mm256_set1_ps(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0)], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1)], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2)], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3)], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4)], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5)], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6)], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7)], qv[7]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //eight-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the fifth pixel (x=4) qv[4] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 4 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 4 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the sixth pixel (x=5) qv[5] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 5 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 5 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //the seventh pixel (x=6) qv[6] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(a1, a2))); pA = &buf[atW(x + 6 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 6 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvA, dvB); sum = _mm256_add_ps(sum, dvA); b1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), b1); b2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), a2)), b2); //the eighth pixel (x=7) qv[7] = _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(sum, _mm256_add_ps(b1, b2))); pA = &buf[atW(x + 7 - r)]; pvA = _mm256_set_ps(pA[w * 7], pA[w * 6], pA[w * 5], pA[w * 4], pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 7 + r + 1)]; pvB = _mm256_set_ps(pB[w * 7], pB[w * 6], pB[w * 5], pB[w * 4], pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_ps(pvB, pvA); delta = _mm256_sub_ps(dvB, dvA); sum = _mm256_add_ps(sum, dvB); a1 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta), _mm256_mul_ps(_mm256_set1_ps(cf11), b1)), a1); a2 = _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta), _mm256_mul_ps(_mm256_set1_ps(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE8_PS(qv[0], qv[1], qv[2], qv[3], qv[4], qv[5], qv[6], qv[7]); _mm256_storeu_ps(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_ps(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_ps(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_ps(&dst[w*(y + 3) + x], qv[3]); _mm256_storeu_ps(&dst[w*(y + 4) + x], qv[4]); _mm256_storeu_ps(&dst[w*(y + 5) + x], qv[5]); _mm256_storeu_ps(&dst[w*(y + 6) + x], qv[6]); _mm256_storeu_ps(&dst[w*(y + 7) + x], qv[7]); } } } template<> inline void gauss::filter_avx_v<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m256) == 0); const int B = sizeof(__m256) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m256))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 p0 = _mm256_load_ps(&src[x]); __m256 p1 = _mm256_load_ps(&src[x + w]); _mm256_store_ps(&ws[B * 0], p0); _mm256_store_ps(&ws[B * 1], _mm256_mul_ps(p1, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 2], _mm256_mul_ps(p0, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 3], _mm256_mul_ps(p1, _mm256_set1_ps(table[1]))); _mm256_store_ps(&ws[B * 4], _mm256_mul_ps(p0, _mm256_set1_ps(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 sum0 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(0 - v)]), _mm256_load_ps(&src[x + w*(0 + v)])); __m256 sum1 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(1 - v)]), _mm256_load_ps(&src[x + w*(1 + v)])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(_mm256_load_ps(&ws[B * 0]), sum0)); _mm256_store_ps(&ws[B * 1], _mm256_add_ps(_mm256_load_ps(&ws[B * 1]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 2], _mm256_add_ps(_mm256_load_ps(&ws[B * 2]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 3], _mm256_add_ps(_mm256_load_ps(&ws[B * 3]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 1])))); _mm256_store_ps(&ws[B * 4], _mm256_add_ps(_mm256_load_ps(&ws[B * 4]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a2 = _mm256_load_ps(&ws[B * 2]); const __m256 a4 = _mm256_load_ps(&ws[B * 4]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a2, a4)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d0)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a1 = _mm256_load_ps(&ws[B * 1]); const __m256 a3 = _mm256_load_ps(&ws[B * 3]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a1, a3)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p0S[x]), _mm256_load_ps(&p0N[x])); const __m256 d1 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); const __m256 delta1 = _mm256_sub_ps(d1, d0); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d1)); _mm256_store_ps(&ws[B * 1], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta1), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), _mm256_load_ps(&ws[B * 2]))); _mm256_store_ps(&ws[B * 2], a1); _mm256_store_ps(&ws[B * 3], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta1), _mm256_mul_ps(_mm256_set1_ps(cf12), a3)), _mm256_load_ps(&ws[B * 4]))); _mm256_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_v_OMP<float>(int w, int h, float* src, float* dst) { assert(w % sizeof(__m256) == 0); const int B = sizeof(__m256) / sizeof(float); const int r = ry; const float norm = float(1.0 / (r + 1 + r)); std::vector<float> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = float(tableY[t]); //work space to keep raster scanning float* workspace = reinterpret_cast<float*>(_mm_malloc(sizeof(float)*(2 * K + 1)*w, sizeof(__m256))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 p0 = _mm256_load_ps(&src[x]); __m256 p1 = _mm256_load_ps(&src[x + w]); _mm256_store_ps(&ws[B * 0], p0); _mm256_store_ps(&ws[B * 1], _mm256_mul_ps(p1, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 2], _mm256_mul_ps(p0, _mm256_set1_ps(table[0]))); _mm256_store_ps(&ws[B * 3], _mm256_mul_ps(p1, _mm256_set1_ps(table[1]))); _mm256_store_ps(&ws[B * 4], _mm256_mul_ps(p0, _mm256_set1_ps(table[1]))); } //#pragma omp parallel for for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; __m256 sum0 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(0 - v)]), _mm256_load_ps(&src[x + w*(0 + v)])); __m256 sum1 = _mm256_add_ps(_mm256_load_ps(&src[x + w*atN(1 - v)]), _mm256_load_ps(&src[x + w*(1 + v)])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(_mm256_load_ps(&ws[B * 0]), sum0)); _mm256_store_ps(&ws[B * 1], _mm256_add_ps(_mm256_load_ps(&ws[B * 1]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 2], _mm256_add_ps(_mm256_load_ps(&ws[B * 2]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 0])))); _mm256_store_ps(&ws[B * 3], _mm256_add_ps(_mm256_load_ps(&ws[B * 3]), _mm256_mul_ps(sum1, _mm256_set1_ps(table[K*v + 1])))); _mm256_store_ps(&ws[B * 4], _mm256_add_ps(_mm256_load_ps(&ws[B * 4]), _mm256_mul_ps(sum0, _mm256_set1_ps(table[K*v + 1])))); } } const float cf11 = float(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const float cf12 = float(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution //#pragma omp parallel for for (int y = 0; y < 1; ++y) //the first line (y=0) { float* q = &dst[w*y]; const float* p1N = &src[w*atN(y - r)]; const float* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a2 = _mm256_load_ps(&ws[B * 2]); const __m256 a4 = _mm256_load_ps(&ws[B * 4]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a2, a4)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d0)); } } for (int y = 1; y < h; ++y) //the other lines { float* q = &dst[w*y]; const float* p0N = &src[w*atN(y - r - 1)]; const float* p1N = &src[w*atN(y - r)]; const float* p0S = &src[w*atS(y + r)]; const float* p1S = &src[w*atS(y + r + 1)]; //#pragma omp parallel for for (int x = 0; x < w / B*B; x += B) { float* ws = &workspace[(2 * K + 1)*x]; const __m256 a0 = _mm256_load_ps(&ws[B * 0]); const __m256 a1 = _mm256_load_ps(&ws[B * 1]); const __m256 a3 = _mm256_load_ps(&ws[B * 3]); _mm256_store_ps(&q[x], _mm256_mul_ps(_mm256_set1_ps(norm), _mm256_add_ps(a0, _mm256_add_ps(a1, a3)))); const __m256 d0 = _mm256_sub_ps(_mm256_load_ps(&p0S[x]), _mm256_load_ps(&p0N[x])); const __m256 d1 = _mm256_sub_ps(_mm256_load_ps(&p1S[x]), _mm256_load_ps(&p1N[x])); const __m256 delta1 = _mm256_sub_ps(d1, d0); _mm256_store_ps(&ws[B * 0], _mm256_add_ps(a0, d1)); _mm256_store_ps(&ws[B * 1], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR1), delta1), _mm256_mul_ps(_mm256_set1_ps(cf11), a1)), _mm256_load_ps(&ws[B * 2]))); _mm256_store_ps(&ws[B * 2], a1); _mm256_store_ps(&ws[B * 3], _mm256_sub_ps(_mm256_add_ps(_mm256_mul_ps(_mm256_set1_ps(cfR2), delta1), _mm256_mul_ps(_mm256_set1_ps(cf12), a3)), _mm256_load_ps(&ws[B * 4]))); _mm256_store_ps(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_h<double>(int w, int h, double* src, double* dst) { const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; double sum, a1, a2, b1, b2; double dA, dB, delta; std::vector<double> buf(w); //to allow for src==dst for (int y = 0; y < h; ++y) { std::copy(&src[w*y], &src[w*y + w], buf.begin()); sum = buf[0]; a1 = buf[0] * table[0]; b1 = buf[1] * table[0]; a2 = buf[0] * table[1]; b2 = buf[1] * table[1]; for (int u = 1; u <= r; ++u) { const double sumA = buf[atW(0 - u)] + buf[0 + u]; const double sumB = buf[atW(1 - u)] + buf[1 + u]; sum += sumA; a1 += sumA*table[K*u + 0]; b1 += sumB*table[K*u + 0]; a2 += sumA*table[K*u + 1]; b2 += sumB*table[K*u + 1]; } //the first pixel (x=0) double* q = &dst[w*y]; q[0] = norm*(sum + a1 + a2); dA = buf[atE(0 + r + 1)] - buf[atW(0 - r)]; sum += dA; //the other pixels (0<x<w) int x = 1; while (true) //four-length ring buffers { q[x] = norm*(sum + b1 + b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 + cfR1*delta; a2 += -cf12*b2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - a1 - a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 + cfR1*delta; b2 += +cf12*a2 + cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum - b1 - b2); dB = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dA - dB; sum += dB; a1 += -cf11*b1 - cfR1*delta; a2 += -cf12*b2 - cfR2*delta; x++; if (w <= x) break; q[x] = norm*(sum + a1 + a2); dA = buf[atE(x + r + 1)] - buf[atW(x - r)]; delta = dB - dA; sum += dA; b1 += +cf11*a1 - cfR1*delta; b2 += +cf12*a2 - cfR2*delta; x++; if (w <= x) break; } } } template<> inline void gauss::filter_v<double>(int w, int h, double* src, double* dst) { const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning std::vector<double> workspace((2 * K + 1)*w); //calculating the first and second terms for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; ws[0] = src[x]; ws[1] = src[x + w] * table[0]; ws[2] = src[x] * table[0]; ws[3] = src[x + w] * table[1]; ws[4] = src[x] * table[1]; } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w; ++x) { const double sum0 = src[x + w*atN(0 - v)] + src[x + w*(0 + v)]; const double sum1 = src[x + w*atN(1 - v)] + src[x + w*(1 + v)]; double* ws = &workspace[(2 * K + 1)*x]; ws[0] += sum0; ws[1] += sum1*table[K*v + 0]; ws[2] += sum0*table[K*v + 0]; ws[3] += sum1*table[K*v + 1]; ws[4] += sum0*table[K*v + 1]; } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; double *q, *p0N, *p0S, *p1N, *p1S; for (int y = 0; y < 1; ++y) //the first line (y=0) { q = &dst[w*y]; p1N = &src[w*atN(0 - r)]; p1S = &src[w*atS(0 + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); ws[0] += p1S[x] - p1N[x]; } } for (int y = 1; y < h; ++y) //remaining lines (with two-length ring buffers) { q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[1] + ws[3]); const double d0 = p0S[x] - p0N[x]; const double d1 = p1S[x] - p1N[x]; const double delta = d1 - d0; ws[0] += d1; ws[2] = cfR1*delta + cf11*ws[1] - ws[2]; ws[4] = cfR2*delta + cf12*ws[3] - ws[4]; } y++; if (h <= y) break; //to the next line q = &dst[w*y]; p0N = &src[w*atN(y - r - 1)]; p0S = &src[w*atS(y + r)]; p1N = &src[w*atN(y - r)]; p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w; ++x) { double* ws = &workspace[(2 * K + 1)*x]; q[x] = norm*(ws[0] + ws[2] + ws[4]); const double d0 = p0S[x] - p0N[x]; const double d1 = p1S[x] - p1N[x]; const double delta = d1 - d0; ws[0] += d1; ws[1] = cfR1*delta + cf11*ws[2] - ws[1]; ws[3] = cfR2*delta + cf12*ws[4] - ws[3]; } } } #define _MM_TRANSPOSE2_PD(row0, row1) { \ __m128d tmp1, tmp0; \ \ tmp0 = _mm_shuffle_pd(row0, row1, 0); \ tmp1 = _mm_shuffle_pd(row0, row1, 3); \ row0 = tmp0; \ row1 = tmp1; \ } template<> inline void gauss::filter_sse_h<double>(int w, int h, double* src, double* dst) { const int B = sizeof(__m128d) / sizeof(double); const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<double> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m128d pv0 = _mm_set_pd(buf[w * 1 + 0], buf[w * 0 + 0]); __m128d pv1 = _mm_set_pd(buf[w * 1 + 1], buf[w * 0 + 1]); __m128d sum = pv0; __m128d a1 = _mm_mul_pd(_mm_set1_pd(table[0]), pv0); __m128d b1 = _mm_mul_pd(_mm_set1_pd(table[0]), pv1); __m128d a2 = _mm_mul_pd(_mm_set1_pd(table[1]), pv0); __m128d b2 = _mm_mul_pd(_mm_set1_pd(table[1]), pv1); for (int u = 1; u <= r; ++u) { const double* p0M = &buf[atW(0 - u)]; const double* p1M = &buf[atW(1 - u)]; const double* p0P = &buf[(0 + u)]; const double* p1P = &buf[(1 + u)]; __m128d pv0M = _mm_set_pd(p0M[w * 1], p0M[w * 0]); __m128d pv1M = _mm_set_pd(p1M[w * 1], p1M[w * 0]); __m128d pv0P = _mm_set_pd(p0P[w * 1], p0P[w * 0]); __m128d pv1P = _mm_set_pd(p1P[w * 1], p1P[w * 0]); __m128d sumA = _mm_add_pd(pv0M, pv0P); __m128d sumB = _mm_add_pd(pv1M, pv1P); sum = _mm_add_pd(sum, sumA); a1 = _mm_add_pd(a1, _mm_mul_pd(_mm_set1_pd(table[K*u + 0]), sumA)); b1 = _mm_add_pd(b1, _mm_mul_pd(_mm_set1_pd(table[K*u + 0]), sumB)); a2 = _mm_add_pd(a2, _mm_mul_pd(_mm_set1_pd(table[K*u + 1]), sumA)); b2 = _mm_add_pd(b2, _mm_mul_pd(_mm_set1_pd(table[K*u + 1]), sumB)); } //sliding convolution double *pA, *pB; __m128d pvA, pvB; __m128d dvA, dvB, delta; __m128d qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvA = _mm_sub_pd(pvB, pvA); sum = _mm_add_pd(sum, dvA); //b1=_mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1),delta),_mm_mul_pd(_mm_set1_pd(cf11),a1)),b1); //b2=_mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2),delta),_mm_mul_pd(_mm_set1_pd(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvB = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvB, dvA); sum = _mm_add_pd(sum, dvB); a1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), b1)), a1); a2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE2_PD(qv[0], qv[1]); _mm_storeu_pd(&dst[w*(y + 0)], qv[0]); _mm_storeu_pd(&dst[w*(y + 1)], qv[1]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvA = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvA, dvB); sum = _mm_add_pd(sum, dvA); b1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), a1)), b1); b2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(sum, _mm_add_pd(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm_set_pd(pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm_set_pd(pB[w * 1], pB[w * 0]); dvB = _mm_sub_pd(pvB, pvA); delta = _mm_sub_pd(dvB, dvA); sum = _mm_add_pd(sum, dvB); a1 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), b1)), a1); a2 = _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), b2)), a2); //output with transposition _MM_TRANSPOSE2_PD(qv[0], qv[1]); _mm_storeu_pd(&dst[w*(y + 0) + x], qv[0]); _mm_storeu_pd(&dst[w*(y + 1) + x], qv[1]); } } } template<> inline void gauss::filter_sse_v<double>(int w, int h, double* src, double* dst) { assert(w % sizeof(__m128d) == 0); const int B = sizeof(__m128d) / sizeof(double); const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning double* workspace = reinterpret_cast<double*>(_mm_malloc(sizeof(double)*(2 * K + 1)*w, sizeof(__m128d))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m128d p0 = _mm_load_pd(&src[x]); __m128d p1 = _mm_load_pd(&src[x + w]); _mm_store_pd(&ws[B * 0], p0); _mm_store_pd(&ws[B * 1], _mm_mul_pd(p1, _mm_set1_pd(table[0]))); _mm_store_pd(&ws[B * 2], _mm_mul_pd(p0, _mm_set1_pd(table[0]))); _mm_store_pd(&ws[B * 3], _mm_mul_pd(p1, _mm_set1_pd(table[1]))); _mm_store_pd(&ws[B * 4], _mm_mul_pd(p0, _mm_set1_pd(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m128d sum0 = _mm_add_pd(_mm_load_pd(&src[x + w*atN(0 - v)]), _mm_load_pd(&src[x + w*(0 + v)])); __m128d sum1 = _mm_add_pd(_mm_load_pd(&src[x + w*atN(1 - v)]), _mm_load_pd(&src[x + w*(1 + v)])); _mm_store_pd(&ws[B * 0], _mm_add_pd(_mm_load_pd(&ws[B * 0]), sum0)); _mm_store_pd(&ws[B * 1], _mm_add_pd(_mm_load_pd(&ws[B * 1]), _mm_mul_pd(sum1, _mm_set1_pd(table[K*v + 0])))); _mm_store_pd(&ws[B * 2], _mm_add_pd(_mm_load_pd(&ws[B * 2]), _mm_mul_pd(sum0, _mm_set1_pd(table[K*v + 0])))); _mm_store_pd(&ws[B * 3], _mm_add_pd(_mm_load_pd(&ws[B * 3]), _mm_mul_pd(sum1, _mm_set1_pd(table[K*v + 1])))); _mm_store_pd(&ws[B * 4], _mm_add_pd(_mm_load_pd(&ws[B * 4]), _mm_mul_pd(sum0, _mm_set1_pd(table[K*v + 1])))); } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { double* q = &dst[w*y]; const double* p1N = &src[w*atN(y - r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m128d a0 = _mm_load_pd(&ws[B * 0]); const __m128d a2 = _mm_load_pd(&ws[B * 2]); const __m128d a4 = _mm_load_pd(&ws[B * 4]); _mm_store_pd(&q[x], _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(a0, _mm_add_pd(a2, a4)))); const __m128d d = _mm_sub_pd(_mm_load_pd(&p1S[x]), _mm_load_pd(&p1N[x])); _mm_store_pd(&ws[B * 0], _mm_add_pd(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { double* q = &dst[w*y]; const double* p0N = &src[w*atN(y - r - 1)]; const double* p1N = &src[w*atN(y - r)]; const double* p0S = &src[w*atS(y + r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m128d a0 = _mm_load_pd(&ws[B * 0]); const __m128d a1 = _mm_load_pd(&ws[B * 1]); const __m128d a3 = _mm_load_pd(&ws[B * 3]); _mm_store_pd(&q[x], _mm_mul_pd(_mm_set1_pd(norm), _mm_add_pd(a0, _mm_add_pd(a1, a3)))); const __m128d d0 = _mm_sub_pd(_mm_load_pd(&p0S[x]), _mm_load_pd(&p0N[x])); const __m128d d1 = _mm_sub_pd(_mm_load_pd(&p1S[x]), _mm_load_pd(&p1N[x])); const __m128d delta = _mm_sub_pd(d1, d0); _mm_store_pd(&ws[B * 0], _mm_add_pd(a0, d1)); _mm_store_pd(&ws[B * 1], _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR1), delta), _mm_mul_pd(_mm_set1_pd(cf11), a1)), _mm_load_pd(&ws[B * 2]))); _mm_store_pd(&ws[B * 2], a1); _mm_store_pd(&ws[B * 3], _mm_sub_pd(_mm_add_pd(_mm_mul_pd(_mm_set1_pd(cfR2), delta), _mm_mul_pd(_mm_set1_pd(cf12), a3)), _mm_load_pd(&ws[B * 4]))); _mm_store_pd(&ws[B * 4], a3); } } _mm_free(workspace); } template<> inline void gauss::filter_avx_h<double>(int w, int h, double* src, double* dst) { const int B = sizeof(__m256d) / sizeof(double); const int r = rx; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableX.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableX[t]); const double cf11 = double(table[K * 1 + 0] * 2.0 / spectX[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectX[1]), cfR2 = table[K*r + 1]; //to allow for src==dst std::vector<double> buf(B*w); assert(h%B == 0); for (int y = 0; y < h / B*B; y += B) { std::copy(&src[w*y], &src[w*(y + B)], buf.begin()); __m256d pv0 = _mm256_set_pd(buf[w * 3 + 0], buf[w * 2 + 0], buf[w * 1 + 0], buf[w * 0 + 0]); __m256d pv1 = _mm256_set_pd(buf[w * 3 + 1], buf[w * 2 + 1], buf[w * 1 + 1], buf[w * 0 + 1]); __m256d sum = pv0; __m256d a1 = _mm256_mul_pd(_mm256_set1_pd(table[0]), pv0); __m256d b1 = _mm256_mul_pd(_mm256_set1_pd(table[0]), pv1); __m256d a2 = _mm256_mul_pd(_mm256_set1_pd(table[1]), pv0); __m256d b2 = _mm256_mul_pd(_mm256_set1_pd(table[1]), pv1); for (int u = 1; u <= r; ++u) { const double* p0M = &buf[atW(0 - u)]; const double* p1M = &buf[atW(1 - u)]; const double* p0P = &buf[(0 + u)]; const double* p1P = &buf[(1 + u)]; __m256d pv0M = _mm256_set_pd(p0M[w * 3], p0M[w * 2], p0M[w * 1], p0M[w * 0]); __m256d pv1M = _mm256_set_pd(p1M[w * 3], p1M[w * 2], p1M[w * 1], p1M[w * 0]); __m256d pv0P = _mm256_set_pd(p0P[w * 3], p0P[w * 2], p0P[w * 1], p0P[w * 0]); __m256d pv1P = _mm256_set_pd(p1P[w * 3], p1P[w * 2], p1P[w * 1], p1P[w * 0]); __m256d sumA = _mm256_add_pd(pv0M, pv0P); __m256d sumB = _mm256_add_pd(pv1M, pv1P); sum = _mm256_add_pd(sum, sumA); a1 = _mm256_add_pd(a1, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 0]), sumA)); b1 = _mm256_add_pd(b1, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 0]), sumB)); a2 = _mm256_add_pd(a2, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 1]), sumA)); b2 = _mm256_add_pd(b2, _mm256_mul_pd(_mm256_set1_pd(table[K*u + 1]), sumB)); } //sliding convolution double *pA, *pB; __m256d pvA, pvB; __m256d dvA, dvB, delta; __m256d qv[B]; //the first four pixels (0<=x<B) for (int x = 0; x < B; x += B) { //the first pixel (x=0) qv[0] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(0 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(0 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); sum = _mm256_add_pd(sum, dvA); //b1=_mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1),delta),_mm256_mul_pd(_mm256_set1_pd(cf11),a1)),b1); //b2=_mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2),delta),_mm256_mul_pd(_mm256_set1_pd(cf12),a2)),b2); //the second pixel (x=1) qv[1] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(1 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(1 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(2 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(2 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(3 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[(3 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE4_PD(qv[0], qv[1], qv[2], qv[3]); _mm256_storeu_pd(&dst[w*(y + 0)], qv[0]); _mm256_storeu_pd(&dst[w*(y + 1)], qv[1]); _mm256_storeu_pd(&dst[w*(y + 2)], qv[2]); _mm256_storeu_pd(&dst[w*(y + 3)], qv[3]); } //the other pixels (B<=x<w) for (int x = B; x < w / B*B; x += B) //four-length ring buffers { //the first pixel (x=0) qv[0] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(x + 0 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 0 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the second pixel (x=1) qv[1] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(x + 1 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 1 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //the third pixel (x=2) qv[2] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(a1, a2))); pA = &buf[atW(x + 2 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 2 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvA = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvA, dvB); sum = _mm256_add_pd(sum, dvA); b1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), b1); b2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a2)), b2); //the forth pixel (x=3) qv[3] = _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(sum, _mm256_add_pd(b1, b2))); pA = &buf[atW(x + 3 - r)]; pvA = _mm256_set_pd(pA[w * 3], pA[w * 2], pA[w * 1], pA[w * 0]); pB = &buf[atE(x + 3 + r + 1)]; pvB = _mm256_set_pd(pB[w * 3], pB[w * 2], pB[w * 1], pB[w * 0]); dvB = _mm256_sub_pd(pvB, pvA); delta = _mm256_sub_pd(dvB, dvA); sum = _mm256_add_pd(sum, dvB); a1 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), b1)), a1); a2 = _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), b2)), a2); //output with transposition _MM256_TRANSPOSE4_PD(qv[0], qv[1], qv[2], qv[3]); _mm256_storeu_pd(&dst[w*(y + 0) + x], qv[0]); _mm256_storeu_pd(&dst[w*(y + 1) + x], qv[1]); _mm256_storeu_pd(&dst[w*(y + 2) + x], qv[2]); _mm256_storeu_pd(&dst[w*(y + 3) + x], qv[3]); } } } template<> inline void gauss::filter_avx_v<double>(int w, int h, double* src, double* dst) { assert(w % sizeof(__m256d) == 0); const int B = sizeof(__m256d) / sizeof(double); const int r = ry; const double norm = double(1.0 / (r + 1 + r)); std::vector<double> table(tableY.size()); for (int t = 0; t<int(table.size()); ++t) table[t] = double(tableY[t]); //work space to keep raster scanning double* workspace = reinterpret_cast<double*>(_mm_malloc(sizeof(double)*(2 * K + 1)*w, sizeof(__m256d))); //calculating the first and second terms for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m256d p0 = _mm256_load_pd(&src[x]); __m256d p1 = _mm256_load_pd(&src[x + w]); _mm256_store_pd(&ws[B * 0], p0); _mm256_store_pd(&ws[B * 1], _mm256_mul_pd(p1, _mm256_set1_pd(table[0]))); _mm256_store_pd(&ws[B * 2], _mm256_mul_pd(p0, _mm256_set1_pd(table[0]))); _mm256_store_pd(&ws[B * 3], _mm256_mul_pd(p1, _mm256_set1_pd(table[1]))); _mm256_store_pd(&ws[B * 4], _mm256_mul_pd(p0, _mm256_set1_pd(table[1]))); } for (int v = 1; v <= r; ++v) { for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; __m256d sum0 = _mm256_add_pd(_mm256_load_pd(&src[x + w*atN(0 - v)]), _mm256_load_pd(&src[x + w*(0 + v)])); __m256d sum1 = _mm256_add_pd(_mm256_load_pd(&src[x + w*atN(1 - v)]), _mm256_load_pd(&src[x + w*(1 + v)])); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(_mm256_load_pd(&ws[B * 0]), sum0)); _mm256_store_pd(&ws[B * 1], _mm256_add_pd(_mm256_load_pd(&ws[B * 1]), _mm256_mul_pd(sum1, _mm256_set1_pd(table[K*v + 0])))); _mm256_store_pd(&ws[B * 2], _mm256_add_pd(_mm256_load_pd(&ws[B * 2]), _mm256_mul_pd(sum0, _mm256_set1_pd(table[K*v + 0])))); _mm256_store_pd(&ws[B * 3], _mm256_add_pd(_mm256_load_pd(&ws[B * 3]), _mm256_mul_pd(sum1, _mm256_set1_pd(table[K*v + 1])))); _mm256_store_pd(&ws[B * 4], _mm256_add_pd(_mm256_load_pd(&ws[B * 4]), _mm256_mul_pd(sum0, _mm256_set1_pd(table[K*v + 1])))); } } const double cf11 = double(table[K * 1 + 0] * 2.0 / spectY[0]), cfR1 = table[K*r + 0]; const double cf12 = double(table[K * 1 + 1] * 2.0 / spectY[1]), cfR2 = table[K*r + 1]; //sliding convolution for (int y = 0; y < 1; ++y) //the first line (y=0) { double* q = &dst[w*y]; const double* p1N = &src[w*atN(y - r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m256d a0 = _mm256_load_pd(&ws[B * 0]); const __m256d a2 = _mm256_load_pd(&ws[B * 2]); const __m256d a4 = _mm256_load_pd(&ws[B * 4]); _mm256_store_pd(&q[x], _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(a0, _mm256_add_pd(a2, a4)))); const __m256d d = _mm256_sub_pd(_mm256_load_pd(&p1S[x]), _mm256_load_pd(&p1N[x])); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(a0, d)); } } for (int y = 1; y < h; ++y) //the other lines { double* q = &dst[w*y]; const double* p0N = &src[w*atN(y - r - 1)]; const double* p1N = &src[w*atN(y - r)]; const double* p0S = &src[w*atS(y + r)]; const double* p1S = &src[w*atS(y + r + 1)]; for (int x = 0; x < w / B*B; x += B) { double* ws = &workspace[(2 * K + 1)*x]; const __m256d a0 = _mm256_load_pd(&ws[B * 0]); const __m256d a1 = _mm256_load_pd(&ws[B * 1]); const __m256d a3 = _mm256_load_pd(&ws[B * 3]); _mm256_store_pd(&q[x], _mm256_mul_pd(_mm256_set1_pd(norm), _mm256_add_pd(a0, _mm256_add_pd(a1, a3)))); const __m256d d0 = _mm256_sub_pd(_mm256_load_pd(&p0S[x]), _mm256_load_pd(&p0N[x])); const __m256d d1 = _mm256_sub_pd(_mm256_load_pd(&p1S[x]), _mm256_load_pd(&p1N[x])); const __m256d delta = _mm256_sub_pd(d1, d0); _mm256_store_pd(&ws[B * 0], _mm256_add_pd(a0, d1)); _mm256_store_pd(&ws[B * 1], _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR1), delta), _mm256_mul_pd(_mm256_set1_pd(cf11), a1)), _mm256_load_pd(&ws[B * 2]))); _mm256_store_pd(&ws[B * 2], a1); _mm256_store_pd(&ws[B * 3], _mm256_sub_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(cfR2), delta), _mm256_mul_pd(_mm256_set1_pd(cf12), a3)), _mm256_load_pd(&ws[B * 4]))); _mm256_store_pd(&ws[B * 4], a3); } } _mm_free(workspace); } } void GaussianBlurSR_cliped_32F(InputArray src_, OutputArray dest, float sigma) { Mat src = src_.getMat(); if (dest.empty())dest.create(src_.size(), src.type()); Mat dst = dest.getMat(); if (src.channels() == 1) { spectral_recursive_filter::gauss srf_gauss(sigma, sigma); if (src.data != dst.data) { srf_gauss.filter(src, dst); } else { Mat a(src.size(), src.type()); srf_gauss.filter(src, a); a.copyTo(dst); } } else if (src.channels() == 3) { vector<Mat> plane; split(src, plane); Mat temp(src.size(), CV_32F); spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(plane[0], temp); temp.copyTo(plane[0]); srf_gauss.filter(plane[1], temp); temp.copyTo(plane[1]); srf_gauss.filter(plane[2], temp); temp.copyTo(plane[2]); merge(plane, dest); } } void GaussianBlurSR_cliped_64F(InputArray src_, OutputArray dest, double sigma) { Mat src = src_.getMat(); Mat srcf2(src.size(), CV_64FC(src.channels())); if (src.channels() == 1) { spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(src, srcf2); } else if (src.channels() == 3) { vector<Mat> plane; split(src, plane); Mat temp(src.size(), CV_64F); spectral_recursive_filter::gauss srf_gauss(sigma, sigma); srf_gauss.filter(plane[0], temp); temp.copyTo(plane[0]); srf_gauss.filter(plane[1], temp); temp.copyTo(plane[1]); srf_gauss.filter(plane[2], temp); temp.copyTo(plane[2]); merge(plane, srcf2); } if (dest.empty()) srcf2.copyTo(dest); else if (dest.depth() != CV_64F) srcf2.convertTo(dest, CV_64F); else srcf2.copyTo(dest); } void GaussianBlurSR(InputArray src, OutputArray dest, const double sigma) { int SIMDSTEP = 4; if (src.depth() == CV_64F) SIMDSTEP = 2; int xpad = src.size().width%SIMDSTEP; int ypad = src.size().height%SIMDSTEP; xpad = (SIMDSTEP - xpad) % SIMDSTEP; ypad = (SIMDSTEP - ypad) % SIMDSTEP; if (xpad == 0 && ypad == 0) { if (src.depth() == CV_64F) { GaussianBlurSR_cliped_64F(src, dest, sigma); } else if (src.depth() == CV_32F) { GaussianBlurSR_cliped_32F(src, dest, (float)sigma); } else { Mat srcf, destf; src.getMat().convertTo(srcf, CV_32F); GaussianBlurSR_cliped_32F(srcf, destf, (float)sigma); destf.convertTo(dest, src.depth(), 1.0, 0.5); } } else { Mat s, d; copyMakeBorder(src, s, 0, ypad, 0, xpad, BORDER_REFLECT); if (src.depth() == CV_64F) { GaussianBlurSR_cliped_64F(s, d, sigma); } else if (src.depth() == CV_32F) { GaussianBlurSR_cliped_32F(s, d, (float)sigma); } else { Mat srcf, destf; s.convertTo(srcf, CV_32F); GaussianBlurSR_cliped_32F(srcf, destf, (float)sigma); destf.convertTo(d, src.depth(), 1.0, 0.5); } Mat(d(Rect(Point(0, 0), src.size()))).copyTo(dest); } }
43.750223
376
0.592692
norishigefukushima
5ea5c38a54bbddb0af567a118f6fd080996075ed
2,678
hpp
C++
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
null
null
null
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
1
2018-06-09T04:40:01.000Z
2018-06-09T04:40:01.000Z
include/tnt/deps/simd/detail/preprocessor/facilities/is_empty.hpp
JordanCheney/tnt
a0fd378079d36b2bd39960c34e5c83f9633db0c0
[ "MIT" ]
null
null
null
# /* ************************************************************************** # * * # * (C) Copyright Paul Mensonides 2003. # * (C) Copyright Edward Diener 2014. # * Distributed under the Boost Software License, Version 1.0. (See # * accompanying file LICENSE_1_0.txt or copy at # * http://www.boost.org/LICENSE_1_0.txt) # * * # ************************************************************************** */ # # /* See http://www.boost.org for most recent version. */ # # ifndef SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP # define SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP # #include <tnt/deps/simd/detail/preprocessor/config/config.hpp> # # if SIMDPP_PP_VARIADICS # #include <tnt/deps/simd/detail/preprocessor/facilities/is_empty_variadic.hpp> # # else # # if ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() && ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MWCC() #include <tnt/deps/simd/detail/preprocessor/tuple/elem.hpp> #include <tnt/deps/simd/detail/preprocessor/facilities/identity.hpp> # else #include <tnt/deps/simd/detail/preprocessor/cat.hpp> #include <tnt/deps/simd/detail/preprocessor/detail/split.hpp> # endif # # /* SIMDPP_PP_IS_EMPTY */ # # if ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() && ~SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MWCC() # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I(x SIMDPP_PP_IS_EMPTY_HELPER) # define SIMDPP_PP_IS_EMPTY_I(contents) SIMDPP_PP_TUPLE_ELEM(2, 1, (SIMDPP_PP_IS_EMPTY_DEF_ ## contents())) # define SIMDPP_PP_IS_EMPTY_DEF_SIMDPP_PP_IS_EMPTY_HELPER 1, SIMDPP_PP_IDENTITY(1) # define SIMDPP_PP_IS_EMPTY_HELPER() , 0 # else # if SIMDPP_PP_CONFIG_FLAGS() & SIMDPP_PP_CONFIG_MSVC() # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I(SIMDPP_PP_IS_EMPTY_HELPER x ()) # define SIMDPP_PP_IS_EMPTY_I(test) SIMDPP_PP_IS_EMPTY_II(SIMDPP_PP_SPLIT(0, SIMDPP_PP_CAT(SIMDPP_PP_IS_EMPTY_DEF_, test))) # define SIMDPP_PP_IS_EMPTY_II(id) id # else # define SIMDPP_PP_IS_EMPTY(x) SIMDPP_PP_IS_EMPTY_I((SIMDPP_PP_IS_EMPTY_HELPER x ())) # define SIMDPP_PP_IS_EMPTY_I(par) SIMDPP_PP_IS_EMPTY_II ## par # define SIMDPP_PP_IS_EMPTY_II(test) SIMDPP_PP_SPLIT(0, SIMDPP_PP_CAT(SIMDPP_PP_IS_EMPTY_DEF_, test)) # endif # define SIMDPP_PP_IS_EMPTY_HELPER() 1 # define SIMDPP_PP_IS_EMPTY_DEF_1 1, SIMDPP_PP_NIL # define SIMDPP_PP_IS_EMPTY_DEF_SIMDPP_PP_IS_EMPTY_HELPER 0, SIMDPP_PP_NIL # endif # # endif /* SIMDPP_PP_VARIADICS */ # # endif /* SIMDPP_PREPROCESSOR_FACILITIES_IS_EMPTY_HPP */
46.982456
130
0.676998
JordanCheney
5eaaa8feb9f470edc8ae8aa3a1ae75043b27c7a6
2,996
cpp
C++
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
MyGame/Motor2D/j1EntityManager.cpp
AlexisCosano/DevCodex
32891063f5c4d7b766a517415c749d222649e070
[ "MIT" ]
null
null
null
#include "j1EntityManager.h" #include "j1App.h" #include "p2Defs.h" #include "p2Log.h" #include "j1Player.h" #include "j1GroundedEnemy.h" #include "j1FlyingEnemy.h" j1EntityManager::j1EntityManager() : j1Module() { name = "entities"; } j1EntityManager::~j1EntityManager() { } bool j1EntityManager::Awake(pugi::xml_node& module_node) { this->module_node = module_node; bool ret = true; return ret; } bool j1EntityManager::Start() { bool ret = true; return ret; } bool j1EntityManager::PreUpdate() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->PreUpdate(); item = item->next; } return ret; } bool j1EntityManager::Update(float dt) { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && item->data != NULL && ret == true) { ret = item->data->Update(dt); item = item->next; } item = entities.start; while (item != NULL && ret == true) { ret = item->data->Draw(dt); item = item->next; } return ret; } bool j1EntityManager::PostUpdate() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->PostUpdate(); item = item->next; } return ret; } bool j1EntityManager::CleanUp() { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL) { ret = item->data->CleanUp(); RELEASE(item->data); item = item->next; } entities.clear(); return ret; } void j1EntityManager::ResetEntities() { p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL) { item->data->Reset(); item = item->next; } } bool j1EntityManager::Load(pugi::xml_node& module_node) { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->Load(module_node); item = item->next; } return ret; } bool j1EntityManager::Save(pugi::xml_node& module_node) const { bool ret = true; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == true) { ret = item->data->Save(module_node); item = item->next; } return ret; } j1Entity * j1EntityManager::CreateEntity(Type type) { j1Entity* ret = nullptr; switch (type) { case PLAYER: ret = new j1Player(); break; case GROUNDED_ENEMY: ret = new j1GroundedEnemy(); break; case FLYING_ENEMY: ret = new j1FlyingEnemy(); break; } ret->type = type; ret->Awake(module_node.child(ret->TypeToString().GetString())); ret->Start(); if (ret != nullptr) entities.add(ret); return ret; } bool j1EntityManager::DestroyEntity(j1Entity * entity) { bool ret = false; p2List_item<j1Entity*>* item; item = entities.start; while (item != NULL && ret == false) { if(item->data == entity) { ret = item->data->CleanUp(); RELEASE(item->data); entities.del(item); return ret; } item = item->next; } return ret; }
15.604167
64
0.648198
AlexisCosano
5eaee45bf8f9a844bccaf9f28099a4db7aa6b6fe
250
hpp
C++
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
src/common/thread_compat.hpp
Helios-vmg/napalm
15f61c742a4488304583865f35cb286e777112fe
[ "BSD-2-Clause" ]
null
null
null
#pragma once #if defined __MINGW32__ && !(defined _GLIBCXX_HAS_GTHREADS) #include <mingw.thread.h> #include <mingw.mutex.h> #include <mingw.condition_variable.h> #else #include <thread> #include <mutex> #include <condition_variable> #endif
22.727273
60
0.74
Helios-vmg
5eb7e84f957c3891ba0d0b57500ab7dc3b2431d7
10,096
cpp
C++
external/the-forge/Middleware_3/UI/imgui_user.cpp
learn-computer-graphics/the-forge-samples
36ee5310bf76271bf41186475c433cf050ab32af
[ "Apache-2.0" ]
18
2020-05-05T18:11:59.000Z
2021-12-16T07:07:46.000Z
external/the-forge/Middleware_3/UI/imgui_user.cpp
boberfly/the-forge-glfw
c3b4642f83bec165af481e8a7d6916330d4bd07b
[ "Apache-2.0" ]
null
null
null
external/the-forge/Middleware_3/UI/imgui_user.cpp
boberfly/the-forge-glfw
c3b4642f83bec165af481e8a7d6916330d4bd07b
[ "Apache-2.0" ]
6
2020-05-23T21:42:12.000Z
2021-08-09T13:44:02.000Z
/* * Copyright (c) 2018-2021 The Forge Interactive Inc. * * This file is part of The-Forge * (see https://github.com/ConfettiFX/The-Forge). * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include "imgui_user.h" #include "../../Common_3/ThirdParty/OpenSource/imgui/imgui_internal.h" #ifndef M_PI #define M_PI 3.14159f #endif namespace ImGui { int KnobFloat( const char* label, float* value_p, const float& step, const float& minv, const float& maxv, const char* format, const float& minimumHitRadius, bool doubleTapForText, bool spawnText) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return 0; ImGuiContext& g = *GImGui; const ImGuiStyle& style = g.Style; const ImGuiID id = window->GetID(label); float size = CalcItemWidth(); float2 extraPadding = style.ItemSpacing + style.ItemInnerSpacing; //extraPadding.y = 0.f; float line_height = ImGui::GetTextLineHeight(); //extraPadding *= 2.f; float2 label_size = CalcTextSize(label, NULL, true); label_size.y = fmaxf(label_size.y, 0.f) + line_height; ImRect total_bb(window->DC.CursorPos, window->DC.CursorPos + float2(size, size + label_size.y / 2.f) + extraPadding); float knobRadius = size * 0.5f; float2 startPos = window->DC.CursorPos; float2 center = total_bb.GetCenter(); const ImRect inner_bb(center - float2(knobRadius, knobRadius), center + float2(knobRadius, knobRadius)); //bool hovered, held; //Create Invisible button and check if its active/hovered float2 mousePos = ImGui::GetIO().MousePos; // Tabbing or CTRL-clicking on Drag turns it into an input box bool start_text_input = false; bool hovered = ItemHoverable(inner_bb, id); const bool tab_focus_requested = FocusableItemRegister(window, id); if (doubleTapForText && (tab_focus_requested || (hovered && (g.IO.MouseClicked[0] || g.IO.MouseDoubleClicked[0])) || g.NavActivateId == id || (g.NavInputId == id && g.ScalarAsInputTextId != id))) { SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); g.ActiveIdAllowNavDirFlags = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); if (tab_focus_requested || g.IO.KeyCtrl || g.IO.MouseDoubleClicked[0] || g.NavInputId == id) { start_text_input = true; g.ScalarAsInputTextId = 0; } } bool using_text_input = false; if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id)) { if (spawnText) { int retValue = (int)InputScalarAsWidgetReplacement(inner_bb, id, label, ImGuiDataType_Float, value_p, format); ImDrawList* draw_list = ImGui::GetWindowDrawList(); // Bottom Label (X, Y, Z, W) Goes Below Knob label_size = CalcTextSize(label, NULL, true); uint32_t col32text = ImGui::GetColorU32(ImGuiCol_Text); float2 textpos = center + float2(-label_size.x / 2.f, inner_bb.GetHeight() / 2.f + label_size.y / 2.f); draw_list->AddText(textpos, col32text, label); // if max and min are not equal only then we apply the limits // to the final value if (!(fabs(maxv - minv) <= ((fabs(maxv) < fabs(minv) ? fabs(minv) : fabs(maxv)) * 0.01f))) { value_p[0] = fmaxf(minv, fminf(value_p[0], maxv)); } return retValue; } else //Return value to indicate if text was requested using_text_input = true; } //Create Invisible button and check if its active/hovered ImGui::InvisibleButton(label, total_bb.GetSize()); bool isActive = ImGui::IsItemActive(); bool updatedKnob = false; float currentAngle = 0.f; // Mouse delta movement since last frame float2 mouseDelta = ImGui::GetIO().MouseDelta; // Previous Mouse position float2 mousePrevPos = mousePos - mouseDelta; // Vector from center of knob to previous mouse position float2 mousePrevToKnob = mousePrevPos - center; // Get the length float lengthPrev = sqrtf(mousePrevToKnob.x * mousePrevToKnob.x + mousePrevToKnob.y * mousePrevToKnob.y); // Get Vector from center of knob to current mouse position float2 mouseToKnob = mousePos - center; // Get the length float lengthCurr = sqrtf(mouseToKnob.x * mouseToKnob.x + mouseToKnob.y * mouseToKnob.y); if (lengthCurr > knobRadius && g.ActiveId != id) isActive = false; const float hitRadius = minimumHitRadius * knobRadius; if (isActive && g.ActiveIdPreviousFrame == id) { // sanity check in case user clicks on center of knob. // wait for 3 frames before activating the knob const float delay = ((1.f / g.IO.Framerate) * 3.f); if (lengthPrev > 0.001f && lengthCurr > hitRadius && g.ActiveIdTimer > delay) { //Normalize our vectors mousePrevToKnob /= lengthPrev; mouseToKnob /= lengthCurr; // Function returns true if we have modified a value, not just activated it. updatedKnob = true; // dot product between[x1, y1] and [x2, y2] float dot = mouseToKnob.x * mousePrevToKnob.x + mouseToKnob.y * mousePrevToKnob.y; // determinant float det = mouseToKnob.x * mousePrevToKnob.y - mouseToKnob.y * mousePrevToKnob.x; // Get the new angle to add. Needs to be in degrees float deltaAngle = atan2f(det, dot) * 180.f / M_PI; // Increment current value value_p[0] += deltaAngle * step / fmaxf(1.f, lengthCurr / knobRadius); // if max and min are not equal only then we apply the limits // to the final value if (!(fabs(maxv - minv) <= ((fabs(maxv) < fabs(minv) ? fabs(minv) : fabs(maxv)) * 0.01f))) { value_p[0] = fmaxf(minv, fminf(value_p[0], maxv)); } float lineAngle = atan2f(mouseToKnob.y, mouseToKnob.x) - M_PI / 2.0f; // TODO: Add magnitude to increase step. (Multiples of initial length) currentAngle = lineAngle; } } // Display current value (Final value after knob increments) char textval[32]; ImFormatString(textval, IM_ARRAYSIZE(textval), format, value_p[0]); uint32_t col32 = ImGui::GetColorU32(isActive ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); uint32_t col32line = ImGui::GetColorU32(ImGuiCol_SliderGrabActive); ImDrawList* draw_list = ImGui::GetWindowDrawList(); // Enable to draw debug rectangles to view the frames being used // [DEBUGGING] //draw_list->AddRect(total_bb.Min, total_bb.Max, ImColor(0.0f, 1.0f, 0.0f, 1.0f)); //draw_list->AddRect(inner_bb.Min, inner_bb.Max, ImColor(0.0f, 0.0f, 1.0f, 1.0f)); // Draw knob as Filled circle // We could add textures to it in the future. draw_list->AddCircleFilled(center, knobRadius, col32, 32); // Cover the part that can't be dragged // i.e: Create hole in center if (hitRadius > 0.f) draw_list->AddCircleFilled(center, hitRadius, ImGui::GetColorU32(ImGuiCol_WindowBg), 32); // Add line from center of knob to edge of circle along mouse direction float x2 = -sinf(currentAngle) * knobRadius + center.x; float y2 = cosf(currentAngle) * knobRadius + center.y; draw_list->AddLine(center, float2(x2, y2), col32line, 1); // Current Value of Widget (Above Knob) label_size = CalcTextSize(textval, NULL, true); float2 textpos = center - float2(label_size.x / 2.f, total_bb.GetHeight() / 2.f); RenderText(textpos, textval); // Bottom Label (X, Y, Z, W) Goes Below Knob label_size = CalcTextSize(label, NULL, true); textpos = center + float2(-label_size.x / 2.f, inner_bb.GetHeight() / 2.f); RenderText(textpos, label); if (using_text_input) return 2; return (int)updatedKnob; } int KnobFloatN( const char* label, float* value_p, const int& components, const float& step, const float& minv, const float& maxv, const char* format, const float& minimumHitRadius, float windowWidthRatio, bool doubleTapForText, bool spawnText, float framePaddingScale) { ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; int value_changed = 0; // Print label of widget TextUnformatted(label, FindRenderedTextEnd(label)); // Start group. if app calls IsItemActive, then this enables all the elements created to affect the state of widget. BeginGroup(); // Looks better with some padding before titles such as "Translation, Rotation, Scale" PushID(label); //Controls how much padding for start of knobs framePaddingScale = fmaxf(framePaddingScale, 1.0f); float extraFramePadding = GetStyle().FramePadding.x * framePaddingScale; float itemSpacing = GetStyle().ItemSpacing.x * 3; // Scale the content based on how much of the width we would like to fill float contentWidth = window->Size.x - GetStyle().FrameBorderSize - GetStyle().ScrollbarSize - itemSpacing - extraFramePadding; // Compute final size multipler > 0 to avoid undefined behavior windowWidthRatio = fmaxf(windowWidthRatio, 0.05f); PushMultiItemsWidths(components, contentWidth * windowWidthRatio); size_t type_size = sizeof(float); SetCursorPosX(extraFramePadding); // 4 Component names, this could probably be given as an extra paramater with some helper functions for defaults. const char* componentNames[4]{ "x", "y", "z", "w" }; for (int i = 0; i < components; i++) { PushID(i); int currValue = KnobFloat(componentNames[i % 4], value_p, step, minv, maxv, format, minimumHitRadius, doubleTapForText, spawnText); if (value_changed == 0) value_changed = currValue > 1 ? currValue + i : currValue; SameLine(0, itemSpacing); PopID(); PopItemWidth(); // update user provided float value value_p = (float*)((char*)value_p + type_size); } PopID(); EndGroup(); return value_changed; } } // namespace ImGui
37.117647
135
0.716918
learn-computer-graphics
5eb8ccc8ab15da553c58a923713aaf6571c993a1
537
cpp
C++
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
sursa.cpp
seerj30/grafuri_ROYWARSHALL
559c2dcc9c9d30778d4be21b3513da5c9aa374e8
[ "MIT" ]
null
null
null
#include<iostream> #include<fstream> using namespace std; int n,a[50][50]; void citire() { int x,y; ifstream f("in.txt"); f>>n; while(f>>x>>y) a[x][y]=a[y][x]=1; } void afisare() { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) cout<<a[i][j]<<" "; cout<<endl; } cout<<endl; } void Roy_Warshall() { int i,j,k; for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j++) if(i!=j && a[i][j]==0 && a[i][k] && a[k][j]) a[i][j]=1; } int main() { citire(); afisare(); Roy_Warshall(); afisare(); return 0; }
11.933333
48
0.495345
seerj30
5ebddd06b54e498a0d17c1fb3c4fecf080b7b8cf
1,266
cpp
C++
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
mpags-cipher.git/MPAGSCipher/TransformChar.cpp
MPAGS-CPP-2019/mpags-day-2-GluonicPenguin
4a548ed268b16ef085abd75ba6cfd90263bd8b99
[ "MIT" ]
null
null
null
// TransformChar.cpp file, carrying function in separate file #include<cctype> #include<string> #include<iostream> // Function to transform characters to string std::string transformChar(const char inputChar){ std::string inputStrForm {""}; // Uppercase alphabetic characters if (std::isalpha(inputChar)) { inputStrForm += std::toupper(inputChar); return inputStrForm; } // Transliterate digits to English words switch (inputChar) { case '0': inputStrForm += "ZERO"; break; case '1': inputStrForm += "ONE"; break; case '2': inputStrForm += "TWO"; break; case '3': inputStrForm += "THREE"; break; case '4': inputStrForm += "FOUR"; break; case '5': inputStrForm += "FIVE"; break; case '6': inputStrForm += "SIX"; break; case '7': inputStrForm += "SEVEN"; break; case '8': inputStrForm += "EIGHT"; break; case '9': inputStrForm += "NINE"; break; } // If the character isn't alphabetic or numeric, DONT add it. // Our ciphers can only operate on alphabetic characters. return inputStrForm; }
23.018182
65
0.557662
MPAGS-CPP-2019
5ecbe055c8193a4eb162ff73366ebda544f09e10
6,010
cpp
C++
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
20
2016-02-15T23:22:06.000Z
2021-12-07T00:13:49.000Z
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
1
2017-09-04T00:28:19.000Z
2017-09-05T11:00:12.000Z
src/Pyros3D/Utils/Mouse3D/Mouse3D.cpp
Peixinho/Pyros3D
d6857ce99f3731a851ca5e7d67afbb13aafd18e0
[ "MIT" ]
3
2016-08-10T02:44:08.000Z
2021-05-28T23:03:10.000Z
//============================================================================ // Name : Mouse3D.cpp // Author : Duarte Peixinho // Version : // Copyright : ;) // Description : Mouse 3D Class //============================================================================ #include <Pyros3D/Utils/Mouse3D/Mouse3D.h> #include <stdio.h> #include <string.h> namespace p3d { Mouse3D::Mouse3D() { } Mouse3D::~Mouse3D() { } const Vec3 &Mouse3D::GetDirection() const { return Direction; } const Vec3 &Mouse3D::GetOrigin() const { return Origin; } bool Mouse3D::GenerateRay(const f32 windowWidth, const f32 windowHeight, const f32 mouseX, const f32 mouseY, const Matrix &Model, const Matrix &View, const Matrix &Projection) { f32 glMouseY = windowHeight - mouseY; int32 viewPort[4]; f32 x1, y1, z1, x2, y2, z2; viewPort[0] = 0; viewPort[1] = 0; viewPort[2] = (int32)windowWidth; viewPort[3] = (int32)windowHeight; Vec3 v1, v2; if (UnProject(mouseX, glMouseY, 0.f, (View*Model), Projection, Vec4((f32)viewPort[0], (f32)viewPort[1], (f32)viewPort[2], (f32)viewPort[3]), &x1, &y1, &z1) == true && UnProject(mouseX, glMouseY, 1.f, (View*Model), Projection, Vec4((f32)viewPort[0], (f32)viewPort[1], (f32)viewPort[2], (f32)viewPort[3]), &x2, &y2, &z2) == true) { v1.x = x1; v1.y = y1; v1.z = z1; v2.x = x2; v2.y = y2; v2.z = z2; v2 = v2 - v1; v2.normalizeSelf(); Origin = v1; Direction = v2; return true; } return false; } bool Mouse3D::rayIntersectionTriangle(const Vec3 &v1, const Vec3 &v2, const Vec3 &v3, Vec3 *IntersectionPoint32, f32 *t) const { Vec3 V1 = v1; Vec3 V2 = v2; Vec3 V3 = v3; Vec3 e1 = V2 - V1, e2 = V3 - V1; Vec3 pvec = Direction.cross(e2); f32 det = e1.dotProduct(pvec); if (det > -EPSILON && det < EPSILON) { return false; } f32 inv_det = 1.0f / det; Vec3 tvec = Origin - V1; f32 u = tvec.dotProduct(pvec) * inv_det; if (u < 0.0f || u > 1.0f) { return false; }; Vec3 qvec = tvec.cross(e1); f32 v = Direction.dotProduct(qvec) * inv_det; if (v < 0.0f || u + v > 1.0f) { return false; }; f32 _t = e2.dotProduct(qvec) * inv_det; if (!isnan((double)_t)) { *t = _t; } else return false; if (IntersectionPoint32) { *IntersectionPoint32 = Origin + (Direction * _t); } else return false; return true; } bool Mouse3D::rayIntersectionPlane(const Vec3 &Normal, const Vec3 &Position, Vec3 *IntersectionPoint32, f32* t) const { Vec3 intersectPoint; Vec3 u = Direction - Origin; Vec3 w = Origin - Position; f32 D = Normal.dotProduct(u); f32 N = -Normal.dotProduct(w); // if (fabs(D) < EPSILON) // segment is parallel to plane // { // if (N == 0) // segment lies in plane // return false; // else // return false; // no intersection // } float s = N / D; // if (s < 0 || s > 1) // return false; // no intersection intersectPoint = Origin + u*s; // compute segment intersect point // IntersectionPoint32->x = intersectPoint.x; // IntersectionPoint32->y = intersectPoint.y; // IntersectionPoint32->z = intersectPoint.z; f32 denom = Normal.dotProduct(Direction); Vec3 p0l0 = Position - Origin; f32 _t = p0l0.dotProduct(Normal) / denom; *IntersectionPoint32 = Origin + (Direction * _t); *t = _t; return true; } bool Mouse3D::rayIntersectionBox(Vec3 min, Vec3 max, f32* t) const { int32 tNear = INT_MIN; int32 tFar = INT_MAX; //check x if ((Direction.x == 0.f) && (Origin.x < min.x) && (Origin.x > max.x)) { //parallel return false; } else { float t1 = (min.x - Origin.x) / Direction.x; float t2 = (max.x - Origin.x) / Direction.x; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0)) return false; } //check y if ((Direction.y == 0) && (Origin.y < min.y) && (Origin.y > max.y)) { //parallel return false; } else { float t1 = (min.y - Origin.y) / Direction.y; float t2 = (max.y - Origin.y) / Direction.y; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0.f)) return false; } //check z if ((Direction.z == 0.f) && (Origin.z < min.z) && (Origin.z > max.z)) { //parallel return false; } else { float t1 = (min.z - Origin.z) / Direction.z; float t2 = (max.x - Origin.z) / Direction.z; if (t1 > t2) std::swap(t1, t2); tNear = (int32)Max(tNear, t1); tFar = (int32)Min(tFar, t2); if ((tNear > tFar) || (tFar < 0)) return false; } *t = (f32)tNear; return true; } bool Mouse3D::rayIntersectionSphere(const Vec3 &position, const f32 radius, Vec3 *intersectionPoint32, f32 *t) const { Vec3 m = Origin - position; f32 b = m.dotProduct(Direction); f32 c = m.dotProduct(m) - radius * radius; if (c > 0.0f && b > 0.0f) return false; f32 discr = b*b - c; if (discr < 0.0f) return false; *t = -b - sqrtf(discr); if (*t < 0.0f) *t = 0.0f; *intersectionPoint32 = position + (Direction * *t); return true; } bool Mouse3D::UnProject(const f32 winX, const f32 winY, const f32 winZ, const Matrix &modelview, const Matrix &proj, const Vec4 view, f32 *objx, f32 *objy, f32 *objz) { Matrix finalMatrix; Vec4 in; Vec4 out; finalMatrix = (proj * modelview).Inverse(); in.x = winX; in.y = winY; in.z = winZ; in.w = 1.0; /* Map x and y from window coordinates */ in.x = (in.x - view.x) / view.z; in.y = (in.y - view.y) / view.w; /* Map to range -1 to 1 */ in.x = in.x * 2.f - 1.f; in.y = in.y * 2.f - 1.f; in.z = in.z * 2.f - 1.f; out = finalMatrix * in; if (out.w == 0.0) return false; out.x /= out.w; out.y /= out.w; out.z /= out.w; *objx = out.x; *objy = out.y; *objz = out.z; return true; } }
23.385214
176
0.565391
Peixinho
5ece59e0e23c720c19bb40416ba4176396f58711
1,132
hpp
C++
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
13
2020-05-01T02:03:14.000Z
2022-02-03T17:48:26.000Z
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
5
2021-01-22T11:58:21.000Z
2022-01-21T21:06:17.000Z
Source/Scenes/DecryptFileScene.hpp
BaderEddineOuaich/Enigma
a42365146c80fb59e38f5653e17d4c931195e646
[ "MIT" ]
3
2021-01-22T09:05:50.000Z
2022-01-12T09:16:44.000Z
#pragma once #include "Scene.hpp" #include <Algorithm/Algorithm.hpp> NS_ENIGMA_BEGIN class DecryptFileScene : public Scene { public: /* Constructors / Destructor */ DecryptFileScene(); virtual ~DecryptFileScene() = default; private: /* Overrides */ void OnCreate() override; [[maybe_unused]] void OnUpdate(const f32& dt) override; void OnDraw() override; void OnImGuiDraw() override; void OnEvent(Event& event) override; void OnDestroy() override; private: /* Callbacks */ //void OnBrowseInFileButtonPressed(); //void OnBrowseOutFileButtonPressed(); void OnBrowseInFileButtonPressed(); // browse file to decrypt void OnBrowseOutFileLocationButtonPressed(); // browse decrypted file location void OnDecryptButtonPressed(); void OnBackButtonPressed(); private: Algorithm::Type m_type; // Algorithm type, AES, ChaCha, TripleDES... to help us create polymorphic algorithm String m_in_filename; // In File to decrypt String m_out_filename; // Out File to be recover String m_password; // encryption password //bool m_decompress{ true }; // Whether to deompress file with Gzip after decrypting }; NS_ENIGMA_END
29.025641
109
0.762367
BaderEddineOuaich
5ed9f572fd6dbefe9abae9ed029762f2e65bf9e9
42,489
cpp
C++
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
277
2017-05-18T08:27:10.000Z
2022-03-26T01:31:37.000Z
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
77
2017-09-03T15:35:02.000Z
2022-03-28T18:47:20.000Z
src/Samples/src/samples/meshes/extrude_polygon_scene.cpp
samdauwe/BabylonCpp
eea9f761a49bb460ff1324c20e4674ef120e94f1
[ "Apache-2.0" ]
37
2017-03-30T03:36:24.000Z
2022-01-28T08:28:36.000Z
#include <babylon/babylon_stl_util.h> #include <babylon/buffers/vertex_buffer.h> #include <babylon/cameras/arc_rotate_camera.h> #include <babylon/interfaces/icanvas.h> #include <babylon/interfaces/irenderable_scene_with_hud.h> #include <babylon/lights/hemispheric_light.h> #include <babylon/materials/standard_material.h> #include <babylon/materials/textures/texture.h> #include <babylon/maths/vector4.h> #include <babylon/meshes/builders/mesh_builder_options.h> #include <babylon/meshes/mesh.h> #include <babylon/meshes/mesh_builder.h> #include <babylon/samples/babylon_register_sample.h> #include <imgui.h> namespace BABYLON { namespace Samples { /** * @brief Extrude Polygon Scene. Example demonstrating how to use MeshBuilder to generate geometry * from extruded data. * @see https://www.babylonjs-playground.com/#TFLTJJ#0 * @see https://doc.babylonjs.com/api/classes/babylon.meshbuilder#extrudepolygon */ class ExtrudePolygonScene : public IRenderableSceneWithHud { public: ExtrudePolygonScene(ICanvas* iCanvas) : IRenderableSceneWithHud(iCanvas) // Roof , _roof{nullptr} , _ceiling{nullptr} // Front , _frontWall{nullptr} , _windowFBL{nullptr} , _windowFBR{nullptr} , _windowFTL{nullptr} , _windowFTR{nullptr} , _windowFTM{nullptr} , _frontDoor{nullptr} // Back , _rearWallnb1{nullptr} , _rearWallnb2{nullptr} , _windowRBL{nullptr} , _windowRBR{nullptr} , _windowRTL{nullptr} , _windowRTR{nullptr} , _windowR1BL{nullptr} , _windowR1TL{nullptr} , _windowR1TR{nullptr} // Left Side , _sideWallnb1{nullptr} , _sideWallnb3{nullptr} , _backDoor{nullptr} // Right Side , _sideWallnb2{nullptr} { } ~ExtrudePolygonScene() override = default; const char* getName() override { return "Extrude Polygon Scene"; } void initializeScene(ICanvas* canvas, Scene* scene) override { // Camera auto camera = ArcRotateCamera::New("Camera", -Math::PI_2, Math::PI / 3.f, 25.f, Vector3::Zero(), scene); camera->target = Vector3(0, 0.f, 4.5f); camera->attachControl(canvas, true); auto light = HemisphericLight::New("hemiLight", Vector3(10, 10, 0), scene); light->intensity = 0.98f; auto wallmat = StandardMaterial::New("wallmaterial", scene); wallmat->diffuseTexture = Texture::New("textures/wallMaterial.jpg", scene); auto innerwallmat = StandardMaterial::New("innerwallmaterial", scene); innerwallmat->diffuseColor = Color3(240.f / 255.f, 223.f / 255.f, 203.f / 255.f); // Front wall polygon shape in XoZ plane std::vector<Vector3> frontWallData{ Vector3(-5.5f, 0.f, -3.f), // Vector3(-0.5f, 0.f, -3.f), // Vector3(-0.5f, 0.f, -0.75f), // Vector3(0.5f, 0.f, -0.75f), // Vector3(0.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, 3.f), // Vector3(-5.5f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> frontWindowHoles{// frontWindowHoles[0] { Vector3(-4.78f, 0.f, -2.3f), // Vector3(-1.58f, 0.f, -2.3f), // Vector3(-1.58f, 0.f, -0.3f), // Vector3(-4.78f, 0.f, -0.3f) // }, // frontWindowHoles[1] { Vector3(1.58f, 0.f, -2.3f), // Vector3(4.78f, 0.f, -2.3f), // Vector3(4.78f, 0.f, -0.3f), // Vector3(1.58f, 0.f, -0.3f) // }, // frontWindowHoles[2] { Vector3(-4.03f, 0.f, 0.75f), // Vector3(-2.13f, 0.f, 0.75f), // Vector3(-2.13f, 0.f, 2.55f), // Vector3(-4.03f, 0.f, 2.55f) // }, // frontWindowHoles[3] { Vector3(-0.65f, 0.f, 0.75f), // Vector3(0.65f, 0.f, 0.75f), // Vector3(0.65f, 0.f, 2.55f), // Vector3(-0.65f, 0.f, 2.55f) // }, // frontWindowHoles[4] { Vector3(2.13f, 0.f, 0.75f), // Vector3(4.03f, 0.f, 0.75f), // Vector3(4.03f, 0.f, 2.55f), // Vector3(2.13f, 0.f, 2.55f) // }}; // Front wall faceUVs std::array<std::optional<Vector4>, 3> frontWallFaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Front Wall PolygonOptions frontWallOptions; frontWallOptions.shape = frontWallData; frontWallOptions.depth = 0.15f; frontWallOptions.holes = frontWindowHoles; frontWallOptions.faceUV = frontWallFaceUV; _frontWall = MeshBuilder::ExtrudePolygon("wall", frontWallOptions, scene); _frontWall->rotation().x = -Math::PI_2; _frontWall->material = wallmat; // Real wall polygon shape in XoZ plane std::vector<Vector3> rearWallnb1Data{ Vector3(1.4f, 0.f, -3.f), // Vector3(5.5f, 0.f, -3.f), // Vector3(5.5f, 0.f, 3.f), // Vector3(1.4f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> rear1WindowHoles{// rear1WindowHoles[0] { Vector3(3.7f, 0.f, -1.8f), // Vector3(4.5f, 0.f, -1.8f), // Vector3(4.5f, 0.f, -0.3f), // Vector3(3.7f, 0.f, -0.3f) // }, // rear1WindowHoles[1] { Vector3(1.9f, 0.f, 0.75f), // Vector3(2.7f, 0.f, 0.75f), // Vector3(2.7f, 0.f, 2.55f), // Vector3(1.9f, 0.f, 2.55f) // }, // rear1WindowHoles[2] { Vector3(4.2f, 0.f, 0.75f), // Vector3(5.f, 0.f, 0.75f), // Vector3(5.f, 0.f, 2.55f), // Vector3(4.2f, 0.f, 2.55f) // }}; // Rear Wall faceUVs std::array<std::optional<Vector4>, 3> rearFaceUV{ Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(0.f, 0.f, 7.f / 15.f, 1.f) // }; // Rear wall 1 PolygonOptions rearWallnb1Options; rearWallnb1Options.shape = rearWallnb1Data; rearWallnb1Options.depth = 0.1f; rearWallnb1Options.holes = rear1WindowHoles; rearWallnb1Options.faceUV = rearFaceUV; _rearWallnb1 = MeshBuilder::ExtrudePolygon("rearWallnb1", rearWallnb1Options, scene); _rearWallnb1->rotation().x = -Math::PI_2; _rearWallnb1->position().z = 6.15f; _rearWallnb1->material = wallmat; // Real wall nb2 polygon shape in XoZ plane std::vector<Vector3> rearWallnb2Data{ Vector3(-5.6f, 0.f, -3.f), // Vector3(1.45f, 0.f, -3.f), // Vector3(1.45f, 0.f, 3.f), // Vector3(-2.075f, 0.f, 5.5f), // Vector3(-5.6f, 0.f, 3.f) // }; // Holes in XoZ plane std::vector<std::vector<Vector3>> rear2WindowHoles{// rear2WindowHoles[0] { Vector3(-5.f, 0.f, -1.8f), // Vector3(-1.85f, 0.f, -1.8f), // Vector3(-1.85f, 0.f, -0.3f), // Vector3(-5.f, 0.f, -0.3f) // }, // rear2WindowHoles[1] { Vector3(-0.8f, 0.f, -1.8f), // Vector3(0.9f, 0.f, -1.8f), // Vector3(0.9f, 0.f, -0.3f), // Vector3(-0.8f, 0.f, -0.3f) // }, // rear2WindowHoles[2] { Vector3(-5.f, 0.f, 0.75f), // Vector3(-1.85f, 0.f, 0.75f), // Vector3(-1.85f, 0.f, 2.55f), // Vector3(-5.f, 0.f, 2.55f) // }, // rear2WindowHoles[3] { Vector3(-0.6f, 0.f, 1.75f), // Vector3(0.7f, 0.f, 1.75f), // Vector3(0.7f, 0.f, 2.55f), // Vector3(-0.6f, 0.f, 2.55f) // }}; // Rear wall 2 PolygonOptions rearWallnb2Options; rearWallnb2Options.shape = rearWallnb2Data; rearWallnb2Options.depth = 0.1f; rearWallnb2Options.holes = rear2WindowHoles; rearWallnb2Options.faceUV = rearFaceUV; _rearWallnb2 = MeshBuilder::ExtrudePolygon("rearWallnb2", rearWallnb2Options, scene); _rearWallnb2->rotation().x = -Math::PI_2; _rearWallnb2->position().z = 9.15f; _rearWallnb2->material = wallmat; // Side wall 1 polygon shape in XoZ plane std::vector<Vector3> sideWallnb1Data{ Vector3(-3.15f, 0.f, -3.f), // Vector3(3.1f, 0.f, -3.f), // Vector3(3.1f, 0.f, 3.f), // Vector3(0.f, 0.f, 5.5f), // Vector3(-3.15f, 0.f, 3.f) // }; // Side wall 1 faceUVs std::array<std::optional<Vector4>, 3> side1FaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Side wall 1 PolygonOptions sideWallnb1Options; sideWallnb1Options.shape = sideWallnb1Data; sideWallnb1Options.depth = 0.1f; sideWallnb1Options.faceUV = side1FaceUV; _sideWallnb1 = MeshBuilder::ExtrudePolygon("sideWallnb1", sideWallnb1Options, scene); _sideWallnb1->rotation().z = -Math::PI_2; _sideWallnb1->rotation().x = -Math::PI_2; _sideWallnb1->position().x = 5.6f; _sideWallnb1->position().z = 3.15f; _sideWallnb1->material = wallmat; // Side wall nb2 polygon shape in XoZ plane std::vector<Vector3> sideWallnb2Data{ Vector3(-3.15f, 0.f, -3.f), // Vector3(6.f, 0.f, -3.f), // Vector3(6.f, 0.f, 3.f), // Vector3(3.1f, 0.f, 3.f), // Vector3(0.f, 0.f, 5.5f), // Vector3(-3.15f, 0.f, 3.f) // }; // Side wall 2 faceUVs std::array<std::optional<Vector4>, 3> side2FaceUV{ Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(0.f, 0.f, 7.f / 15.f, 1.f) // }; // Side wall 2 PolygonOptions sideWallnb2Options; sideWallnb2Options.shape = sideWallnb2Data; sideWallnb2Options.depth = 0.1f; sideWallnb2Options.faceUV = side2FaceUV; _sideWallnb2 = MeshBuilder::ExtrudePolygon("sideWallnb2", sideWallnb2Options, scene); _sideWallnb2->rotation().z = -Math::PI_2; _sideWallnb2->rotation().x = -Math::PI_2; _sideWallnb2->position().x = -5.5f; _sideWallnb2->position().z = 3.15f; _sideWallnb2->material = wallmat; // Side wall 3 std::vector<Vector3> sideWallnb3Data{ Vector3(3.1f, 0.f, -3.f), // Vector3(4.5f, 0.f, -3.f), // Vector3(4.5f, 0.f, -0.75f), // Vector3(5.5f, 0.f, -0.75f), // Vector3(5.5f, 0.f, -3.f), // Vector3(6.f, 0.f, -3.f), // Vector3(6.f, 0.f, 3.f), // Vector3(3.1f, 0.f, 3.f) // }; // Side wall 3 faceUVs std::array<std::optional<Vector4>, 3> side3FaceUV{ Vector4(0.f, 0.f, 7.f / 15.f, 1.f), // Vector4(14.f / 15.f, 0.f, 1.f, 1.f), // Vector4(7.f / 15.f, 0.f, 14.f / 15.f, 1.f) // }; // Side wall 3 PolygonOptions sideWallnb3Options; sideWallnb3Options.shape = sideWallnb3Data; sideWallnb3Options.depth = 0.1f; sideWallnb3Options.faceUV = side3FaceUV; _sideWallnb3 = MeshBuilder::ExtrudePolygon("sideWallnb3", sideWallnb3Options, scene); _sideWallnb3->rotation().z = -Math::PI_2; _sideWallnb3->rotation().x = -Math::PI_2; _sideWallnb3->position().x = 1.45f; _sideWallnb3->position().z = 3.15f; _sideWallnb3->material = wallmat; // Roof material auto roofmat = StandardMaterial::New("roofmat", scene); roofmat->diffuseTexture = Texture::New("textures/roofMaterial.jpg", scene); // Roof 1 polygon shape in XoZ plane std::vector<Vector3> roof1Data{ Vector3(-0.05f, 0.f, 0.f), // Vector3(0.1f, 0.f, 0.f), // Vector3(3.3f, 0.f, 2.65f), // Vector3(6.5f, 0.f, 0.f), // Vector3(6.6f, 0.f, 0.f), // Vector3(3.3f, 0.f, 2.8f) // }; // Roof 1 PolygonOptions roof1Options; roof1Options.shape = roof1Data; roof1Options.depth = 11.5f; auto roof1 = MeshBuilder::ExtrudePolygon("roof1", roof1Options, scene); roof1->rotation().z = -Math::PI_2; roof1->rotation().x = -Math::PI_2; roof1->position().x = 5.7f; roof1->position().y = 2.9f; roof1->position().z = -0.15f; roof1->material = roofmat; // Roof 2 polygon shape in XoZ plane std::vector<Vector3> roof2Data{ Vector3(0.f, 0.f, 0.f), // Vector3(0.142f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.6f), // Vector3(7.476f, 0.f, 0.f), // Vector3(7.618f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.7f) // }; // Roof 2 PolygonOptions roof2Options; roof2Options.shape = roof2Data; roof2Options.depth = 3.2f; auto roof2 = MeshBuilder::ExtrudePolygon("roof2", roof2Options, scene); roof2->rotation().x = -Math::PI_2; roof2->position().x = -5.9f; roof2->position().y = 2.9f; roof2->position().z = 6.3f; roof2->material = roofmat; // Roof 3 polygon shape in XoZ plane std::vector<Vector3> roof3Data{ Vector3(0.3f, 0.f, 0.2f), // Vector3(0.442f, 0.f, 0.2f), // Vector3(3.834f, 0.f, 2.6f), // Vector3(7.476f, 0.f, 0.f), // Vector3(7.618f, 0.f, 0.f), // Vector3(3.834f, 0.f, 2.7f) // }; // Roof 3 PolygonOptions roof3Options; roof3Options.shape = roof3Data; roof3Options.depth = 3.2f; auto roof3 = MeshBuilder::ExtrudePolygon("roof3", roof3Options, scene); roof3->rotation().x = -Math::PI_2; roof3->position().x = -5.9f; roof3->position().y = 2.9f; roof3->position().z = 3.1f; roof3->material = roofmat; // Roof _roof = Mesh::MergeMeshes({roof1, roof2, roof3}, true); // Staircase auto stairsDepth = 2.f; auto stairsHeight = 3.f; auto stairsThickness = 0.05f; auto nBStairs = 12; std::vector<Vector3> stairs; auto x = 0.f; auto z = 0.f; // Up stairs.emplace_back(Vector3(x, 0.f, z)); z += stairsHeight / nBStairs - stairsThickness; stairs.emplace_back(Vector3(x, 0.f, z)); for (int i = 0; i < nBStairs; ++i) { x += stairsDepth / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); z += stairsHeight / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); } x += stairsDepth / nBStairs - stairsThickness; stairs.emplace_back(Vector3(x, 0.f, z)); // Down for (int i = 0; i <= nBStairs; i++) { x -= stairsDepth / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); z -= stairsHeight / nBStairs; stairs.emplace_back(Vector3(x, 0.f, z)); } std::array<std::optional<Color4>, 3> faceColors{ Color4(0.f, 0.f, 0.f, 1.f), // Color4(190.f / 255.f, 139.f / 255.f, 94.f / 255.f, 1.f), // Color4(0.f, 0.f, 0.f, 1.f), // }; // Stairs auto stairsWidth = 1.f; PolygonOptions stairsOptions; stairsOptions.shape = stairs; stairsOptions.depth = stairsWidth; stairsOptions.faceColors = faceColors; auto stairCase = MeshBuilder::ExtrudePolygon("stairs", stairsOptions, scene); stairCase->position().x = 1.37f; stairCase->position().y = -3.f; stairCase->position().z = 2.51f; stairCase->rotation().x = -Math::PI_2; stairCase->rotation().y = -Math::PI_2; // Floor material auto floormat = StandardMaterial::New("floormaterial", scene); floormat->diffuseTexture = Texture::New("textures/floorMaterial.jpg", scene); // Floor polygon shape in XoZ plane std::vector<Vector3> floorData{ Vector3(-5.5f, 0.f, 0), // Vector3(5.5f, 0.f, 0), // Vector3(5.5f, 0.f, 6), // Vector3(1.345f, 0.f, 6), // Vector3(1.345f, 0.f, 9), // Vector3(-5.5f, 0.f, 9) // }; // Stair space std::vector<std::vector<Vector3>> stairSpace{// stairSpace[0] { Vector3(0.27f, 0.f, 2.5f), // Vector3(0.27f, 0.f, 4.5f), // Vector3(1.37f, 0.f, 4.5f), // Vector3(1.37f, 0.f, 2.5f), // }}; // Rear Wall faceUVs std::array<std::optional<Vector4>, 3> floorFaceUV{ Vector4(0.f, 0.f, 0.5f, 1.f), // Vector4(0.f, 0.f, 0.f, 0.f), // Vector4(0.5f, 0.f, 1.f, 1.f) // }; // Floor PolygonOptions floorOptions; floorOptions.shape = floorData; floorOptions.holes = stairSpace; floorOptions.depth = 0.1f; floorOptions.faceUV = floorFaceUV; auto floor = MeshBuilder::ExtrudePolygon("floor", floorOptions, scene); floor->position().y = 0.21f; floor->position().z = 0.15f; floor->material = floormat; // Ground floor polygon shape in XoZ plane std::vector<Vector3> groundFloorData{ Vector3(-5.6f, 0.f, -0.1f), // Vector3(5.6f, 0.f, -0.1f), // Vector3(5.6f, 0.f, 6.1f), // Vector3(1.36f, 0.f, 6.1f), // Vector3(1.36f, 0.f, 9.1f), // Vector3(-5.6f, 0.f, 9.1f) // }; // Ground floor faceUVs std::array<std::optional<Vector4>, 3> groundFloorFaceUV{ Vector4(0.f, 0.f, 0.5f, 1.f), // Vector4(0.f, 0.f, 0.f, 0.f), // Vector4(0.5f, 0.f, 1.f, 1.f) // }; // Ground floor PolygonOptions groundFloorOptions; groundFloorOptions.shape = groundFloorData; groundFloorOptions.depth = 0.04f; groundFloorOptions.faceUV = groundFloorFaceUV; auto groundFloor = MeshBuilder::ExtrudePolygon("groundFloor", groundFloorOptions, scene); groundFloor->position().y = -3.f; groundFloor->position().z = 0.15f; groundFloor->material = floormat; // Ceiling polygon shape in XoZ plane std::vector<Vector3> ceilingData{ Vector3(-5.5f, 0.f, 0.f), // Vector3(5.5f, 0.f, 0.f), // Vector3(5.5f, 0.f, 6.f), // Vector3(1.345f, 0.f, 6.f), // Vector3(1.345f, 0.f, 9.f), // Vector3(-5.5f, 0.f, 9.f) // }; // Ceiling PolygonOptions ceilingOptions; ceilingOptions.shape = ceilingData; ceilingOptions.depth = 0.1f; _ceiling = MeshBuilder::ExtrudePolygon("ceiling", ceilingOptions, scene); _ceiling->position().y = 2.8f; _ceiling->position().z = 0.15f; _ceiling->material = innerwallmat; // Inner wall 1 polygon shape in XoZ plane std::vector<Vector3> innerWallnb1Data{ Vector3(-3.f, 0.f, 0.6f), // Vector3(-3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 6.1f), // Vector3(-3.f, 0.f, 6.1f), // Vector3(-3.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 0.6f), // }; // Door space 1 std::vector<std::vector<Vector3>> doorSpace1{// doorSpace1[0] { Vector3(0.1f, 0.f, 1.6f), // Vector3(0.1f, 0.f, 0.6f), // Vector3(2.f, 0.f, 0.6f), // Vector3(2.f, 0.f, 1.6f) // }}; // Inner wall 1 PolygonOptions innerWallnb1Options; innerWallnb1Options.shape = innerWallnb1Data; innerWallnb1Options.holes = doorSpace1; innerWallnb1Options.depth = 0.1f; auto innerWallnb1 = MeshBuilder::ExtrudePolygon("innerWallnb1", innerWallnb1Options, scene); innerWallnb1->rotation().z = Math::PI_2; innerWallnb1->position().x = 1.35f; innerWallnb1->position().z = 0.15f; innerWallnb1->material = innerwallmat; // Inner wall 1 polygon shape in XoZ plane std::vector<Vector3> innerWallnb2Data{ Vector3(-3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 0.f), // Vector3(3.f, 0.f, 9.f), // Vector3(-3.f, 0.f, 9.f), // Vector3(-3.f, 0.f, 7.6f), // Vector3(-1.f, 0.f, 7.6f), // Vector3(-1.f, 0.f, 6.6f), // Vector3(-3.f, 0.f, 6.6f), // Vector3(-3.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 1.6f), // Vector3(-1.f, 0.f, 0.6f), // Vector3(-3.f, 0.f, 0.6f) // }; // Door space 2 std::vector<std::vector<Vector3>> doorSpace2{// doorSpace2[0] { Vector3(0.1f, 0.f, 0.6f), // Vector3(2.f, 0.f, 0.6f), // Vector3(2.f, 0.f, 1.6f), // Vector3(0.1f, 0.f, 1.6f) // }, // doorSpace2[1] { Vector3(0.1f, 0.f, 4.6f), // Vector3(2.f, 0.f, 4.6f), // Vector3(2.f, 0.f, 5.6f), // Vector3(0.1f, 0.f, 5.6f) // }}; // Inner wall 2 PolygonOptions innerWallnb2options; innerWallnb2options.shape = innerWallnb2Data; innerWallnb2options.holes = doorSpace2; innerWallnb2options.depth = 0.1f; auto innerWallnb2 = MeshBuilder::ExtrudePolygon("innerWallnb2", innerWallnb2options, scene); innerWallnb2->rotation().z = Math::PI_2; innerWallnb2->position().x = 1.35f; innerWallnb2->position().z = 0.15f; innerWallnb2->position().x = -1.4f; innerWallnb2->material = innerwallmat; // Bathroom wall polygon shape in XoZ plane std::vector<Vector3> bathroomWallData{ Vector3(-1.4f, 0.f, 0), // Vector3(-0.5f, 0.f, 0), // Vector3(-0.5f, 0.f, 2), // Vector3(0.5f, 0.f, 2), // Vector3(0.5f, 0.f, 0), // Vector3(1.4f, 0.f, 0), // Vector3(1.4f, 0.f, 6), // Vector3(-1.4f, 0.f, 6) // }; // Door space 3 std::vector<std::vector<Vector3>> doorSpace3{// doorSpace3[0] { Vector3(-0.5f, 0.f, 3.2f), // Vector3(-0.5f, 0.f, 5.2f), // Vector3(0.5f, 0.f, 5.2f), // Vector3(0.5f, 0.f, 3.2f) // }}; // Bathroom wall PolygonOptions bathroomOptions; bathroomOptions.shape = bathroomWallData; bathroomOptions.depth = 0.1f; bathroomOptions.holes = doorSpace3; auto bathroomWall = MeshBuilder::ExtrudePolygon("bathroomWall", bathroomOptions, scene); bathroomWall->rotation().x = -Math::PI_2; bathroomWall->position().y = -3.f; bathroomWall->position().z = 6.f; bathroomWall->material = innerwallmat; // Bedroom 1 wall shape in XoZ plane std::vector<Vector3> bedroom1WallData{ Vector3(-5.5f, 0.f, 0.f), // Vector3(-2.9f, 0.f, 0.f), // Vector3(-2.9f, 0.f, 2.f), // Vector3(-1.9f, 0.f, 2.f), // Vector3(-1.9f, 0.f, 0.f), // Vector3(-1.4f, 0.f, 0.f), // Vector3(-1.4f, 0.f, 6.f), // Vector3(-5.5f, 0.f, 6.f) // }; // Bedroom 1 wall PolygonOptions bedroom1WallOptions; bedroom1WallOptions.shape = bedroom1WallData; bedroom1WallOptions.depth = 0.1f; auto bedroom1Wall = MeshBuilder::ExtrudePolygon("bedroom1Wall", bedroom1WallOptions, scene); bedroom1Wall->rotation().x = -Math::PI_2; bedroom1Wall->position().y = -3; bedroom1Wall->position().z = 4.5; bedroom1Wall->material = innerwallmat; // Bannister wall shape in XoZ plane std::vector<Vector3> bannisterWallData{ Vector3(0.f, 0.f, 0.f), // Vector3(1.f, 0.f, 0.f), // Vector3(1.f, 0.f, 1.4f), // Vector3(1.75f, 0.f, 1.4f), // Vector3(1.75f, 0.f, 0.f), // Vector3(3.5f, 0.f, 0.f), // Vector3(3.5f, 0.f, 3.2f), // Vector3(1.5f, 0.f, 3.2f), // Vector3(0.f, 0.f, 0.75f) // }; auto spindleThickness = 0.05f; auto spindles = 12; auto railGap = (1.5f - spindles * spindleThickness) / (spindles - 1.f); std::vector<std::vector<Vector3>> rail; auto ac = spindleThickness; for (auto s = 0; s < spindles - 1; s++) { std::vector<Vector3> rails; rails.emplace_back(Vector3(ac, 0.f, 0.1f + 1.6f * ac)); rails.emplace_back(Vector3(ac, 0.f, (0.75f - spindleThickness) + 1.6f * ac)); rails.emplace_back( Vector3(ac + railGap, 0.f, (0.75f - spindleThickness) + 1.6f * (ac + railGap))); rails.emplace_back(Vector3(ac + railGap, 0.f, 1.6f * (ac + railGap))); rail.emplace_back(rails); ac += spindleThickness + railGap; } // Bannister wall PolygonOptions bannisterWallOptions; bannisterWallOptions.shape = bannisterWallData; bannisterWallOptions.holes = rail; bannisterWallOptions.depth = 0.1f; auto bannisterWall = MeshBuilder::ExtrudePolygon("bannisterWall", bannisterWallOptions, scene); bannisterWall->rotation().x = -Math::PI_2; bannisterWall->rotation().z = -Math::PI_2; bannisterWall->position().x = 0.4f; bannisterWall->position().y = -3.f; bannisterWall->position().z = 2.51f; // Bannister 1 shape in XoZ plane std::vector<Vector3> bannister1Data{ Vector3(0, 0.f, 0), Vector3(2, 0.f, 0), Vector3(2, 0.f, 0.75), Vector3(0, 0.f, 0.75), }; auto spindle1Thickness = 0.05f; auto spindles1 = 12; auto rail1Gap = (2.f - spindles1 * spindle1Thickness) / (spindles1 - 1.f); std::vector<std::vector<Vector3>> rail1; auto ac1 = spindle1Thickness; for (auto s = 0; s < spindles1 - 1; s++) { std::vector<Vector3> rail1s; rail1s.emplace_back(Vector3(ac1, 0.f, spindle1Thickness)); rail1s.emplace_back(Vector3(ac1, 0.f, 0.75f - spindle1Thickness)); rail1s.emplace_back(Vector3(ac1 + rail1Gap, 0.f, 0.75f - spindle1Thickness)); rail1s.emplace_back(Vector3(ac1 + rail1Gap, 0.f, spindle1Thickness)); rail1.emplace_back(rail1s); ac1 += spindle1Thickness + rail1Gap; } // Bannister 1 PolygonOptions bannister1Options; bannister1Options.shape = bannister1Data; bannister1Options.holes = rail1; bannister1Options.depth = 0.1f; auto bannister1 = MeshBuilder::ExtrudePolygon("bannister1", bannister1Options, scene); bannister1->rotation().x = -Math::PI_2; bannister1->rotation().z = -Math::PI_2; bannister1->position().x = 0.3f; bannister1->position().y = 0.2f; bannister1->position().z = 2.61f; // Bannister 2 shape in XoZ plane std::vector<Vector3> bannister2Data{ Vector3(0, 0.f, 0), Vector3(1, 0.f, 0), Vector3(1, 0.f, 0.75), Vector3(0, 0.f, 0.75), }; auto spindle2Thickness = 0.05f; auto spindles2 = 6; auto rail2Gap = (1.f - spindles2 * spindle2Thickness) / (spindles2 - 1.f); std::vector<std::vector<Vector3>> rail2; auto ac2 = spindle2Thickness; for (auto s = 0; s < spindles2 - 1; s++) { std::vector<Vector3> rail2s; rail2s.emplace_back(Vector3(ac2, 0.f, spindle2Thickness)); rail2s.emplace_back(Vector3(ac2, 0.f, 0.75f - spindle2Thickness)); rail2s.emplace_back(Vector3(ac2 + rail2Gap, 0.f, 0.75f - spindle2Thickness)); rail2s.emplace_back(Vector3(ac2 + rail2Gap, 0.f, spindle2Thickness)); rail2.emplace_back(rail2s); ac2 += spindle2Thickness + rail2Gap; } // Bannister 2 PolygonOptions bannister2Options; bannister2Options.shape = bannister2Data; bannister2Options.holes = rail2; bannister2Options.depth = 0.1f; auto bannister2 = MeshBuilder::ExtrudePolygon("bannister2", bannister2Options, scene); bannister2->rotation().x = -Math::PI_2; bannister2->position().x = 0.3f; bannister2->position().y = 0.2f; bannister2->position().z = 2.61f; // Windo maker function const auto windowMaker = [scene](float width, float height, float frames, float frameDepth, float frameThickness) { std::vector<Vector3> windowShape{ Vector3(0.f, 0.f, 0.f), // Vector3(width, 0.f, 0.f), // Vector3(width, 0.f, height), // Vector3(0.f, 0.f, height) // }; auto glassWidth = (width - (frames + 1.f) * frameThickness) / frames; auto glassTopHeight = height / 3.f - frameThickness; auto glassBotHeight = 2.f * glassTopHeight; std::vector<std::vector<Vector3>> glass; auto acf = frameThickness; for (auto f = 0; f < frames; ++f) { std::vector<Vector3> glass2f; glass2f.emplace_back(Vector3(acf, 0.f, 2.f * frameThickness + glassBotHeight)); glass2f.emplace_back(Vector3(acf + glassWidth, 0.f, 2.f * frameThickness + glassBotHeight)); glass2f.emplace_back( Vector3(acf + glassWidth, 0.f, 2.f * frameThickness + glassBotHeight + glassTopHeight)); glass2f.emplace_back( Vector3(acf, 0.f, 2.f * frameThickness + glassBotHeight + glassTopHeight)); glass.emplace_back(glass2f); std::vector<Vector3> glass2f1; glass2f1.emplace_back(Vector3(acf, 0.f, frameThickness)); glass2f1.emplace_back(Vector3(acf + glassWidth, 0.f, frameThickness)); glass2f1.emplace_back(Vector3(acf + glassWidth, 0.f, frameThickness + glassBotHeight)); glass2f1.emplace_back(Vector3(acf, 0.f, frameThickness + glassBotHeight)); glass.emplace_back(glass2f1); acf += frameThickness + glassWidth; } PolygonOptions windowOptions; windowOptions.shape = windowShape; windowOptions.holes = glass; windowOptions.depth = frameDepth; auto window = MeshBuilder::ExtrudePolygon("window", windowOptions, scene); window->rotation().x = -Math::PI_2; return window; }; _windowFBL = windowMaker(3.2f, 2.f, 4.f, 0.15f, 0.1f); _windowFBL->position().x = -4.78f; _windowFBL->position().y = -2.3f; _windowFBL->position().z = 0.1f; _windowFBR = windowMaker(3.2f, 2.f, 4.f, 0.15f, 0.1f); _windowFBR->position().x = 1.58f; _windowFBR->position().y = -2.3f; _windowFBR->position().z = 0.1f; _windowFTL = windowMaker(1.9f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTL->position().x = -4.03f; _windowFTL->position().y = 0.75f; _windowFTL->position().z = 0.1f; _windowFTR = windowMaker(1.9f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTR->position().x = 2.13f; _windowFTR->position().y = 0.75f; _windowFTR->position().z = 0.1f; _windowFTM = windowMaker(1.3f, 1.8f, 2.f, 0.15f, 0.1f); _windowFTM->position().x = -0.65f; _windowFTM->position().y = 0.75f; _windowFTM->position().z = 0.1f; _windowRBL = windowMaker(3.15f, 1.5f, 4.f, 0.15f, 0.1f); _windowRBL->position().x = -5.f; _windowRBL->position().y = -1.8f; _windowRBL->position().z = 9.f; _windowRBR = windowMaker(1.7f, 1.5f, 2.f, 0.15f, 0.1f); _windowRBR->position().x = -0.8f; _windowRBR->position().y = -1.8f; _windowRBR->position().z = 9.f; _windowRTL = windowMaker(3.15f, 1.8f, 4.f, 0.15f, 0.1f); _windowRTL->position().x = -5.f; _windowRTL->position().y = 0.75f; _windowRTL->position().z = 9.f; _windowRTR = windowMaker(1.3f, 0.8f, 1.f, 0.15f, 0.1f); _windowRTR->position().x = -0.6f; _windowRTR->position().y = 1.75f; _windowRTR->position().z = 9.f; _windowR1BL = windowMaker(0.8f, 1.5f, 1.f, 0.15f, 0.1f); _windowR1BL->position().x = 3.7f; _windowR1BL->position().y = -1.8f; _windowR1BL->position().z = 6.f; _windowR1TL = windowMaker(0.8f, 1.8f, 1.f, 0.15f, 0.1f); _windowR1TL->position().x = 1.9f; _windowR1TL->position().y = 0.75f; _windowR1TL->position().z = 6.f; _windowR1TR = windowMaker(0.8f, 1.8f, 1.f, 0.15f, 0.1f); _windowR1TR->position().x = 4.2f; _windowR1TR->position().y = 0.75f; _windowR1TR->position().z = 6.f; // Door maker function const auto doorMaker = [scene](float width, float height, float depth) { std::vector<Vector3> doorShape{ Vector3(0.f, 0.f, 0.f), // Vector3(width, 0.f, 0.f), // Vector3(width, 0.f, height), // Vector3(0.f, 0.f, height) // }; auto edgeThickness = width / 8.f; auto panelWidth = width - 2.f * edgeThickness; auto panelBotHeight = (height - 3.f * edgeThickness) / 1.75f; auto panelTopHeight = 0.75f * panelBotHeight; std::vector<std::vector<Vector3>> panel; std::vector<Vector3> panel0; panel0.emplace_back(Vector3(edgeThickness, 0.f, 2.f * edgeThickness + panelBotHeight)); panel0.emplace_back( Vector3(edgeThickness + panelWidth, 0.f, 2.f * edgeThickness + panelBotHeight)); panel0.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, 2.f * edgeThickness + panelBotHeight + panelTopHeight)); panel0.emplace_back( Vector3(edgeThickness, 0.f, 2.f * edgeThickness + panelBotHeight + panelTopHeight)); panel.emplace_back(panel0); std::vector<Vector3> panel1; panel1.emplace_back(Vector3(edgeThickness, 0.f, edgeThickness)); panel1.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, edgeThickness)); panel1.emplace_back(Vector3(edgeThickness + panelWidth, 0.f, edgeThickness + panelBotHeight)); panel1.emplace_back(Vector3(edgeThickness, 0.f, edgeThickness + panelBotHeight)); panel.emplace_back(panel1); // Door PolygonOptions doorOptions; doorOptions.shape = doorShape; doorOptions.holes = panel; doorOptions.depth = depth; auto door = MeshBuilder::ExtrudePolygon("door", doorOptions, scene); door->rotation().x = -Math::PI_2; // Bottom panel BoxOptions panelBOptions; panelBOptions.width = panelWidth; panelBOptions.height = panelBotHeight; panelBOptions.depth = depth / 2.f; auto panelB = MeshBuilder::CreateBox("p1b", panelBOptions, scene); panelB->position().x = edgeThickness + panelWidth / 2.f; panelB->position().y = edgeThickness + panelBotHeight / 2.f; panelB->position().z = depth / 2.f; // Top panel BoxOptions panelTOptions; panelTOptions.width = panelWidth; panelTOptions.height = panelTopHeight; panelTOptions.depth = depth / 2.f; auto panelT = MeshBuilder::CreateBox("p1t", panelTOptions, scene); panelT->position().x = edgeThickness + panelWidth / 2; panelT->position().y = 2.f * edgeThickness + panelBotHeight + panelTopHeight / 2.f; panelT->position().z = depth / 2.f; return Mesh::MergeMeshes({door, panelB, panelT}, true); }; auto doormat = StandardMaterial::New("door", scene); doormat->diffuseColor = Color3(82.f / 255.f, 172.f / 255.f, 106.f / 255.f); // Front door _frontDoor = doorMaker(1.f, 2.25f, 0.1f); _frontDoor->position().x = -0.5f; _frontDoor->position().y = -3.f; _frontDoor->position().z = 0.1f; _frontDoor->material = doormat; // Back door _backDoor = doorMaker(1, 2.25f, 0.1f); _backDoor->rotation().y = Math::PI_2; _backDoor->position().x = 1.3f; _backDoor->position().y = -3.f; _backDoor->position().z = 8.65f; _backDoor->material = doormat; hudGui = [=]() { // Checkbox helper const auto renderCheckBox = [](const char* label, bool isSelected) -> bool { bool origValue = isSelected; ImGui::Checkbox(label, &isSelected); return origValue != isSelected; }; // Header ImGui::TextWrapped("%s", "Toggle Visibility"); // Toggle Roof Visibility if (renderCheckBox("Roof", _roof->isVisible)) { _roof->isVisible = !_roof->isVisible; _ceiling->isVisible = !_ceiling->isVisible; } // Toggle Front Visibility if (renderCheckBox("Front", _frontWall->isVisible)) { _frontWall->isVisible = !_frontWall->isVisible; _windowFBL->isVisible = !_windowFBL->isVisible; _windowFBR->isVisible = !_windowFBR->isVisible; _windowFTL->isVisible = !_windowFTL->isVisible; _windowFTR->isVisible = !_windowFTR->isVisible; _windowFTM->isVisible = !_windowFTM->isVisible; _frontDoor->isVisible = !_frontDoor->isVisible; } // Toggle Back Visibility if (renderCheckBox("Back", _rearWallnb1->isVisible)) { _rearWallnb1->isVisible = !_rearWallnb1->isVisible; _rearWallnb2->isVisible = !_rearWallnb2->isVisible; _windowRBL->isVisible = !_windowRBL->isVisible; _windowRBR->isVisible = !_windowRBR->isVisible; _windowRTL->isVisible = !_windowRTL->isVisible; _windowRTR->isVisible = !_windowRTR->isVisible; _windowR1BL->isVisible = !_windowR1BL->isVisible; _windowR1TL->isVisible = !_windowR1TL->isVisible; _windowR1TR->isVisible = !_windowR1TR->isVisible; } // Toggle Left Side Visibility if (renderCheckBox("Left Side", _sideWallnb1->isVisible)) { _sideWallnb1->isVisible = !_sideWallnb1->isVisible; _sideWallnb3->isVisible = !_sideWallnb3->isVisible; _backDoor->isVisible = !_backDoor->isVisible; } // Toggle Right Side Visibility if (renderCheckBox("Right Side", _sideWallnb2->isVisible)) { _sideWallnb2->isVisible = !_sideWallnb2->isVisible; } }; } private: // Roof MeshPtr _roof, _ceiling; // Front MeshPtr _frontWall, _windowFBL, _windowFBR, _windowFTL, _windowFTR, _windowFTM, _frontDoor; // Back MeshPtr _rearWallnb1, _rearWallnb2, _windowRBL, _windowRBR, _windowRTL, _windowRTR, _windowR1BL, _windowR1TL, _windowR1TR; // Left Side MeshPtr _sideWallnb1, _sideWallnb3, _backDoor; // Right Side MeshPtr _sideWallnb2; }; // end of class ExtrudePolygonScene BABYLON_REGISTER_SAMPLE("Meshes", ExtrudePolygonScene) } // end of namespace Samples } // end of namespace BABYLON
41.533724
100
0.512274
samdauwe
5eda7a9a5a1a0619e7d0ea373894e962f5c0bb43
3,546
cpp
C++
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
stocks_trade.cpp
mattregul/df-ai
9e74c015e173b9f67cf95e45fdb0ce02e987f1df
[ "Zlib" ]
null
null
null
#include "ai.h" #include "stocks.h" #include "df/general_ref.h" #include "df/item_foodst.h" bool Stocks::willing_to_trade_item(color_ostream & out, df::item *item) { if (virtual_cast<df::item_foodst>(item)) { return true; } if (item->isFoodStorage()) { bool any_contents = false; for (auto ref : item->general_refs) { if (ref->getType() == general_ref_type::CONTAINS_ITEM) { any_contents = true; if (!willing_to_trade_item(out, ref->getItem())) { return false; } } } return any_contents; } return false; } bool Stocks::want_trader_item(color_ostream &, df::item *item, const std::vector<df::item *> & already_want) { if (item->hasSpecificImprovements(improvement_type::WRITING) || item->getType() == item_type::BOOK) { return true; } if (item->getType() == item_type::WOOD || item->getType() == item_type::BOULDER || item->getType() == item_type::BAR) { return true; } if (item->getType() == item_type::CLOTH || item->getType() == item_type::SKIN_TANNED || item->getType() == item_type::THREAD) { return true; } if (item->getType() == item_type::CHEESE || item->getType() == item_type::EGG || item->getType() == item_type::FISH || item->getType() == item_type::FISH_RAW || item->getType() == item_type::MEAT || item->getType() == item_type::PLANT || item->getType() == item_type::PLANT_GROWTH) { return true; } if (item->getType() == item_type::INSTRUMENT) { return true; } if (item->getType() == item_type::ANVIL) { int32_t anvils_wanted = -int32_t(std::count_if(already_want.begin(), already_want.end(), [](df::item *i) -> bool { return i->getType() == item_type::ANVIL; })); anvils_wanted -= count_free[stock_item::anvil]; ai.find_room(room_type::workshop, [&anvils_wanted](room *r) -> bool { if (r->workshop_type == workshop_type::MetalsmithsForge && !r->dfbuilding()) { anvils_wanted++; } return false; }); return anvils_wanted >= 0; } return false; } bool Stocks::want_trader_item_more(df::item *a, df::item *b) { if (a->getType() == item_type::WOOD && b->getType() != item_type::WOOD) { return true; } else if (b->getType() == item_type::WOOD && a->getType() != item_type::WOOD) { return false; } if (a->getType() == item_type::ANVIL && b->getType() != item_type::ANVIL) { return true; } else if (b->getType() == item_type::ANVIL && a->getType() != item_type::ANVIL) { return false; } if ((a->hasSpecificImprovements(improvement_type::WRITING) || a->getType() == item_type::BOOK) && !(b->hasSpecificImprovements(improvement_type::WRITING) || b->getType() == item_type::BOOK)) { return true; } else if ((b->hasSpecificImprovements(improvement_type::WRITING) || b->getType() == item_type::BOOK) && !(a->hasSpecificImprovements(improvement_type::WRITING) || a->getType() == item_type::BOOK)) { return false; } if (a->getType() == item_type::INSTRUMENT && b->getType() != item_type::INSTRUMENT) { return true; } else if (b->getType() == item_type::INSTRUMENT && a->getType() != item_type::INSTRUMENT) { return false; } return false; }
28.829268
285
0.565426
mattregul
5edb4636708ab8b61422e468e1bcf33a5bbf0bb0
456
cpp
C++
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
9
2020-06-02T16:40:40.000Z
2021-10-03T15:22:40.000Z
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
2
2020-11-06T00:00:24.000Z
2022-02-14T01:59:08.000Z
common/Net/Fd.cpp
ZmnSCPxj/cldcb
4375d95cacee2a51fe5c4c1accc9fc616474bd41
[ "MIT" ]
2
2021-01-02T15:29:50.000Z
2022-02-23T07:26:00.000Z
#include<errno.h> #include<unistd.h> #include<utility> #include"Net/Fd.hpp" namespace Net { Fd& Fd::operator=(Fd&& o) { auto tmp = Fd(std::move(o)); swap(tmp); return *this; } Fd::~Fd() { if (fd >= 0) { /* Ignore errors. * This is a destructor, so it is * entirely possible that this * occurred due to errno-based * errors. * So, we should preserve the errno. */ auto my_errno = errno; close(fd); errno = my_errno; } } }
15.2
38
0.607456
ZmnSCPxj
5edc8bfef4f7236867a536407485d247cc1558d3
2,833
cpp
C++
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
TopCoderSRM/SRM635/IdentifyingWood.cpp
zombiecry/AlgorithmPractice
f42933883bd62a86aeef9740356f5010c6c9bebf
[ "MIT" ]
null
null
null
// BEGIN CUT HERE // END CUT HERE #line 5 "IdentifyingWood.cpp" #include <vector> #include <list> #include <bitset> #include <map> #include <set> #include <deque> #include <queue> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cstring> using namespace std; int n,m; class IdentifyingWood { public: string s; string t; int dp[11][11]; bool Solve(int p,int q){ if (q==0){return true;} if (p==0){return false;} if (dp[p][q]!=-1){return dp[p][q];} bool res=false; if (s[p-1]==t[q-1]){ res|=Solve(p-1,q-1); } res|=Solve(p-1,q); dp[p][q]=res; return res; } string check(string s, string t) { n=s.length(); m=t.length(); if (m>n){ return "Nope."; } this->s=s; this->t=t; memset(dp,-1,sizeof(dp)); if (Solve(n,m)){ return "Yep, it's wood."; } return "Nope."; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const string &Expected, const string &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } } void test_case_0() { string Arg0 = "absdefgh"; string Arg1 = "asdf"; string Arg2 = "Yep, it's wood."; verify_case(0, Arg2, check(Arg0, Arg1)); } void test_case_1() { string Arg0 = "oxoxoxox"; string Arg1 = "ooxxoo"; string Arg2 = "Nope."; verify_case(1, Arg2, check(Arg0, Arg1)); } void test_case_2() { string Arg0 = "oxoxoxox"; string Arg1 = "xxx"; string Arg2 = "Yep, it's wood."; verify_case(2, Arg2, check(Arg0, Arg1)); } void test_case_3() { string Arg0 = "qwerty"; string Arg1 = "qwerty"; string Arg2 = "Yep, it's wood."; verify_case(3, Arg2, check(Arg0, Arg1)); } void test_case_4() { string Arg0 = "string"; string Arg1 = "longstring"; string Arg2 = "Nope."; verify_case(4, Arg2, check(Arg0, Arg1)); } // END CUT HERE }; // BEGIN CUT HERE int main() { IdentifyingWood ___test; ___test.run_test(-1); system("pause"); return 0; } // END CUT HERE
32.563218
314
0.590187
zombiecry
5edf254d52b46d7f901c8a46cdbc0b992d3eda4f
3,242
cxx
C++
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
XY/testing/test_AB.cxx
fmauger/BoostSerializationTwoCompilationUnitsDemo
6ddb5e10d72383042258e3e9f13a1ae51a96cbff
[ "OLDAP-2.3" ]
null
null
null
// Standard library: #include <iostream> #include <fstream> /// Third Party: // - Boost: #include <boost/serialization/nvp.hpp> #include <boost/archive/xml_oarchive.hpp> #include <boost/archive/xml_iarchive.hpp> // Ourselves: #include <XY/config.hpp> #if BSTCUD_WITH_EOS == 1 #include <eos/portable_oarchive.hpp> #include <eos/portable_iarchive.hpp> #endif // Ourselves: #include <XY/A.hpp> #include <XY/B.hpp> int main(void) { { { std::ofstream file("test_AB.xml"); boost::archive::xml_oarchive oa(file); xy::A * a_ptr = new xy::A(1); xy::A * b_ptr = new xy::B(2, 3); xy::A * b2_ptr = new xy::B(4, 5); std::clog << "a = " << a_ptr->to_string() << std::endl; std::clog << "b = " << b_ptr->to_string() << std::endl; std::clog << "b2 = " << b2_ptr->to_string() << std::endl; std::clog << "Serializing..." << std::endl; oa & BOOST_SERIALIZATION_NVP(a_ptr); oa & BOOST_SERIALIZATION_NVP(b_ptr); oa & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } { std::ifstream file("test_AB.xml"); boost::archive::xml_iarchive ia(file); xy::A * a_ptr = nullptr; xy::A * b_ptr = nullptr; xy::A * b2_ptr = nullptr; std::clog << "Deserializing..." << std::endl; ia & BOOST_SERIALIZATION_NVP(a_ptr); ia & BOOST_SERIALIZATION_NVP(b_ptr); ia & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; std::clog << "loaded a = " << a_ptr->to_string() << std::endl; std::clog << "loaded b = " << b_ptr->to_string() << std::endl; std::clog << "loaded b2 = " << b2_ptr->to_string() << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } } #if BSTCUD_WITH_EOS == 1 { { std::ofstream file("test_AB.data"); eos::portable_oarchive oa(file); xy::A * a_ptr = new xy::A(1); xy::A * b_ptr = new xy::B(2, 3); xy::A * b2_ptr = new xy::B(4, 5); std::clog << "a = " << a_ptr->to_string() << std::endl; std::clog << "b = " << b_ptr->to_string() << std::endl; std::clog << "b2 = " << b2_ptr->to_string() << std::endl; std::clog << "Serializing..." << std::endl; oa & BOOST_SERIALIZATION_NVP(a_ptr); oa & BOOST_SERIALIZATION_NVP(b_ptr); oa & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } { std::ifstream file("test_AB.data"); eos::portable_iarchive ia(file); xy::A * a_ptr = nullptr; xy::A * b_ptr = nullptr; xy::A * b2_ptr = nullptr; std::clog << "Deserializing..." << std::endl; ia & BOOST_SERIALIZATION_NVP(a_ptr); ia & BOOST_SERIALIZATION_NVP(b_ptr); ia & BOOST_SERIALIZATION_NVP(b2_ptr); std::clog << "Done." << std::endl; std::clog << "loaded a = " << a_ptr->to_string() << std::endl; std::clog << "loaded b = " << b_ptr->to_string() << std::endl; std::clog << "loaded b2 = " << b2_ptr->to_string() << std::endl; delete a_ptr; delete b_ptr; delete b2_ptr; } } #endif return 0; }
29.472727
70
0.559531
fmauger
5ee0805621a7661148327ddbf1aa332461ddb931
7,268
cpp
C++
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
660
2017-11-21T15:55:52.000Z
2022-03-31T06:31:00.000Z
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
1,070
2017-12-01T00:26:10.000Z
2022-03-31T17:55:26.000Z
media_driver/agnostic/gen8/codec/hal/codechal_kernel_hme_g8.cpp
lacc97/media-driver
8aa1d74b80668f9963e691b1c01ab564f50aec85
[ "Intel", "BSD-3-Clause", "MIT" ]
309
2017-11-30T08:34:09.000Z
2022-03-30T18:52:07.000Z
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ //! //! \file codechal_kernel_hme_g8.cpp //! \brief Hme kernel implementation for Gen8 platform //! #include "codechal_kernel_hme_g8.h" // clang-format off const uint32_t CodechalKernelHmeG8::Curbe::m_initCurbe[39] = { 0x00000000, 0x00200010, 0x00003939, 0x77a43000, 0x00000000, 0x28300000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff }; // clang-format on CodechalKernelHmeG8::CodechalKernelHmeG8( CodechalEncoderState *encoder, bool me4xDistBufferSupported) : CodechalKernelHme(encoder, me4xDistBufferSupported) { } MOS_STATUS CodechalKernelHmeG8::SetCurbe(MHW_KERNEL_STATE *kernelState) { CODECHAL_ENCODE_CHK_NULL_RETURN(kernelState); Curbe curbe; uint32_t mvShiftFactor = 0; uint32_t prevMvReadPosFactor = 0; uint32_t scaleFactor; bool useMvFromPrevStep; bool writeDistortions; if (m_32xMeInUse) { useMvFromPrevStep = false; writeDistortions = false; scaleFactor = scalingFactor32X; mvShiftFactor = 1; prevMvReadPosFactor = 0; } else if (m_16xMeInUse) { useMvFromPrevStep = Is32xMeEnabled() ? true : false; writeDistortions = false; scaleFactor = scalingFactor16X; mvShiftFactor = 2; prevMvReadPosFactor = 1; } else if (m_4xMeInUse) { useMvFromPrevStep = Is16xMeEnabled() ? true : false; writeDistortions = true; scaleFactor = scalingFactor4X; mvShiftFactor = 2; prevMvReadPosFactor = 0; } else { return MOS_STATUS_INVALID_PARAMETER; } curbe.m_data.DW3.SubPelMode = m_curbeParam.subPelMode; if (m_fieldScalingOutputInterleaved) { curbe.m_data.DW3.SrcAccess = curbe.m_data.DW3.RefAccess = CodecHal_PictureIsField(m_curbeParam.currOriginalPic); curbe.m_data.DW7.SrcFieldPolarity = CodecHal_PictureIsBottomField(m_curbeParam.currOriginalPic); } curbe.m_data.DW4.PictureHeightMinus1 = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameFieldHeight / scaleFactor) - 1; curbe.m_data.DW4.PictureWidth = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_frameWidth / scaleFactor); curbe.m_data.DW5.QpPrimeY = m_curbeParam.qpPrimeY; curbe.m_data.DW6.WriteDistortions = writeDistortions; curbe.m_data.DW6.UseMvFromPrevStep = useMvFromPrevStep; curbe.m_data.DW6.SuperCombineDist = SuperCombineDist[m_curbeParam.targetUsage]; curbe.m_data.DW6.MaxVmvR = CodecHal_PictureIsFrame(m_curbeParam.currOriginalPic) ? m_curbeParam.maxMvLen * 4 : (m_curbeParam.maxMvLen >> 1) * 4; if (m_pictureCodingType == B_TYPE) { curbe.m_data.DW1.BiWeight = 32; curbe.m_data.DW13.NumRefIdxL1MinusOne = m_curbeParam.numRefIdxL1Minus1; } if (m_pictureCodingType == B_TYPE || m_pictureCodingType == P_TYPE) { curbe.m_data.DW13.NumRefIdxL0MinusOne = m_curbeParam.numRefIdxL0Minus1; } if (!CodecHal_PictureIsFrame(m_curbeParam.currOriginalPic)) { if (m_pictureCodingType != I_TYPE) { curbe.m_data.DW14.List0RefID0FieldParity = m_curbeParam.list0RefID0FieldParity; curbe.m_data.DW14.List0RefID1FieldParity = m_curbeParam.list0RefID1FieldParity; curbe.m_data.DW14.List0RefID2FieldParity = m_curbeParam.list0RefID2FieldParity; curbe.m_data.DW14.List0RefID3FieldParity = m_curbeParam.list0RefID3FieldParity; curbe.m_data.DW14.List0RefID4FieldParity = m_curbeParam.list0RefID4FieldParity; curbe.m_data.DW14.List0RefID5FieldParity = m_curbeParam.list0RefID5FieldParity; curbe.m_data.DW14.List0RefID6FieldParity = m_curbeParam.list0RefID6FieldParity; curbe.m_data.DW14.List0RefID7FieldParity = m_curbeParam.list0RefID7FieldParity; } if (m_pictureCodingType == B_TYPE) { curbe.m_data.DW14.List1RefID0FieldParity = m_curbeParam.list1RefID0FieldParity; curbe.m_data.DW14.List1RefID1FieldParity = m_curbeParam.list1RefID1FieldParity; } } curbe.m_data.DW15.MvShiftFactor = mvShiftFactor; curbe.m_data.DW15.PrevMvReadPosFactor = prevMvReadPosFactor; // r3 & r4 uint8_t methodIndex; if (m_pictureCodingType == B_TYPE) { CODECHAL_ENCODE_CHK_NULL_RETURN(m_bmeMethodTable); methodIndex = m_curbeParam.bmeMethodTable ? m_curbeParam.bmeMethodTable[m_curbeParam.targetUsage] : m_bmeMethodTable[m_curbeParam.targetUsage]; } else { CODECHAL_ENCODE_CHK_NULL_RETURN(m_meMethodTable); methodIndex = m_curbeParam.meMethodTable ? m_curbeParam.meMethodTable[m_curbeParam.targetUsage] : m_meMethodTable[m_curbeParam.targetUsage]; } uint8_t tableIndex = (m_pictureCodingType == B_TYPE) ? 1 : 0; MOS_SecureMemcpy(&curbe.m_data.SpDelta, 14 * sizeof(uint32_t), codechalEncodeSearchPath[tableIndex][methodIndex], 14 * sizeof(uint32_t)); //r5 curbe.m_data.DW32._4xMeMvOutputDataSurfIndex = BindingTableOffset::meOutputMvDataSurface; curbe.m_data.DW33._16xOr32xMeMvInputDataSurfIndex = BindingTableOffset::meInputMvDataSurface; curbe.m_data.DW34._4xMeOutputDistSurfIndex = BindingTableOffset::meDistortionSurface; curbe.m_data.DW35._4xMeOutputBrcDistSurfIndex = BindingTableOffset::meBrcDistortion; curbe.m_data.DW36.VMEFwdInterPredictionSurfIndex = BindingTableOffset::meCurrForFwdRef; curbe.m_data.DW37.VMEBwdInterPredictionSurfIndex = BindingTableOffset::meCurrForBwdRef; CODECHAL_ENCODE_CHK_STATUS_RETURN(kernelState->m_dshRegion.AddData(&curbe.m_data, kernelState->dwCurbeOffset, Curbe::m_curbeSize)); return MOS_STATUS_SUCCESS; }
44.048485
160
0.726472
lacc97
5ee2066454a7ab9999491f028bcaa3647abf74df
712
cpp
C++
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
6
2022-01-23T09:40:33.000Z
2022-03-20T20:53:25.000Z
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
null
null
null
src/shadereditor/src/shadereditor/properties/vsheet_cmatrix.cpp
cstom4994/SourceEngineRebuild
edfd7f8ce8af13e9d23586318350319a2e193c08
[ "MIT" ]
1
2022-02-06T21:05:23.000Z
2022-02-06T21:05:23.000Z
 #include "cbase.h" #include "vSheets.h" CSheet_CMatrix::CSheet_CMatrix(CBaseNode *pNode, CNodeView *view, KeyValues *data, Panel *parent) : BaseClass(pNode, view, data, parent) { SetParent(parent); m_pCBox_MType = new ComboBox(this, "cbox_mtype", 10, false); for (int i = 0; i < CMATRIX_LAST; i++) m_pCBox_MType->AddItem(GetCMatrixInfo(i)->szCanvasName, NULL); LoadControlSettings("shadereditorui/vgui/sheet_cmatrix.res"); } CSheet_CMatrix::~CSheet_CMatrix() { } void CSheet_CMatrix::OnResetData() { m_pCBox_MType->ActivateItem(pData->GetInt("i_c_matrix")); } void CSheet_CMatrix::OnApplyChanges() { pData->SetInt("i_c_matrix", m_pCBox_MType->GetActiveItem()); }
26.37037
97
0.706461
cstom4994
5ee413f5311948e62f5d3d287c45a4ae742842f4
294
cpp
C++
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
Smart_Home/src/core/main.cpp
Forsyth-Creations/Smart_Home_VT
0b53ecf15eeacafacf28d311eb360f84184e63d4
[ "MIT" ]
null
null
null
#include <Arduino.h> #include "smarthome\SmartHome.h" #include <SoftwareSerial.h> SmartHome home = SmartHome(); void setup() { // put your setup code here, to run once: Serial.begin(9600); home.init(); } void loop() { // put your main code here, to run repeatedly: home.run(); }
14
48
0.663265
Forsyth-Creations
5ee5dc81098368d12401b468d376fdbe41907e3a
1,223
cpp
C++
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
1
2021-02-08T14:50:50.000Z
2021-02-08T14:50:50.000Z
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
null
null
null
src/cpp/arrays/10_rotate_matrix.cpp
ajaybiswas22/gfg-coding-problems
9484ff82f7fb7f663a15bc6058bc0bc24cd13015
[ "MIT" ]
null
null
null
#include<bits/stdc++.h> using namespace std; void swapFour(int &x, int &y, int &z,int &a) { int temp = x; x = y; y = z; z = a; a = temp; } void printMatrix(vector<vector<int>> A) { for(int i=0;i<A.size();i++) { for(int j=0;j<A[i].size();j++) { cout<<A[i][j]<< " "; } cout<<"\n"; } } void rotate(vector<vector<int>> &A) { int n = A.size(); int *a,*b,*c,*d; // a b // c d for(int i=0;i<n/2;i++) // outer to inner { for(int j=0;j<n-i-1;j++) // stop one before also stay in inner box { // place all pointers at each corner // move a right, c up, d left, b down (spins left side) a = &A[i][i+j]; b = &A[i+j][n-1-i]; c = &A[n-1-i-j][i]; d = &A[n-1-i][n-1-i-j]; swapFour(*a,*b,*d,*c); } } } int main() { vector<vector<int>> A = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,16} }; printMatrix(A); rotate(A); cout<<"\n"; printMatrix(A); return 0; }
20.383333
79
0.376942
ajaybiswas22
5ee6865fad9c2fcf874d70d1c35635e2714cc1d0
6,602
cpp
C++
Framework/Audio/Audio.cpp
dengwenyi88/Deferred_Lighting
b45b6590150a3119b0c2365f4795d93b3b4f0748
[ "MIT" ]
110
2017-06-23T17:12:28.000Z
2022-02-22T19:11:38.000Z
RunTest/Framework3/Audio/Audio.cpp
dtrebilco/ECSAtto
86a04f0bdc521c79f758df94250c1898c39213c8
[ "MIT" ]
null
null
null
RunTest/Framework3/Audio/Audio.cpp
dtrebilco/ECSAtto
86a04f0bdc521c79f758df94250c1898c39213c8
[ "MIT" ]
3
2018-02-12T00:16:18.000Z
2018-02-18T11:12:35.000Z
/* * * * * * * * * * * * * Author's note * * * * * * * * * * * *\ * _ _ _ _ _ _ _ _ _ _ _ _ * * |_| |_| |_| |_| |_|_ _|_| |_| |_| _|_|_|_|_| * * |_|_ _ _|_| |_| |_| |_|_|_|_|_| |_| |_| |_|_ _ _ * * |_|_|_|_|_| |_| |_| |_| |_| |_| |_| |_| |_|_|_|_ * * |_| |_| |_|_ _ _|_| |_| |_| |_|_ _ _|_| _ _ _ _|_| * * |_| |_| |_|_|_| |_| |_| |_|_|_| |_|_|_|_| * * * * http://www.humus.name * * * * This file is a part of the work done by Humus. You are free to * * use the code in any way you like, modified, unmodified or copied * * into your own work. However, I expect you to respect these points: * * - If you use this file and its contents unmodified, or use a major * * part of this file, please credit the author and leave this note. * * - For use in anything commercial, please request my approval. * * - Share your work and ideas too as much as you can. * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "Audio.h" #include <stdio.h> #include "codec.h" #include "vorbisfile.h" #ifdef _WIN32 # pragma comment (lib, "../Framework3/Libs/OpenAL32.lib") # pragma comment (lib, "../Framework3/Libs/alut.lib") # pragma comment (lib, "../Framework3/Libs/ogg_static.lib") # pragma comment (lib, "../Framework3/Libs/vorbis_static.lib") # pragma comment (lib, "../Framework3/Libs/vorbisfile_static.lib") #endif Audio::Audio(){ dev = alcOpenDevice(NULL); ctx = alcCreateContext(dev, NULL); alcMakeContextCurrent(ctx); // alDistanceModel(AL_INVERSE_DISTANCE); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); //alListenerf(AL_GAIN, 0.0f); } Audio::~Audio(){ clear(); alcMakeContextCurrent(NULL); alcDestroyContext(ctx); alcCloseDevice(dev); } void Audio::clear(){ int index = sounds.getCount(); while (index--){ deleteSound(index); } index = soundSources.getCount(); while (index--){ deleteSoundSource(index); } } SoundID Audio::addSound(const char *fileName, unsigned int flags){ Sound sound; // Clear error flag alGetError(); const char *ext = strrchr(fileName, '.') + 1; char str[256]; if (stricmp(ext, "ogg") == 0){ FILE *file = fopen(fileName, "rb"); if (file == NULL){ sprintf(str, "Couldn't open \"%s\"", fileName); ErrorMsg(str); return SOUND_NONE; } OggVorbis_File vf; memset(&vf, 0, sizeof(vf)); if (ov_open(file, &vf, NULL, 0) < 0){ fclose(file); sprintf(str, "\"%s\" is not an ogg file", fileName); ErrorMsg(str); return SOUND_NONE; } vorbis_info *vi = ov_info(&vf, -1); int nSamples = (uint) ov_pcm_total(&vf, -1); int nChannels = vi->channels; sound.format = nChannels == 1? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16; sound.sampleRate = vi->rate; sound.size = nSamples * nChannels; sound.samples = new short[sound.size]; sound.size *= sizeof(short); int samplePos = 0; while (samplePos < sound.size){ char *dest = ((char *) sound.samples) + samplePos; int bitStream, readBytes = ov_read(&vf, dest, sound.size - samplePos, 0, 2, 1, &bitStream); if (readBytes <= 0) break; samplePos += readBytes; } ov_clear(&vf); } else { ALboolean al_bool; ALvoid *data; alutLoadWAVFile(fileName, &sound.format, &data, &sound.size, &sound.sampleRate, &al_bool); sound.samples = (short *) data; } alGenBuffers(1, &sound.buffer); alBufferData(sound.buffer, sound.format, sound.samples, sound.size, sound.sampleRate); if (alGetError() != AL_NO_ERROR){ alDeleteBuffers(1, &sound.buffer); sprintf(str, "Couldn't open \"%s\"", fileName); ErrorMsg(str); return SOUND_NONE; } return insertSound(sound); } SoundID Audio::insertSound(Sound &sound){ for (uint i = 0; i < sounds.getCount(); i++){ if (sounds[i].samples == NULL){ sounds[i] = sound; return i; } } return sounds.add(sound); } void Audio::deleteSound(const SoundID sound){ if (sounds[sound].samples){ alDeleteBuffers(1, &sounds[sound].buffer); alutUnloadWAV(sounds[sound].format, sounds[sound].samples, sounds[sound].size, sounds[sound].sampleRate); //delete sound.samples; sounds[sound].samples = NULL; } } SoundSourceID Audio::addSoundSource(const SoundID sound, uint flags){ SoundSrc soundSource; soundSource.sound = sound; alGenSources(1, &soundSource.source); alSourcei(soundSource.source, AL_LOOPING, (flags & LOOPING)? AL_TRUE : AL_FALSE); alSourcei(soundSource.source, AL_SOURCE_RELATIVE, (flags & RELATIVEPOS)? AL_TRUE : AL_FALSE); alSourcei(soundSource.source, AL_BUFFER, sounds[sound].buffer); alSourcef(soundSource.source, AL_MIN_GAIN, 0.0f); alSourcef(soundSource.source, AL_MAX_GAIN, 1.0f); return insertSoundSource(soundSource); } SoundID Audio::insertSoundSource(SoundSrc &source){ for (uint i = 0; i < soundSources.getCount(); i++){ if (soundSources[i].sound == SOUND_NONE){ soundSources[i] = source; return i; } } return soundSources.add(source); } void Audio::deleteSoundSource(const SoundSourceID source){ if (soundSources[source].sound != SOUND_NONE){ alDeleteSources(1, &soundSources[source].source); soundSources[source].sound = SOUND_NONE; } } void Audio::play(const SoundSourceID source){ alSourcePlay(soundSources[source].source); } void Audio::stop(const SoundSourceID source){ alSourceStop(soundSources[source].source); } void Audio::pause(const SoundSourceID source){ alSourcePause(soundSources[source].source); } bool Audio::isPlaying(const SoundSourceID source){ ALint state; alGetSourcei(soundSources[source].source, AL_SOURCE_STATE, &state); return (state == AL_PLAYING); } void Audio::setListenerOrientation(const vec3 &position, const vec3 &zDir){ alListenerfv(AL_POSITION, position); float orient[] = { zDir.x, zDir.y, zDir.z, 0, -1, 0 }; alListenerfv(AL_ORIENTATION, orient); } void Audio::setSourceGain(const SoundSourceID source, const float gain){ alSourcef(soundSources[source].source, AL_GAIN, gain); } void Audio::setSourcePosition(const SoundSourceID source, const vec3 &position){ alSourcefv(soundSources[source].source, AL_POSITION, position); } void Audio::setSourceAttenuation(const SoundSourceID source, const float rollOff, const float refDistance){ alSourcef(soundSources[source].source, AL_REFERENCE_DISTANCE, refDistance); alSourcef(soundSources[source].source, AL_ROLLOFF_FACTOR, rollOff); }
29.212389
107
0.642684
dengwenyi88
5ee81ea9b33246e8e0912bb59182c86a6f510bbc
4,345
cpp
C++
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
135
2021-05-06T04:03:27.000Z
2022-03-31T01:34:03.000Z
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
17
2021-05-10T06:44:54.000Z
2022-03-07T09:00:43.000Z
src/backbones/VGG.cpp
0x0000dead/LibtorchSegmentation
04332ea83a6ea843bd8a52e3c95deda449457373
[ "MIT" ]
33
2021-05-05T16:12:17.000Z
2022-03-22T07:56:26.000Z
#include "VGG.h" torch::nn::Sequential make_features(std::vector<int> &cfg, bool batch_norm) { torch::nn::Sequential features; int in_channels = 3; for (auto v : cfg) { if (v == -1) { features->push_back(torch::nn::MaxPool2d(maxpool_options(2, 2))); } else { auto conv2d = torch::nn::Conv2d(conv_options(in_channels, v, 3, 1, 1)); features->push_back(conv2d); if (batch_norm) { features->push_back(torch::nn::BatchNorm2d(torch::nn::BatchNorm2dOptions(v))); } features->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); in_channels = v; } } return features; } VGGImpl::VGGImpl(std::vector<int> _cfg, int num_classes, bool batch_norm_) { cfg = _cfg; batch_norm = batch_norm_; features_ = make_features(cfg, batch_norm); avgpool = torch::nn::AdaptiveAvgPool2d(torch::nn::AdaptiveAvgPool2dOptions(7)); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(512 * 7 * 7, 4096))); classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); classifier->push_back(torch::nn::Dropout()); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, 4096))); classifier->push_back(torch::nn::ReLU(torch::nn::ReLUOptions(true))); classifier->push_back(torch::nn::Dropout()); classifier->push_back(torch::nn::Linear(torch::nn::LinearOptions(4096, num_classes))); features_ = register_module("features", features_); classifier = register_module("classifier", classifier); } torch::Tensor VGGImpl::forward(torch::Tensor x) { x = features_->forward(x); x = avgpool(x); x = torch::flatten(x, 1); x = classifier->forward(x); return torch::log_softmax(x, 1); } std::vector<torch::Tensor> VGGImpl::features(torch::Tensor x, int encoder_depth) { std::vector<torch::Tensor> ans; int j = 0;// layer index of features_ for (int i = 0; i < cfg.size(); i++) { if (cfg[i] == -1) { ans.push_back(x); if (ans.size() == encoder_depth ) { break; } x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); } else { x = this->features_[j++]->as<torch::nn::Conv2d>()->forward(x); if (batch_norm) { x = this->features_[j++]->as<torch::nn::BatchNorm2d>()->forward(x); } x = this->features_[j++]->as<torch::nn::ReLU>()->forward(x); } } if (ans.size() == encoder_depth && encoder_depth==5) { x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); ans.push_back(x); } return ans; } torch::Tensor VGGImpl::features_at(torch::Tensor x, int stage_num) { assert(stage_num > 0 && stage_num <=5 && "the stage number must in range[1,5]"); int j = 0; int stage_count = 0; for (int i = 0; i < cfg.size(); i++) { if (cfg[i] == -1) { x = this->features_[j++]->as<torch::nn::MaxPool2d>()->forward(x); stage_count++; if (stage_count == stage_num) return x; } else { x = this->features_[j++]->as<torch::nn::Conv2d>()->forward(x); if (batch_norm) { x = this->features_[j++]->as<torch::nn::BatchNorm2d>()->forward(x); } x = this->features_[j++]->as<torch::nn::ReLU>()->forward(x); } } return x; } void VGGImpl::load_pretrained(std::string pretrained_path) { VGG net_pretrained = VGG(cfg, 1000, batch_norm); torch::load(net_pretrained, pretrained_path); torch::OrderedDict<std::string, at::Tensor> pretrained_dict = net_pretrained->named_parameters(); torch::OrderedDict<std::string, at::Tensor> model_dict = this->named_parameters(); for (auto n = pretrained_dict.begin(); n != pretrained_dict.end(); n++) { if (strstr((*n).key().data(), "classifier.")) { continue; } model_dict[(*n).key()] = (*n).value(); } torch::autograd::GradMode::set_enabled(false); // make parameters copying possible auto new_params = model_dict; // implement this auto params = this->named_parameters(true /*recurse*/); auto buffers = this->named_buffers(true /*recurse*/); for (auto& val : new_params) { auto name = val.key(); auto* t = params.find(name); if (t != nullptr) { t->copy_(val.value()); } else { t = buffers.find(name); if (t != nullptr) { t->copy_(val.value()); } } } torch::autograd::GradMode::set_enabled(true); return; } void VGGImpl::make_dilated(std::vector<int> stage_list, std::vector<int> dilation_list) { std::cout<< "'VGG' models do not support dilated mode due to Max Pooling operations for downsampling!"; return; }
31.035714
104
0.653855
0x0000dead
5eeefc8955a126639d411835065af8b4d429f63d
244,816
cc
C++
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
61
2020-03-17T12:30:11.000Z
2022-03-01T18:59:11.000Z
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
12
2020-03-24T15:46:54.000Z
2022-01-08T02:03:31.000Z
source/auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.cc
AdamJMiles/gpu_performance_api
7bd0c8b484b2a658610581e2e48b615606130fdc
[ "MIT" ]
19
2020-03-16T17:32:09.000Z
2022-03-29T23:35:31.000Z
//============================================================================== // Copyright (c) 2010-2021 Advanced Micro Devices, Inc. All rights reserved. /// @author AMD Developer Tools Team /// @file /// @brief Public Counter Definitions for DX12 GFX8. //============================================================================== #include "gpu_perf_api_counter_generator/gpa_counter.h" #include "auto_generated/gpu_perf_api_counter_generator/public_counter_definitions_dx12_gfx8.h" // *** Note, this is an auto-generated file. Do not edit. Execute PublicCounterCompiler to rebuild. void AutoDefinePublicDerivedCountersDx12Gfx8(GpaDerivedCounters& c) { { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); c.DefineDerivedCounter("GPUTime", "Timing", "Time this API command took to execute on the GPU in nanoseconds from the time the previous command reached the bottom of the pipeline (BOP) to the time this command reaches the bottom of the pipeline (BOP). Does not include time that draw calls are processed in parallel.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "cbd338f2-de6c-7b14-92ad-ba724ca2e501"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51134); c.DefineDerivedCounter("ExecutionDuration", "Timing", "GPU command execution duration in nanoseconds, from the time the command enters the top of the pipeline (TOP) to the time the command reaches the bottom of the pipeline (BOP). Does not include time that draw calls are processed in parallel.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "b2f08d0d-af13-cd66-d3b4-b290ad448e69"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51135); c.DefineDerivedCounter("ExecutionStart", "Timing", "GPU command execution start time in nanoseconds. This is the time the command enters the top of the pipeline (TOP).", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "a368f79d-fcfe-2158-71c4-2f0c4eef5aa4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51136); c.DefineDerivedCounter("ExecutionEnd", "Timing", "GPU command execution end time in nanoseconds. This is the time the command reaches the bottom of the pipeline (BOP).", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "0,TS_FREQ,/,(1000000000),*", "0bce206a-0976-06a2-bf20-03fb351035a8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(49743); internal_counters.push_back(49741); c.DefineDerivedCounter("GPUBusy", "Timing", "The percentage of time GPU was busy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,/,(100),*,(100),min", "bef38bf3-1167-0844-81f0-67d2d28ddbc5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(49743); c.DefineDerivedCounter("GPUBusyCycles", "Timing", "Number of GPU cycles that the GPU was busy.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0", "1e84970d-7014-2b8d-d61e-388b5f782691"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(191); internal_counters.push_back(338); internal_counters.push_back(485); internal_counters.push_back(632); internal_counters.push_back(49743); c.DefineDerivedCounter("TessellatorBusy", "Timing", "The percentage of time the tessellation engine is busy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,/,(100),*", "36af6c72-dcfb-8102-4fd4-ce8ddc573365"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(191); internal_counters.push_back(338); internal_counters.push_back(485); internal_counters.push_back(632); c.DefineDerivedCounter("TessellatorBusyCycles", "Timing", "Number of GPU cycles that the tessellation engine is busy.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max", "60289dcb-7b33-46e7-26d1-8a2121605543"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("VSBusy", "Timing", "The percentage of time the ShaderUnit has vertex shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,16,ifnotzero,4,20,ifnotzero,8,24,ifnotzero,(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,max,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max,28,/,(100),*,(100),min", "94caad5e-867c-6c09-cf3a-d05b51df8f3b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); c.DefineDerivedCounter("VSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has vertex shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,16,ifnotzero,4,20,ifnotzero,8,24,ifnotzero,(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,max,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max", "a2086d4e-274b-48a8-3e08-a4ab76ac15dd"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2903); internal_counters.push_back(3100); internal_counters.push_back(3297); internal_counters.push_back(3494); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2865); internal_counters.push_back(3062); internal_counters.push_back(3259); internal_counters.push_back(3456); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("VSTime", "Timing", "Time vertex shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,17,ifnotzero,5,21,ifnotzero,9,25,ifnotzero,(0),2,18,ifnotzero,6,22,ifnotzero,10,26,ifnotzero,max,(0),3,19,ifnotzero,7,23,ifnotzero,11,27,ifnotzero,max,(0),4,20,ifnotzero,8,24,ifnotzero,12,28,ifnotzero,max,29,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "d6ce819e-69af-a241-d07a-5dd8d146e436"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); internal_counters.push_back(49743); c.DefineDerivedCounter("HSBusy", "Timing", "The percentage of time the ShaderUnit has hull shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*,(100),min", "16f30a0b-4cbf-eccd-b13f-ab68dd254d32"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); c.DefineDerivedCounter("HSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has hull shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "753e76ef-8ef8-3f13-b511-4bd9f3589fdb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2893); internal_counters.push_back(3090); internal_counters.push_back(3287); internal_counters.push_back(3484); internal_counters.push_back(2899); internal_counters.push_back(3096); internal_counters.push_back(3293); internal_counters.push_back(3490); internal_counters.push_back(49743); c.DefineDerivedCounter("HSTime", "Timing", "Time hull shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "8386a863-dd34-1526-f703-0f0c7b241bc4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("DSBusy", "Timing", "The percentage of time the ShaderUnit has domain shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,12,ifnotzero,16,ifnotzero,(0),1,5,13,ifnotzero,17,ifnotzero,max,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max,20,/,(100),*,(100),min", "0c626e8a-9b82-b6d4-d9a3-578509316301"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); c.DefineDerivedCounter("DSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has domain shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,12,ifnotzero,16,ifnotzero,(0),1,5,13,ifnotzero,17,ifnotzero,max,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max", "2f3f7561-0549-2232-536d-129ffc5f7703"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2856); internal_counters.push_back(3053); internal_counters.push_back(3250); internal_counters.push_back(3447); internal_counters.push_back(2881); internal_counters.push_back(3078); internal_counters.push_back(3275); internal_counters.push_back(3472); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2887); internal_counters.push_back(3084); internal_counters.push_back(3281); internal_counters.push_back(3478); internal_counters.push_back(2909); internal_counters.push_back(3106); internal_counters.push_back(3303); internal_counters.push_back(3500); internal_counters.push_back(49743); c.DefineDerivedCounter("DSTime", "Timing", "Time domain shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,13,ifnotzero,17,ifnotzero,(0),2,6,14,ifnotzero,18,ifnotzero,max,(0),3,7,15,ifnotzero,19,ifnotzero,max,(0),4,8,16,ifnotzero,20,ifnotzero,max,21,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "bfe28947-c727-8a9f-aa59-c218e58bfba5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); internal_counters.push_back(49743); c.DefineDerivedCounter("GSBusy", "Timing", "The percentage of time the ShaderUnit has geometry shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*,(100),min", "876f36d8-d046-833f-7832-673cbffd0a45"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); c.DefineDerivedCounter("GSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has geometry shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "48203b6b-8983-c067-d63e-05da8be5111b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2872); internal_counters.push_back(3069); internal_counters.push_back(3266); internal_counters.push_back(3463); internal_counters.push_back(2875); internal_counters.push_back(3072); internal_counters.push_back(3269); internal_counters.push_back(3466); internal_counters.push_back(49743); c.DefineDerivedCounter("GSTime", "Timing", "Time geometry shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "c73e715f-59af-76e8-9e22-097b94c066c4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); internal_counters.push_back(49743); c.DefineDerivedCounter("PSBusy", "Timing", "The percentage of time the ShaderUnit has pixel shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,8,/,(100),*", "7e772beb-d82c-bd9a-aed0-fe504d416ce5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); c.DefineDerivedCounter("PSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has pixel shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,4,ifnotzero,(0),1,5,ifnotzero,max,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max", "b58bea04-ce8e-2984-80f4-8aba7d4c817b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2925); internal_counters.push_back(3122); internal_counters.push_back(3319); internal_counters.push_back(3516); internal_counters.push_back(2930); internal_counters.push_back(3127); internal_counters.push_back(3324); internal_counters.push_back(3521); internal_counters.push_back(49743); c.DefineDerivedCounter("PSTime", "Timing", "Time pixel shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "(0),1,5,ifnotzero,(0),2,6,ifnotzero,max,(0),3,7,ifnotzero,max,(0),4,8,ifnotzero,max,9,/,0,TS_FREQ,/,(1000000000),*,*", "edca7694-7416-e8a6-0c5a-63a5ad5f3d74"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); internal_counters.push_back(49743); c.DefineDerivedCounter("CSBusy", "Timing", "The percentage of time the ShaderUnit has compute shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,comparemax4,8,9,10,11,12,13,14,15,comparemax4,max,16,/,(100),*,(100),min", "493fdd90-8d2b-a055-5e4e-2d29c3396b8c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); c.DefineDerivedCounter("CSBusyCycles", "Timing", "Number of GPU cycles that the ShaderUnit has compute shader work to do.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,comparemax4,8,9,10,11,12,13,14,15,comparemax4,max", "39bcf1b8-f6b2-4c37-f9af-0a2bb59512f9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(51131); internal_counters.push_back(2913); internal_counters.push_back(3110); internal_counters.push_back(3307); internal_counters.push_back(3504); internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2919); internal_counters.push_back(3116); internal_counters.push_back(3313); internal_counters.push_back(3510); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); internal_counters.push_back(49743); c.DefineDerivedCounter("CSTime", "Timing", "Time compute shaders are busy in nanoseconds.", kGpaDataTypeFloat64, kGpaUsageTypeNanoseconds, internal_counters, "1,2,3,4,5,6,7,8,comparemax4,9,10,11,12,13,14,15,16,comparemax4,max,17,/,(1),min,0,TS_FREQ,/,(1000000000),*,*", "dbc24916-ecb2-7eef-8d63-7afadaaab6bc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); internal_counters.push_back(163); internal_counters.push_back(310); internal_counters.push_back(457); internal_counters.push_back(604); c.DefineDerivedCounter("VSVerticesIn", "VertexShader", "The number of vertices processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,4,5,6,7,sum4,ifnotzero,8,9,10,11,sum4,8,9,10,11,sum4,ifnotzero", "810a04c8-2ff4-081d-766d-bfa2bd4ad916"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7257); internal_counters.push_back(7556); internal_counters.push_back(7855); internal_counters.push_back(8154); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4865); internal_counters.push_back(5164); internal_counters.push_back(5463); internal_counters.push_back(5762); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9649); internal_counters.push_back(9948); internal_counters.push_back(10247); internal_counters.push_back(10546); internal_counters.push_back(9627); internal_counters.push_back(9926); internal_counters.push_back(10225); internal_counters.push_back(10524); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUInstCount", "VertexShader", "Average number of vector ALU instructions executed in the VS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,24,25,26,27,sum4,/,28,29,30,31,sum4,ifnotzero", "8ec604e4-63f5-e6b5-4558-c38f0b26d4b1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7261); internal_counters.push_back(7560); internal_counters.push_back(7859); internal_counters.push_back(8158); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4869); internal_counters.push_back(5168); internal_counters.push_back(5467); internal_counters.push_back(5766); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9653); internal_counters.push_back(9952); internal_counters.push_back(10251); internal_counters.push_back(10550); internal_counters.push_back(9627); internal_counters.push_back(9926); internal_counters.push_back(10225); internal_counters.push_back(10524); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUInstCount", "VertexShader", "Average number of scalar ALU instructions executed in the VS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,24,25,26,27,sum4,/,28,29,30,31,sum4,ifnotzero", "e3da0383-7322-7f65-8cf2-3ce641578e54"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(49743); internal_counters.push_back(9704); internal_counters.push_back(10003); internal_counters.push_back(10302); internal_counters.push_back(10601); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUBusy", "VertexShader", "The percentage of GPUTime vector ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,13,14,15,16,sum4,17,18,19,20,sum4,ifnotzero,(4),*,NUM_SIMDS,/,12,/,(100),*", "8b3572f7-fda0-eddf-6c93-2ab145b8754b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9704); internal_counters.push_back(10003); internal_counters.push_back(10302); internal_counters.push_back(10601); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSVALUBusyCycles", "VertexShader", "Number of GPU cycles where vector ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,16,17,18,19,sum4,ifnotzero,(4),*,NUM_SIMDS,/", "0af1686e-6d77-2f6e-2862-7bb8e869a776"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(49743); internal_counters.push_back(9709); internal_counters.push_back(10008); internal_counters.push_back(10307); internal_counters.push_back(10606); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUBusy", "VertexShader", "The percentage of GPUTime scalar ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,13,14,15,16,sum4,17,18,19,20,sum4,ifnotzero,NUM_CUS,/,12,/,(100),*", "3bc8730c-e3bc-e2f0-7d24-36974064c25a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9709); internal_counters.push_back(10008); internal_counters.push_back(10307); internal_counters.push_back(10606); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("VSSALUBusyCycles", "VertexShader", "Number of GPU cycles where scalar ALU instructions are being processed by the VS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,16,17,18,19,sum4,ifnotzero,NUM_CUS,/", "357ac7cd-2e1c-dcb0-77f6-37527237f35b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(172); internal_counters.push_back(319); internal_counters.push_back(466); internal_counters.push_back(613); c.DefineDerivedCounter("HSPatches", "HullShader", "The number of patches processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "d1bbd27d-d591-4509-df52-d329fb73a98f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10845); internal_counters.push_back(11144); internal_counters.push_back(11443); internal_counters.push_back(11742); internal_counters.push_back(10823); internal_counters.push_back(11122); internal_counters.push_back(11421); internal_counters.push_back(11720); c.DefineDerivedCounter("HSVALUInstCount", "HullShader", "Average number of vector ALU instructions executed in the HS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "786673bf-d58f-9895-3a37-9d6efb5e5804"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10849); internal_counters.push_back(11148); internal_counters.push_back(11447); internal_counters.push_back(11746); internal_counters.push_back(10823); internal_counters.push_back(11122); internal_counters.push_back(11421); internal_counters.push_back(11720); c.DefineDerivedCounter("HSSALUInstCount", "HullShader", "Average number of scalar ALU instructions executed in the HS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "1af675c4-cb0b-c4c5-c131-2796750f683e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10900); internal_counters.push_back(11199); internal_counters.push_back(11498); internal_counters.push_back(11797); internal_counters.push_back(49743); c.DefineDerivedCounter("HSVALUBusy", "HullShader", "The percentage of GPUTime vector ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "7880d192-8015-0311-d43e-fb0b7a4df179"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10900); internal_counters.push_back(11199); internal_counters.push_back(11498); internal_counters.push_back(11797); c.DefineDerivedCounter("HSVALUBusyCycles", "HullShader", "Number of GPU cycles vector where ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "3afb94e4-e937-5730-0cc9-41d3113ba012"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10905); internal_counters.push_back(11204); internal_counters.push_back(11503); internal_counters.push_back(11802); internal_counters.push_back(49743); c.DefineDerivedCounter("HSSALUBusy", "HullShader", "The percentage of GPUTime scalar ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "34748a4b-9148-0b06-b7b9-5700d6631bde"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(10905); internal_counters.push_back(11204); internal_counters.push_back(11503); internal_counters.push_back(11802); c.DefineDerivedCounter("HSSALUBusyCycles", "HullShader", "Number of GPU cycles where scalar ALU instructions are being processed by the HS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "9bceabf7-3f01-2fd9-7b1d-8fe46c729efc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); internal_counters.push_back(163); internal_counters.push_back(310); internal_counters.push_back(457); internal_counters.push_back(604); c.DefineDerivedCounter("DSVerticesIn", "DomainShader", "The number of vertices processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,4,5,6,7,sum4,ifnotzero,8,9,10,11,sum4,ifnotzero", "b88d9d05-2418-e639-4e3d-3a5815855f8d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7257); internal_counters.push_back(7556); internal_counters.push_back(7855); internal_counters.push_back(8154); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4865); internal_counters.push_back(5164); internal_counters.push_back(5463); internal_counters.push_back(5762); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUInstCount", "DomainShader", "Average number of vector ALU instructions executed in the DS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,ifnotzero", "03a3e949-82f9-be4d-7228-5eb5ad80915a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7261); internal_counters.push_back(7560); internal_counters.push_back(7859); internal_counters.push_back(8158); internal_counters.push_back(7235); internal_counters.push_back(7534); internal_counters.push_back(7833); internal_counters.push_back(8132); internal_counters.push_back(4869); internal_counters.push_back(5168); internal_counters.push_back(5467); internal_counters.push_back(5766); internal_counters.push_back(4843); internal_counters.push_back(5142); internal_counters.push_back(5441); internal_counters.push_back(5740); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUInstCount", "DomainShader", "Average number of scalar ALU instructions executed in the DS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,sum4,12,13,14,15,sum4,/,16,17,18,19,sum4,ifnotzero,20,21,22,23,sum4,ifnotzero", "73daa728-483e-95d0-5b40-504719aadc1c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(49743); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUBusy", "DomainShader", "The percentage of GPUTime vector ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,9,10,11,12,sum4,ifnotzero,13,14,15,16,sum4,ifnotzero,(4),*,NUM_SIMDS,/,8,/,(100),*", "ddc0dd0c-0c73-b831-a410-cfea8b9713d9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7312); internal_counters.push_back(7611); internal_counters.push_back(7910); internal_counters.push_back(8209); internal_counters.push_back(4920); internal_counters.push_back(5219); internal_counters.push_back(5518); internal_counters.push_back(5817); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSVALUBusyCycles", "DomainShader", "Number of GPU cycles where vector ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,ifnotzero,(4),*,NUM_SIMDS,/", "1e280912-81ee-a684-823b-94c468d8ebda"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(49743); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUBusy", "DomainShader", "The percentage of GPUTime scalar ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,9,10,11,12,sum4,ifnotzero,13,14,15,16,sum4,ifnotzero,NUM_CUS,/,8,/,(100),*", "b639f64c-24af-348f-6439-43c701b4fc07"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(7317); internal_counters.push_back(7616); internal_counters.push_back(7915); internal_counters.push_back(8214); internal_counters.push_back(4925); internal_counters.push_back(5224); internal_counters.push_back(5523); internal_counters.push_back(5822); internal_counters.push_back(4853); internal_counters.push_back(5152); internal_counters.push_back(5451); internal_counters.push_back(5750); internal_counters.push_back(9637); internal_counters.push_back(9936); internal_counters.push_back(10235); internal_counters.push_back(10534); c.DefineDerivedCounter("DSSALUBusyCycles", "DomainShader", "Number of GPU cycles where scalar ALU instructions are being processed by the DS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,ifnotzero,12,13,14,15,sum4,ifnotzero,NUM_CUS,/", "b5bf8a0c-e682-1aa6-23d7-c6c6784ffa5c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(76); internal_counters.push_back(223); internal_counters.push_back(370); internal_counters.push_back(517); c.DefineDerivedCounter("GSPrimsIn", "GeometryShader", "The number of primitives passed into the GS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "20c29866-509a-aaab-2697-6b2c38f79953"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(87); internal_counters.push_back(234); internal_counters.push_back(381); internal_counters.push_back(528); internal_counters.push_back(68); internal_counters.push_back(215); internal_counters.push_back(362); internal_counters.push_back(509); c.DefineDerivedCounter("GSVerticesOut", "GeometryShader", "The number of vertices output by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,ifnotzero", "775b9736-319a-bd8a-48c9-68db9c91d978"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6061); internal_counters.push_back(6360); internal_counters.push_back(6659); internal_counters.push_back(6958); internal_counters.push_back(6039); internal_counters.push_back(6338); internal_counters.push_back(6637); internal_counters.push_back(6936); c.DefineDerivedCounter("GSVALUInstCount", "GeometryShader", "Average number of vector ALU instructions executed in the GS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "21b12bfa-b8cd-2e71-a2d5-f9e9f1d65d61"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6065); internal_counters.push_back(6364); internal_counters.push_back(6663); internal_counters.push_back(6962); internal_counters.push_back(6039); internal_counters.push_back(6338); internal_counters.push_back(6637); internal_counters.push_back(6936); c.DefineDerivedCounter("GSSALUInstCount", "GeometryShader", "Average number of scalar ALU instructions executed in the GS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "a8562594-d335-ca43-61bf-03b72d2b98a5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6116); internal_counters.push_back(6415); internal_counters.push_back(6714); internal_counters.push_back(7013); internal_counters.push_back(49743); c.DefineDerivedCounter("GSVALUBusy", "GeometryShader", "The percentage of GPUTime vector ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "228a4818-1e56-cebb-0720-3b2cdc057a6f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6116); internal_counters.push_back(6415); internal_counters.push_back(6714); internal_counters.push_back(7013); c.DefineDerivedCounter("GSVALUBusyCycles", "GeometryShader", "Number of GPU cycles where vector ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "be217edd-226f-bd97-9a48-46e2809b1933"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6121); internal_counters.push_back(6420); internal_counters.push_back(6719); internal_counters.push_back(7018); internal_counters.push_back(49743); c.DefineDerivedCounter("GSSALUBusy", "GeometryShader", "The percentage of GPUTime scalar ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "f28ce300-800e-9822-39e4-f48528bdb935"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(6121); internal_counters.push_back(6420); internal_counters.push_back(6719); internal_counters.push_back(7018); c.DefineDerivedCounter("GSSALUBusyCycles", "GeometryShader", "Number of GPU cycles where scalar ALU instructions are being processed by the GS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "b3eace7c-3bc4-0107-887f-923851dc8ea7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(760); internal_counters.push_back(913); internal_counters.push_back(1066); internal_counters.push_back(1219); internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(716); internal_counters.push_back(869); internal_counters.push_back(1022); internal_counters.push_back(1175); internal_counters.push_back(728); internal_counters.push_back(881); internal_counters.push_back(1034); internal_counters.push_back(1187); internal_counters.push_back(717); internal_counters.push_back(870); internal_counters.push_back(1023); internal_counters.push_back(1176); internal_counters.push_back(729); internal_counters.push_back(882); internal_counters.push_back(1035); internal_counters.push_back(1188); internal_counters.push_back(49743); c.DefineDerivedCounter("PrimitiveAssemblyBusy", "Timing", "The percentage of GPUTime that primitive assembly (clipping and culling) is busy. High values may be caused by having many small primitives; mid to low values may indicate pixel shader or output buffer bottleneck.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,4,-,8,12,+,16,+,20,(2),*,+,SU_CLOCKS_PRIM,*,-,1,5,-,9,13,+,17,+,21,(2),*,+,SU_CLOCKS_PRIM,*,-,max,2,6,-,10,14,+,18,+,22,(2),*,+,SU_CLOCKS_PRIM,*,-,max,3,7,-,11,15,+,19,+,23,(2),*,+,SU_CLOCKS_PRIM,*,-,max,(0),max,24,/,(100),*,(100),min", "54ac5640-c4d7-95e2-20e0-6a9fdfc07333"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(760); internal_counters.push_back(913); internal_counters.push_back(1066); internal_counters.push_back(1219); internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(716); internal_counters.push_back(869); internal_counters.push_back(1022); internal_counters.push_back(1175); internal_counters.push_back(728); internal_counters.push_back(881); internal_counters.push_back(1034); internal_counters.push_back(1187); internal_counters.push_back(717); internal_counters.push_back(870); internal_counters.push_back(1023); internal_counters.push_back(1176); internal_counters.push_back(729); internal_counters.push_back(882); internal_counters.push_back(1035); internal_counters.push_back(1188); c.DefineDerivedCounter("PrimitiveAssemblyBusyCycles", "Timing", "Number of GPU cycles the primitive assembly (clipping and culling) is busy. High values may be caused by having many small primitives; mid to low values may indicate pixel shader or output buffer bottleneck.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,4,-,8,12,+,16,+,20,(2),*,+,SU_CLOCKS_PRIM,*,-,1,5,-,9,13,+,17,+,21,(2),*,+,SU_CLOCKS_PRIM,*,-,max,2,6,-,10,14,+,18,+,22,(2),*,+,SU_CLOCKS_PRIM,*,-,max,3,7,-,11,15,+,19,+,23,(2),*,+,SU_CLOCKS_PRIM,*,-,max,(0),max", "99777f2d-9626-c78a-a97c-c4505eba1e5f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(663); internal_counters.push_back(816); internal_counters.push_back(969); internal_counters.push_back(1122); c.DefineDerivedCounter("PrimitivesIn", "PrimitiveAssembly", "The number of primitives received by the hardware. This includes primitives generated by tessellation.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "a515b80d-75c3-c7d2-0d2f-d7766b4759a6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(669); internal_counters.push_back(822); internal_counters.push_back(975); internal_counters.push_back(1128); internal_counters.push_back(709); internal_counters.push_back(862); internal_counters.push_back(1015); internal_counters.push_back(1168); internal_counters.push_back(710); internal_counters.push_back(863); internal_counters.push_back(1016); internal_counters.push_back(1169); internal_counters.push_back(711); internal_counters.push_back(864); internal_counters.push_back(1017); internal_counters.push_back(1170); internal_counters.push_back(712); internal_counters.push_back(865); internal_counters.push_back(1018); internal_counters.push_back(1171); c.DefineDerivedCounter("CulledPrims", "PrimitiveAssembly", "The number of culled primitives. Typical reasons include scissor, the primitive having zero area, and back or front face culling.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,+,2,+,3,+,4,+,5,+,6,+,7,+,8,+,9,+,10,+,11,+,12,+,13,+,14,+,15,+,16,+,17,+,18,+,19,+", "589bdf55-9192-280a-41c3-584bc94f2562"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(676); internal_counters.push_back(829); internal_counters.push_back(982); internal_counters.push_back(1135); c.DefineDerivedCounter("ClippedPrims", "PrimitiveAssembly", "The number of primitives that required one or more clipping operations due to intersecting the view volume or user clip planes.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "5ef6f9d5-155e-5baa-163f-8359d9ea9bbf"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); internal_counters.push_back(49743); c.DefineDerivedCounter("PAStalledOnRasterizer", "PrimitiveAssembly", "Percentage of GPUTime that primitive assembly waits for rasterization to be ready to accept data. This roughly indicates for what percentage of time the pipeline is bottlenecked by pixel operations.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,/,(100),*", "6f9f416b-53c1-0457-f88c-7b6ba8973974"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(764); internal_counters.push_back(917); internal_counters.push_back(1070); internal_counters.push_back(1223); c.DefineDerivedCounter("PAStalledOnRasterizerCycles", "PrimitiveAssembly", "Number of GPU cycles the primitive assembly waits for rasterization to be ready to accept data. Indicates the number of GPU cycles the pipeline is bottlenecked by pixel operations.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max", "7a8c492a-c566-9328-6805-760dbff5c0f2"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13223); internal_counters.push_back(13257); internal_counters.push_back(13291); internal_counters.push_back(13325); internal_counters.push_back(13228); internal_counters.push_back(13262); internal_counters.push_back(13296); internal_counters.push_back(13330); internal_counters.push_back(13233); internal_counters.push_back(13267); internal_counters.push_back(13301); internal_counters.push_back(13335); internal_counters.push_back(13238); internal_counters.push_back(13272); internal_counters.push_back(13306); internal_counters.push_back(13340); c.DefineDerivedCounter("PSPixelsOut", "PixelShader", "Pixels exported from shader to color buffers. Does not include killed or alpha tested pixels; if there are multiple render targets, each render target receives one export, so this will be 2 for 1 pixel written to two RTs.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,8,9,10,11,sum4,12,13,14,15,sum4,sum4", "24cba16c-baa6-6ecd-95ad-92ecb1338da1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13225); internal_counters.push_back(13259); internal_counters.push_back(13293); internal_counters.push_back(13327); internal_counters.push_back(13230); internal_counters.push_back(13264); internal_counters.push_back(13298); internal_counters.push_back(13332); internal_counters.push_back(13235); internal_counters.push_back(13269); internal_counters.push_back(13303); internal_counters.push_back(13337); internal_counters.push_back(13240); internal_counters.push_back(13274); internal_counters.push_back(13308); internal_counters.push_back(13342); internal_counters.push_back(49743); c.DefineDerivedCounter("PSExportStalls", "PixelShader", "Pixel shader output stalls. Percentage of GPUBusy. Should be zero for PS or further upstream limited cases; if not zero, indicates a bottleneck in late Z testing or in the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,max,2,max,3,max,4,max,5,max,6,max,7,max,8,max,9,max,10,max,11,max,12,max,13,max,14,max,15,max,16,/,(100),*", "9b4f466c-ff97-22bb-557d-84d3c4c51895"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13225); internal_counters.push_back(13259); internal_counters.push_back(13293); internal_counters.push_back(13327); internal_counters.push_back(13230); internal_counters.push_back(13264); internal_counters.push_back(13298); internal_counters.push_back(13332); internal_counters.push_back(13235); internal_counters.push_back(13269); internal_counters.push_back(13303); internal_counters.push_back(13337); internal_counters.push_back(13240); internal_counters.push_back(13274); internal_counters.push_back(13308); internal_counters.push_back(13342); c.DefineDerivedCounter("PSExportStallsCycles", "PixelShader", "Number of GPU cycles the pixel shader output stalls. Should be zero for PS or further upstream limited cases; if not zero, indicates a bottleneck in late Z testing or in the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,max,2,max,3,max,4,max,5,max,6,max,7,max,8,max,9,max,10,max,11,max,12,max,13,max,14,max,15,max", "47c72aad-64e6-0864-d533-d8e0bc27c156"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8453); internal_counters.push_back(8752); internal_counters.push_back(9051); internal_counters.push_back(9350); internal_counters.push_back(8431); internal_counters.push_back(8730); internal_counters.push_back(9029); internal_counters.push_back(9328); c.DefineDerivedCounter("PSVALUInstCount", "PixelShader", "Average number of vector ALU instructions executed in the PS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "eb74389e-435c-4137-ecf1-39eb5bc1cbfe"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8457); internal_counters.push_back(8756); internal_counters.push_back(9055); internal_counters.push_back(9354); internal_counters.push_back(8431); internal_counters.push_back(8730); internal_counters.push_back(9029); internal_counters.push_back(9328); c.DefineDerivedCounter("PSSALUInstCount", "PixelShader", "Average number of scalar ALU instructions executed in the PS. Affected by flow control.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4,4,5,6,7,sum4,/", "e6a06580-8a82-96d6-976c-acc121fc5516"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8508); internal_counters.push_back(8807); internal_counters.push_back(9106); internal_counters.push_back(9405); internal_counters.push_back(49743); c.DefineDerivedCounter("PSVALUBusy", "PixelShader", "The percentage of GPUTime vector ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*", "6ce6fef7-8e33-10b4-f351-af755e177e85"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8508); internal_counters.push_back(8807); internal_counters.push_back(9106); internal_counters.push_back(9405); c.DefineDerivedCounter("PSVALUBusyCycles", "PixelShader", "Number of GPU cycles where vector ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,(4),*,NUM_SIMDS,/", "1e276f86-cd2a-72e7-fc9d-004f666f2981"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8513); internal_counters.push_back(8812); internal_counters.push_back(9111); internal_counters.push_back(9410); internal_counters.push_back(49743); c.DefineDerivedCounter("PSSALUBusy", "PixelShader", "The percentage of GPUTime scalar ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*", "2ff9f34f-e94b-af4d-18c2-5fbbf6d1727a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(8513); internal_counters.push_back(8812); internal_counters.push_back(9111); internal_counters.push_back(9410); c.DefineDerivedCounter("PSSALUBusyCycles", "PixelShader", "Number of GPU cycles where scalar ALU instructions are being processed by the PS.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,sum4,NUM_CUS,/", "29808906-f128-b078-fc79-820a4b3b3b8d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSThreadGroups", "ComputeShader", "Total number of thread groups.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,sum8", "8ce3fc80-56b2-97f9-8e70-2e8c747cea68"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2917); internal_counters.push_back(3114); internal_counters.push_back(3311); internal_counters.push_back(3508); internal_counters.push_back(2923); internal_counters.push_back(3120); internal_counters.push_back(3317); internal_counters.push_back(3514); c.DefineDerivedCounter("CSWavefronts", "ComputeShader", "The total number of wavefronts used for the CS.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,sum8", "42379c6e-369b-c237-8b25-cdb9cdc65c4d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); internal_counters.push_back(12029); internal_counters.push_back(12328); internal_counters.push_back(12627); internal_counters.push_back(12926); c.DefineDerivedCounter("CSThreads", "ComputeShader", "The number of CS threads processed by the hardware.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,4,5,6,7,sum8,8,9,10,11,sum4,ifnotzero", "7a648013-6eac-2665-ac36-13c6f4ac9c26"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12041); internal_counters.push_back(12340); internal_counters.push_back(12639); internal_counters.push_back(12938); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUInsts", "ComputeShader", "The average number of vector ALU instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "376cb1cc-5a40-9d1d-404c-f1736c0c5084"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12104); internal_counters.push_back(12403); internal_counters.push_back(12702); internal_counters.push_back(13001); internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUUtilization", "ComputeShader", "The percentage of active vector ALU threads in a wave. A lower number can mean either more thread divergence in a wave or that the work-group size is not a multiple of 64. Value range: 0% (bad), 100% (ideal - no thread divergence).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,(64),*,/,(100),*,8,9,10,11,12,13,14,15,sum8,ifnotzero,(100),min", "4476879e-cdc0-d602-b24e-9b4a8d38438f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12045); internal_counters.push_back(12344); internal_counters.push_back(12643); internal_counters.push_back(12942); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUInsts", "ComputeShader", "The average number of scalar ALU instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "eb211144-8136-ff86-e8bf-4d0493a904cb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12043); internal_counters.push_back(12342); internal_counters.push_back(12641); internal_counters.push_back(12940); internal_counters.push_back(13448); internal_counters.push_back(13567); internal_counters.push_back(13686); internal_counters.push_back(13805); internal_counters.push_back(13924); internal_counters.push_back(14043); internal_counters.push_back(14162); internal_counters.push_back(14281); internal_counters.push_back(14400); internal_counters.push_back(14519); internal_counters.push_back(14638); internal_counters.push_back(14757); internal_counters.push_back(14876); internal_counters.push_back(14995); internal_counters.push_back(15114); internal_counters.push_back(15233); internal_counters.push_back(15352); internal_counters.push_back(15471); internal_counters.push_back(15590); internal_counters.push_back(15709); internal_counters.push_back(15828); internal_counters.push_back(15947); internal_counters.push_back(16066); internal_counters.push_back(16185); internal_counters.push_back(16304); internal_counters.push_back(16423); internal_counters.push_back(16542); internal_counters.push_back(16661); internal_counters.push_back(16780); internal_counters.push_back(16899); internal_counters.push_back(17018); internal_counters.push_back(17137); internal_counters.push_back(17256); internal_counters.push_back(17375); internal_counters.push_back(17494); internal_counters.push_back(17613); internal_counters.push_back(17732); internal_counters.push_back(17851); internal_counters.push_back(17970); internal_counters.push_back(18089); internal_counters.push_back(18208); internal_counters.push_back(18327); internal_counters.push_back(18446); internal_counters.push_back(18565); internal_counters.push_back(18684); internal_counters.push_back(18803); internal_counters.push_back(18922); internal_counters.push_back(19041); internal_counters.push_back(19160); internal_counters.push_back(19279); internal_counters.push_back(19398); internal_counters.push_back(19517); internal_counters.push_back(19636); internal_counters.push_back(19755); internal_counters.push_back(19874); internal_counters.push_back(19993); internal_counters.push_back(20112); internal_counters.push_back(20231); internal_counters.push_back(20350); internal_counters.push_back(20469); internal_counters.push_back(20588); internal_counters.push_back(20707); internal_counters.push_back(20826); internal_counters.push_back(20945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVFetchInsts", "ComputeShader", "The average number of vector fetch instructions from the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,sum64,-,68,69,70,71,sum4,/,72,73,74,75,76,77,78,79,sum8,ifnotzero", "3e2829c0-6215-783b-c271-6d57ff2c520e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12046); internal_counters.push_back(12345); internal_counters.push_back(12644); internal_counters.push_back(12943); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSFetchInsts", "ComputeShader", "The average number of scalar fetch instructions from the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "da09171c-6a0a-584f-fddc-dc5062d63a3e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12042); internal_counters.push_back(12341); internal_counters.push_back(12640); internal_counters.push_back(12939); internal_counters.push_back(13449); internal_counters.push_back(13568); internal_counters.push_back(13687); internal_counters.push_back(13806); internal_counters.push_back(13925); internal_counters.push_back(14044); internal_counters.push_back(14163); internal_counters.push_back(14282); internal_counters.push_back(14401); internal_counters.push_back(14520); internal_counters.push_back(14639); internal_counters.push_back(14758); internal_counters.push_back(14877); internal_counters.push_back(14996); internal_counters.push_back(15115); internal_counters.push_back(15234); internal_counters.push_back(15353); internal_counters.push_back(15472); internal_counters.push_back(15591); internal_counters.push_back(15710); internal_counters.push_back(15829); internal_counters.push_back(15948); internal_counters.push_back(16067); internal_counters.push_back(16186); internal_counters.push_back(16305); internal_counters.push_back(16424); internal_counters.push_back(16543); internal_counters.push_back(16662); internal_counters.push_back(16781); internal_counters.push_back(16900); internal_counters.push_back(17019); internal_counters.push_back(17138); internal_counters.push_back(17257); internal_counters.push_back(17376); internal_counters.push_back(17495); internal_counters.push_back(17614); internal_counters.push_back(17733); internal_counters.push_back(17852); internal_counters.push_back(17971); internal_counters.push_back(18090); internal_counters.push_back(18209); internal_counters.push_back(18328); internal_counters.push_back(18447); internal_counters.push_back(18566); internal_counters.push_back(18685); internal_counters.push_back(18804); internal_counters.push_back(18923); internal_counters.push_back(19042); internal_counters.push_back(19161); internal_counters.push_back(19280); internal_counters.push_back(19399); internal_counters.push_back(19518); internal_counters.push_back(19637); internal_counters.push_back(19756); internal_counters.push_back(19875); internal_counters.push_back(19994); internal_counters.push_back(20113); internal_counters.push_back(20232); internal_counters.push_back(20351); internal_counters.push_back(20470); internal_counters.push_back(20589); internal_counters.push_back(20708); internal_counters.push_back(20827); internal_counters.push_back(20946); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVWriteInsts", "ComputeShader", "The average number of vector write instructions to the video memory executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,sum64,-,68,69,70,71,sum4,/,72,73,74,75,76,77,78,79,sum8,ifnotzero", "43438c22-e910-b377-b767-b32902e0df0d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12047); internal_counters.push_back(12346); internal_counters.push_back(12645); internal_counters.push_back(12944); internal_counters.push_back(12048); internal_counters.push_back(12347); internal_counters.push_back(12646); internal_counters.push_back(12945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSFlatVMemInsts", "ComputeShader", "The average number of FLAT instructions that read from or write to the video memory executed per work item (affected by flow control). Includes FLAT instructions that read from or write to scratch.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,-,8,9,10,11,sum4,/,12,13,14,15,16,17,18,19,sum8,ifnotzero", "2570b477-13e3-f5b6-e6ff-7159373bc74d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUBusy", "ComputeShader", "The percentage of GPUTime vector ALU instructions are processed. Value range: 0% (bad) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "f1e64815-f6a8-c277-d4f9-d054b443e205"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12096); internal_counters.push_back(12395); internal_counters.push_back(12694); internal_counters.push_back(12993); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSVALUBusyCycles", "ComputeShader", "Number of GPU cycles where vector ALU instructions are processed.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,(4),*,NUM_SIMDS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "2d0d5852-2658-eb73-68d2-f23f7118c9c3"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12101); internal_counters.push_back(12400); internal_counters.push_back(12699); internal_counters.push_back(12998); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUBusy", "ComputeShader", "The percentage of GPUTime scalar ALU instructions are processed. Value range: 0% (bad) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,NUM_CUS,/,4,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "3fc35f4e-9882-94e3-6f5f-4e81cd97082a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12101); internal_counters.push_back(12400); internal_counters.push_back(12699); internal_counters.push_back(12998); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSSALUBusyCycles", "ComputeShader", "Number of GPU cycles where scalar ALU instructions are processed.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_CUS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "de58f8fc-8ed4-a799-648d-62ded7b1c4c4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitBusy", "ComputeShader", "The percentage of GPUTime the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account. Value range: 0% to 100% (fetch-bound).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,/,(100),*,65,66,67,68,69,70,71,72,sum8,ifnotzero", "42ab96e1-0a24-96c8-c4ff-098fa267d78e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitBusyCycles", "ComputeShader", "Number of GPU cycles the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,65,66,67,68,69,70,71,sum8,ifnotzero", "39d5687f-c727-7c0c-af82-bb711d3897ed"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitStalled", "ComputeShader", "The percentage of GPUTime the memory unit is stalled. Try reducing the number or size of fetches and writes if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,/,(100),*,65,66,67,68,69,70,71,72,sum8,ifnotzero", "f18e8679-1511-d533-d9ee-4365197f7d0c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSMemUnitStalledCycles", "ComputeShader", "Number of GPU cycles the memory unit is stalled. Try reducing the number or size of fetches and writes if possible.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,65,66,67,68,69,70,71,sum8,ifnotzero", "51991c84-ed2b-bf31-c4ab-8f8e9eb8f29f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSWriteUnitStalled", "ComputeShader", "The percentage of GPUTime the write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*,17,18,19,20,21,22,23,24,sum8,ifnotzero", "55118f7a-8f92-726f-78c6-407f689a2eb4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSWriteUnitStalledCycles", "ComputeShader", "Number of GPU cycles the write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,17,18,19,20,21,22,23,sum8,ifnotzero", "be164c60-5e48-acac-9622-29616d09aa9a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12050); internal_counters.push_back(12349); internal_counters.push_back(12648); internal_counters.push_back(12947); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSGDSInsts", "ComputeShader", "The average number of GDS read or GDS write instructions executed per work item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "2a867f3e-4a37-ad16-55d1-f03d74707819"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12049); internal_counters.push_back(12348); internal_counters.push_back(12647); internal_counters.push_back(12946); internal_counters.push_back(12047); internal_counters.push_back(12346); internal_counters.push_back(12645); internal_counters.push_back(12944); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSInsts", "ComputeShader", "The average number of LDS read/write instructions executed per work-item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,-,8,9,10,11,sum4,/,12,13,14,15,16,17,18,19,sum8,ifnotzero", "61b0b351-7e06-ef8e-a8e0-7a9e3200a836"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12048); internal_counters.push_back(12347); internal_counters.push_back(12646); internal_counters.push_back(12945); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSFlatLDSInsts", "ComputeShader", "The average number of FLAT instructions that read from or write to LDS executed per work item (affected by flow control).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,9,10,11,12,13,14,15,sum8,ifnotzero", "99672cda-de2b-014c-482e-cf73b90068d5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12076); internal_counters.push_back(12375); internal_counters.push_back(12674); internal_counters.push_back(12973); internal_counters.push_back(12019); internal_counters.push_back(12318); internal_counters.push_back(12617); internal_counters.push_back(12916); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSALUStalledByLDS", "ComputeShader", "The percentage of GPUTime ALU units are stalled by the LDS input queue being full or the output queue being not ready. If there are LDS bank conflicts, reduce them. Otherwise, try reducing the number of LDS accesses if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,5,6,7,sum4,/,8,/,NUM_SHADER_ENGINES,/,(100),*,9,10,11,12,13,14,15,16,sum8,ifnotzero", "6dc4f1c2-bad0-c9ff-156e-883b319a752a"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12076); internal_counters.push_back(12375); internal_counters.push_back(12674); internal_counters.push_back(12973); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSALUStalledByLDSCycles", "ComputeShader", "Number of GPU cycles the ALU units are stalled by the LDS input queue being full or the output queue being not ready. If there are LDS bank conflicts, reduce them. Otherwise, try reducing the number of LDS accesses if possible.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_SHADER_ENGINES,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "8f3d5f25-2159-0374-fafe-e26a7799b6c8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12112); internal_counters.push_back(12411); internal_counters.push_back(12710); internal_counters.push_back(13009); internal_counters.push_back(49743); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSBankConflict", "ComputeShader", "The percentage of GPUTime LDS is stalled by bank conflicts. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "(0),0,1,2,3,sum4,4,/,NUM_SIMDS,/,(100),*,5,6,7,8,9,10,11,12,sum8,ifnotzero", "1065ee10-2e41-ea41-1eb3-b61b491752f4"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(12112); internal_counters.push_back(12411); internal_counters.push_back(12710); internal_counters.push_back(13009); internal_counters.push_back(2914); internal_counters.push_back(3111); internal_counters.push_back(3308); internal_counters.push_back(3505); internal_counters.push_back(2920); internal_counters.push_back(3117); internal_counters.push_back(3314); internal_counters.push_back(3511); c.DefineDerivedCounter("CSLDSBankConflictCycles", "ComputeShader", "Number of GPU cycles the LDS is stalled by bank conflicts. Value range: 0 (optimal) to GPUBusyCycles (bad).", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "(0),0,1,2,3,sum4,NUM_SIMDS,/,4,5,6,7,8,9,10,11,sum8,ifnotzero", "1fd1adf3-c51e-94fd-083e-c482a0a0809e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); c.DefineDerivedCounter("TexUnitBusy", "Timing", "The percentage of GPUTime the texture unit is active. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,/,(100),*", "36afb8d9-42fc-aafe-66c5-449542153b2c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); c.DefineDerivedCounter("TexUnitBusyCycles", "Timing", "Number of GPU cycles the texture unit is active. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64", "c68761f2-248c-4f39-6528-c308b1c0807c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13416); internal_counters.push_back(13535); internal_counters.push_back(13654); internal_counters.push_back(13773); internal_counters.push_back(13892); internal_counters.push_back(14011); internal_counters.push_back(14130); internal_counters.push_back(14249); internal_counters.push_back(14368); internal_counters.push_back(14487); internal_counters.push_back(14606); internal_counters.push_back(14725); internal_counters.push_back(14844); internal_counters.push_back(14963); internal_counters.push_back(15082); internal_counters.push_back(15201); internal_counters.push_back(15320); internal_counters.push_back(15439); internal_counters.push_back(15558); internal_counters.push_back(15677); internal_counters.push_back(15796); internal_counters.push_back(15915); internal_counters.push_back(16034); internal_counters.push_back(16153); internal_counters.push_back(16272); internal_counters.push_back(16391); internal_counters.push_back(16510); internal_counters.push_back(16629); internal_counters.push_back(16748); internal_counters.push_back(16867); internal_counters.push_back(16986); internal_counters.push_back(17105); internal_counters.push_back(17224); internal_counters.push_back(17343); internal_counters.push_back(17462); internal_counters.push_back(17581); internal_counters.push_back(17700); internal_counters.push_back(17819); internal_counters.push_back(17938); internal_counters.push_back(18057); internal_counters.push_back(18176); internal_counters.push_back(18295); internal_counters.push_back(18414); internal_counters.push_back(18533); internal_counters.push_back(18652); internal_counters.push_back(18771); internal_counters.push_back(18890); internal_counters.push_back(19009); internal_counters.push_back(19128); internal_counters.push_back(19247); internal_counters.push_back(19366); internal_counters.push_back(19485); internal_counters.push_back(19604); internal_counters.push_back(19723); internal_counters.push_back(19842); internal_counters.push_back(19961); internal_counters.push_back(20080); internal_counters.push_back(20199); internal_counters.push_back(20318); internal_counters.push_back(20437); internal_counters.push_back(20556); internal_counters.push_back(20675); internal_counters.push_back(20794); internal_counters.push_back(20913); internal_counters.push_back(13415); internal_counters.push_back(13534); internal_counters.push_back(13653); internal_counters.push_back(13772); internal_counters.push_back(13891); internal_counters.push_back(14010); internal_counters.push_back(14129); internal_counters.push_back(14248); internal_counters.push_back(14367); internal_counters.push_back(14486); internal_counters.push_back(14605); internal_counters.push_back(14724); internal_counters.push_back(14843); internal_counters.push_back(14962); internal_counters.push_back(15081); internal_counters.push_back(15200); internal_counters.push_back(15319); internal_counters.push_back(15438); internal_counters.push_back(15557); internal_counters.push_back(15676); internal_counters.push_back(15795); internal_counters.push_back(15914); internal_counters.push_back(16033); internal_counters.push_back(16152); internal_counters.push_back(16271); internal_counters.push_back(16390); internal_counters.push_back(16509); internal_counters.push_back(16628); internal_counters.push_back(16747); internal_counters.push_back(16866); internal_counters.push_back(16985); internal_counters.push_back(17104); internal_counters.push_back(17223); internal_counters.push_back(17342); internal_counters.push_back(17461); internal_counters.push_back(17580); internal_counters.push_back(17699); internal_counters.push_back(17818); internal_counters.push_back(17937); internal_counters.push_back(18056); internal_counters.push_back(18175); internal_counters.push_back(18294); internal_counters.push_back(18413); internal_counters.push_back(18532); internal_counters.push_back(18651); internal_counters.push_back(18770); internal_counters.push_back(18889); internal_counters.push_back(19008); internal_counters.push_back(19127); internal_counters.push_back(19246); internal_counters.push_back(19365); internal_counters.push_back(19484); internal_counters.push_back(19603); internal_counters.push_back(19722); internal_counters.push_back(19841); internal_counters.push_back(19960); internal_counters.push_back(20079); internal_counters.push_back(20198); internal_counters.push_back(20317); internal_counters.push_back(20436); internal_counters.push_back(20555); internal_counters.push_back(20674); internal_counters.push_back(20793); internal_counters.push_back(20912); c.DefineDerivedCounter("TexTriFilteringPct", "TextureUnit", "Percentage of pixels that received trilinear filtering. Note that not all pixels for which trilinear filtering is enabled will receive it (e.g. if the texture is magnified).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,sum64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,+,/,(100),*", "1affc3c8-b917-5c81-622b-7004527208ae"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13416); internal_counters.push_back(13535); internal_counters.push_back(13654); internal_counters.push_back(13773); internal_counters.push_back(13892); internal_counters.push_back(14011); internal_counters.push_back(14130); internal_counters.push_back(14249); internal_counters.push_back(14368); internal_counters.push_back(14487); internal_counters.push_back(14606); internal_counters.push_back(14725); internal_counters.push_back(14844); internal_counters.push_back(14963); internal_counters.push_back(15082); internal_counters.push_back(15201); internal_counters.push_back(15320); internal_counters.push_back(15439); internal_counters.push_back(15558); internal_counters.push_back(15677); internal_counters.push_back(15796); internal_counters.push_back(15915); internal_counters.push_back(16034); internal_counters.push_back(16153); internal_counters.push_back(16272); internal_counters.push_back(16391); internal_counters.push_back(16510); internal_counters.push_back(16629); internal_counters.push_back(16748); internal_counters.push_back(16867); internal_counters.push_back(16986); internal_counters.push_back(17105); internal_counters.push_back(17224); internal_counters.push_back(17343); internal_counters.push_back(17462); internal_counters.push_back(17581); internal_counters.push_back(17700); internal_counters.push_back(17819); internal_counters.push_back(17938); internal_counters.push_back(18057); internal_counters.push_back(18176); internal_counters.push_back(18295); internal_counters.push_back(18414); internal_counters.push_back(18533); internal_counters.push_back(18652); internal_counters.push_back(18771); internal_counters.push_back(18890); internal_counters.push_back(19009); internal_counters.push_back(19128); internal_counters.push_back(19247); internal_counters.push_back(19366); internal_counters.push_back(19485); internal_counters.push_back(19604); internal_counters.push_back(19723); internal_counters.push_back(19842); internal_counters.push_back(19961); internal_counters.push_back(20080); internal_counters.push_back(20199); internal_counters.push_back(20318); internal_counters.push_back(20437); internal_counters.push_back(20556); internal_counters.push_back(20675); internal_counters.push_back(20794); internal_counters.push_back(20913); c.DefineDerivedCounter("TexTriFilteringCount", "TextureUnit", "Count of pixels that received trilinear filtering. Note that not all pixels for which trilinear filtering is enabled will receive it (e.g. if the texture is magnified).", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64", "5785b3a1-a513-18db-4b1c-bdeef75bb2b6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13415); internal_counters.push_back(13534); internal_counters.push_back(13653); internal_counters.push_back(13772); internal_counters.push_back(13891); internal_counters.push_back(14010); internal_counters.push_back(14129); internal_counters.push_back(14248); internal_counters.push_back(14367); internal_counters.push_back(14486); internal_counters.push_back(14605); internal_counters.push_back(14724); internal_counters.push_back(14843); internal_counters.push_back(14962); internal_counters.push_back(15081); internal_counters.push_back(15200); internal_counters.push_back(15319); internal_counters.push_back(15438); internal_counters.push_back(15557); internal_counters.push_back(15676); internal_counters.push_back(15795); internal_counters.push_back(15914); internal_counters.push_back(16033); internal_counters.push_back(16152); internal_counters.push_back(16271); internal_counters.push_back(16390); internal_counters.push_back(16509); internal_counters.push_back(16628); internal_counters.push_back(16747); internal_counters.push_back(16866); internal_counters.push_back(16985); internal_counters.push_back(17104); internal_counters.push_back(17223); internal_counters.push_back(17342); internal_counters.push_back(17461); internal_counters.push_back(17580); internal_counters.push_back(17699); internal_counters.push_back(17818); internal_counters.push_back(17937); internal_counters.push_back(18056); internal_counters.push_back(18175); internal_counters.push_back(18294); internal_counters.push_back(18413); internal_counters.push_back(18532); internal_counters.push_back(18651); internal_counters.push_back(18770); internal_counters.push_back(18889); internal_counters.push_back(19008); internal_counters.push_back(19127); internal_counters.push_back(19246); internal_counters.push_back(19365); internal_counters.push_back(19484); internal_counters.push_back(19603); internal_counters.push_back(19722); internal_counters.push_back(19841); internal_counters.push_back(19960); internal_counters.push_back(20079); internal_counters.push_back(20198); internal_counters.push_back(20317); internal_counters.push_back(20436); internal_counters.push_back(20555); internal_counters.push_back(20674); internal_counters.push_back(20793); internal_counters.push_back(20912); c.DefineDerivedCounter("NoTexTriFilteringCount", "TextureUnit", "Count of pixels that did not receive trilinear filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64", "179da29a-81af-c06e-ce8c-a0a731ea030d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13418); internal_counters.push_back(13537); internal_counters.push_back(13656); internal_counters.push_back(13775); internal_counters.push_back(13894); internal_counters.push_back(14013); internal_counters.push_back(14132); internal_counters.push_back(14251); internal_counters.push_back(14370); internal_counters.push_back(14489); internal_counters.push_back(14608); internal_counters.push_back(14727); internal_counters.push_back(14846); internal_counters.push_back(14965); internal_counters.push_back(15084); internal_counters.push_back(15203); internal_counters.push_back(15322); internal_counters.push_back(15441); internal_counters.push_back(15560); internal_counters.push_back(15679); internal_counters.push_back(15798); internal_counters.push_back(15917); internal_counters.push_back(16036); internal_counters.push_back(16155); internal_counters.push_back(16274); internal_counters.push_back(16393); internal_counters.push_back(16512); internal_counters.push_back(16631); internal_counters.push_back(16750); internal_counters.push_back(16869); internal_counters.push_back(16988); internal_counters.push_back(17107); internal_counters.push_back(17226); internal_counters.push_back(17345); internal_counters.push_back(17464); internal_counters.push_back(17583); internal_counters.push_back(17702); internal_counters.push_back(17821); internal_counters.push_back(17940); internal_counters.push_back(18059); internal_counters.push_back(18178); internal_counters.push_back(18297); internal_counters.push_back(18416); internal_counters.push_back(18535); internal_counters.push_back(18654); internal_counters.push_back(18773); internal_counters.push_back(18892); internal_counters.push_back(19011); internal_counters.push_back(19130); internal_counters.push_back(19249); internal_counters.push_back(19368); internal_counters.push_back(19487); internal_counters.push_back(19606); internal_counters.push_back(19725); internal_counters.push_back(19844); internal_counters.push_back(19963); internal_counters.push_back(20082); internal_counters.push_back(20201); internal_counters.push_back(20320); internal_counters.push_back(20439); internal_counters.push_back(20558); internal_counters.push_back(20677); internal_counters.push_back(20796); internal_counters.push_back(20915); internal_counters.push_back(13417); internal_counters.push_back(13536); internal_counters.push_back(13655); internal_counters.push_back(13774); internal_counters.push_back(13893); internal_counters.push_back(14012); internal_counters.push_back(14131); internal_counters.push_back(14250); internal_counters.push_back(14369); internal_counters.push_back(14488); internal_counters.push_back(14607); internal_counters.push_back(14726); internal_counters.push_back(14845); internal_counters.push_back(14964); internal_counters.push_back(15083); internal_counters.push_back(15202); internal_counters.push_back(15321); internal_counters.push_back(15440); internal_counters.push_back(15559); internal_counters.push_back(15678); internal_counters.push_back(15797); internal_counters.push_back(15916); internal_counters.push_back(16035); internal_counters.push_back(16154); internal_counters.push_back(16273); internal_counters.push_back(16392); internal_counters.push_back(16511); internal_counters.push_back(16630); internal_counters.push_back(16749); internal_counters.push_back(16868); internal_counters.push_back(16987); internal_counters.push_back(17106); internal_counters.push_back(17225); internal_counters.push_back(17344); internal_counters.push_back(17463); internal_counters.push_back(17582); internal_counters.push_back(17701); internal_counters.push_back(17820); internal_counters.push_back(17939); internal_counters.push_back(18058); internal_counters.push_back(18177); internal_counters.push_back(18296); internal_counters.push_back(18415); internal_counters.push_back(18534); internal_counters.push_back(18653); internal_counters.push_back(18772); internal_counters.push_back(18891); internal_counters.push_back(19010); internal_counters.push_back(19129); internal_counters.push_back(19248); internal_counters.push_back(19367); internal_counters.push_back(19486); internal_counters.push_back(19605); internal_counters.push_back(19724); internal_counters.push_back(19843); internal_counters.push_back(19962); internal_counters.push_back(20081); internal_counters.push_back(20200); internal_counters.push_back(20319); internal_counters.push_back(20438); internal_counters.push_back(20557); internal_counters.push_back(20676); internal_counters.push_back(20795); internal_counters.push_back(20914); c.DefineDerivedCounter("TexVolFilteringPct", "TextureUnit", "Percentage of pixels that received volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,sum64,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,+,/,(100),*", "b5ff6bed-3178-aee4-42dd-c74391c02a2d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13418); internal_counters.push_back(13537); internal_counters.push_back(13656); internal_counters.push_back(13775); internal_counters.push_back(13894); internal_counters.push_back(14013); internal_counters.push_back(14132); internal_counters.push_back(14251); internal_counters.push_back(14370); internal_counters.push_back(14489); internal_counters.push_back(14608); internal_counters.push_back(14727); internal_counters.push_back(14846); internal_counters.push_back(14965); internal_counters.push_back(15084); internal_counters.push_back(15203); internal_counters.push_back(15322); internal_counters.push_back(15441); internal_counters.push_back(15560); internal_counters.push_back(15679); internal_counters.push_back(15798); internal_counters.push_back(15917); internal_counters.push_back(16036); internal_counters.push_back(16155); internal_counters.push_back(16274); internal_counters.push_back(16393); internal_counters.push_back(16512); internal_counters.push_back(16631); internal_counters.push_back(16750); internal_counters.push_back(16869); internal_counters.push_back(16988); internal_counters.push_back(17107); internal_counters.push_back(17226); internal_counters.push_back(17345); internal_counters.push_back(17464); internal_counters.push_back(17583); internal_counters.push_back(17702); internal_counters.push_back(17821); internal_counters.push_back(17940); internal_counters.push_back(18059); internal_counters.push_back(18178); internal_counters.push_back(18297); internal_counters.push_back(18416); internal_counters.push_back(18535); internal_counters.push_back(18654); internal_counters.push_back(18773); internal_counters.push_back(18892); internal_counters.push_back(19011); internal_counters.push_back(19130); internal_counters.push_back(19249); internal_counters.push_back(19368); internal_counters.push_back(19487); internal_counters.push_back(19606); internal_counters.push_back(19725); internal_counters.push_back(19844); internal_counters.push_back(19963); internal_counters.push_back(20082); internal_counters.push_back(20201); internal_counters.push_back(20320); internal_counters.push_back(20439); internal_counters.push_back(20558); internal_counters.push_back(20677); internal_counters.push_back(20796); internal_counters.push_back(20915); c.DefineDerivedCounter("TexVolFilteringCount", "TextureUnit", "Count of pixels that received volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64", "4bddc587-d589-8128-e18c-762eab2c871f"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13417); internal_counters.push_back(13536); internal_counters.push_back(13655); internal_counters.push_back(13774); internal_counters.push_back(13893); internal_counters.push_back(14012); internal_counters.push_back(14131); internal_counters.push_back(14250); internal_counters.push_back(14369); internal_counters.push_back(14488); internal_counters.push_back(14607); internal_counters.push_back(14726); internal_counters.push_back(14845); internal_counters.push_back(14964); internal_counters.push_back(15083); internal_counters.push_back(15202); internal_counters.push_back(15321); internal_counters.push_back(15440); internal_counters.push_back(15559); internal_counters.push_back(15678); internal_counters.push_back(15797); internal_counters.push_back(15916); internal_counters.push_back(16035); internal_counters.push_back(16154); internal_counters.push_back(16273); internal_counters.push_back(16392); internal_counters.push_back(16511); internal_counters.push_back(16630); internal_counters.push_back(16749); internal_counters.push_back(16868); internal_counters.push_back(16987); internal_counters.push_back(17106); internal_counters.push_back(17225); internal_counters.push_back(17344); internal_counters.push_back(17463); internal_counters.push_back(17582); internal_counters.push_back(17701); internal_counters.push_back(17820); internal_counters.push_back(17939); internal_counters.push_back(18058); internal_counters.push_back(18177); internal_counters.push_back(18296); internal_counters.push_back(18415); internal_counters.push_back(18534); internal_counters.push_back(18653); internal_counters.push_back(18772); internal_counters.push_back(18891); internal_counters.push_back(19010); internal_counters.push_back(19129); internal_counters.push_back(19248); internal_counters.push_back(19367); internal_counters.push_back(19486); internal_counters.push_back(19605); internal_counters.push_back(19724); internal_counters.push_back(19843); internal_counters.push_back(19962); internal_counters.push_back(20081); internal_counters.push_back(20200); internal_counters.push_back(20319); internal_counters.push_back(20438); internal_counters.push_back(20557); internal_counters.push_back(20676); internal_counters.push_back(20795); internal_counters.push_back(20914); c.DefineDerivedCounter("NoTexVolFilteringCount", "TextureUnit", "Count of pixels that did not receive volume filtering.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64", "9fe1a854-17c6-9d26-b2b9-80610cd5827d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13436); internal_counters.push_back(13555); internal_counters.push_back(13674); internal_counters.push_back(13793); internal_counters.push_back(13912); internal_counters.push_back(14031); internal_counters.push_back(14150); internal_counters.push_back(14269); internal_counters.push_back(14388); internal_counters.push_back(14507); internal_counters.push_back(14626); internal_counters.push_back(14745); internal_counters.push_back(14864); internal_counters.push_back(14983); internal_counters.push_back(15102); internal_counters.push_back(15221); internal_counters.push_back(15340); internal_counters.push_back(15459); internal_counters.push_back(15578); internal_counters.push_back(15697); internal_counters.push_back(15816); internal_counters.push_back(15935); internal_counters.push_back(16054); internal_counters.push_back(16173); internal_counters.push_back(16292); internal_counters.push_back(16411); internal_counters.push_back(16530); internal_counters.push_back(16649); internal_counters.push_back(16768); internal_counters.push_back(16887); internal_counters.push_back(17006); internal_counters.push_back(17125); internal_counters.push_back(17244); internal_counters.push_back(17363); internal_counters.push_back(17482); internal_counters.push_back(17601); internal_counters.push_back(17720); internal_counters.push_back(17839); internal_counters.push_back(17958); internal_counters.push_back(18077); internal_counters.push_back(18196); internal_counters.push_back(18315); internal_counters.push_back(18434); internal_counters.push_back(18553); internal_counters.push_back(18672); internal_counters.push_back(18791); internal_counters.push_back(18910); internal_counters.push_back(19029); internal_counters.push_back(19148); internal_counters.push_back(19267); internal_counters.push_back(19386); internal_counters.push_back(19505); internal_counters.push_back(19624); internal_counters.push_back(19743); internal_counters.push_back(19862); internal_counters.push_back(19981); internal_counters.push_back(20100); internal_counters.push_back(20219); internal_counters.push_back(20338); internal_counters.push_back(20457); internal_counters.push_back(20576); internal_counters.push_back(20695); internal_counters.push_back(20814); internal_counters.push_back(20933); internal_counters.push_back(13437); internal_counters.push_back(13556); internal_counters.push_back(13675); internal_counters.push_back(13794); internal_counters.push_back(13913); internal_counters.push_back(14032); internal_counters.push_back(14151); internal_counters.push_back(14270); internal_counters.push_back(14389); internal_counters.push_back(14508); internal_counters.push_back(14627); internal_counters.push_back(14746); internal_counters.push_back(14865); internal_counters.push_back(14984); internal_counters.push_back(15103); internal_counters.push_back(15222); internal_counters.push_back(15341); internal_counters.push_back(15460); internal_counters.push_back(15579); internal_counters.push_back(15698); internal_counters.push_back(15817); internal_counters.push_back(15936); internal_counters.push_back(16055); internal_counters.push_back(16174); internal_counters.push_back(16293); internal_counters.push_back(16412); internal_counters.push_back(16531); internal_counters.push_back(16650); internal_counters.push_back(16769); internal_counters.push_back(16888); internal_counters.push_back(17007); internal_counters.push_back(17126); internal_counters.push_back(17245); internal_counters.push_back(17364); internal_counters.push_back(17483); internal_counters.push_back(17602); internal_counters.push_back(17721); internal_counters.push_back(17840); internal_counters.push_back(17959); internal_counters.push_back(18078); internal_counters.push_back(18197); internal_counters.push_back(18316); internal_counters.push_back(18435); internal_counters.push_back(18554); internal_counters.push_back(18673); internal_counters.push_back(18792); internal_counters.push_back(18911); internal_counters.push_back(19030); internal_counters.push_back(19149); internal_counters.push_back(19268); internal_counters.push_back(19387); internal_counters.push_back(19506); internal_counters.push_back(19625); internal_counters.push_back(19744); internal_counters.push_back(19863); internal_counters.push_back(19982); internal_counters.push_back(20101); internal_counters.push_back(20220); internal_counters.push_back(20339); internal_counters.push_back(20458); internal_counters.push_back(20577); internal_counters.push_back(20696); internal_counters.push_back(20815); internal_counters.push_back(20934); internal_counters.push_back(13438); internal_counters.push_back(13557); internal_counters.push_back(13676); internal_counters.push_back(13795); internal_counters.push_back(13914); internal_counters.push_back(14033); internal_counters.push_back(14152); internal_counters.push_back(14271); internal_counters.push_back(14390); internal_counters.push_back(14509); internal_counters.push_back(14628); internal_counters.push_back(14747); internal_counters.push_back(14866); internal_counters.push_back(14985); internal_counters.push_back(15104); internal_counters.push_back(15223); internal_counters.push_back(15342); internal_counters.push_back(15461); internal_counters.push_back(15580); internal_counters.push_back(15699); internal_counters.push_back(15818); internal_counters.push_back(15937); internal_counters.push_back(16056); internal_counters.push_back(16175); internal_counters.push_back(16294); internal_counters.push_back(16413); internal_counters.push_back(16532); internal_counters.push_back(16651); internal_counters.push_back(16770); internal_counters.push_back(16889); internal_counters.push_back(17008); internal_counters.push_back(17127); internal_counters.push_back(17246); internal_counters.push_back(17365); internal_counters.push_back(17484); internal_counters.push_back(17603); internal_counters.push_back(17722); internal_counters.push_back(17841); internal_counters.push_back(17960); internal_counters.push_back(18079); internal_counters.push_back(18198); internal_counters.push_back(18317); internal_counters.push_back(18436); internal_counters.push_back(18555); internal_counters.push_back(18674); internal_counters.push_back(18793); internal_counters.push_back(18912); internal_counters.push_back(19031); internal_counters.push_back(19150); internal_counters.push_back(19269); internal_counters.push_back(19388); internal_counters.push_back(19507); internal_counters.push_back(19626); internal_counters.push_back(19745); internal_counters.push_back(19864); internal_counters.push_back(19983); internal_counters.push_back(20102); internal_counters.push_back(20221); internal_counters.push_back(20340); internal_counters.push_back(20459); internal_counters.push_back(20578); internal_counters.push_back(20697); internal_counters.push_back(20816); internal_counters.push_back(20935); internal_counters.push_back(13439); internal_counters.push_back(13558); internal_counters.push_back(13677); internal_counters.push_back(13796); internal_counters.push_back(13915); internal_counters.push_back(14034); internal_counters.push_back(14153); internal_counters.push_back(14272); internal_counters.push_back(14391); internal_counters.push_back(14510); internal_counters.push_back(14629); internal_counters.push_back(14748); internal_counters.push_back(14867); internal_counters.push_back(14986); internal_counters.push_back(15105); internal_counters.push_back(15224); internal_counters.push_back(15343); internal_counters.push_back(15462); internal_counters.push_back(15581); internal_counters.push_back(15700); internal_counters.push_back(15819); internal_counters.push_back(15938); internal_counters.push_back(16057); internal_counters.push_back(16176); internal_counters.push_back(16295); internal_counters.push_back(16414); internal_counters.push_back(16533); internal_counters.push_back(16652); internal_counters.push_back(16771); internal_counters.push_back(16890); internal_counters.push_back(17009); internal_counters.push_back(17128); internal_counters.push_back(17247); internal_counters.push_back(17366); internal_counters.push_back(17485); internal_counters.push_back(17604); internal_counters.push_back(17723); internal_counters.push_back(17842); internal_counters.push_back(17961); internal_counters.push_back(18080); internal_counters.push_back(18199); internal_counters.push_back(18318); internal_counters.push_back(18437); internal_counters.push_back(18556); internal_counters.push_back(18675); internal_counters.push_back(18794); internal_counters.push_back(18913); internal_counters.push_back(19032); internal_counters.push_back(19151); internal_counters.push_back(19270); internal_counters.push_back(19389); internal_counters.push_back(19508); internal_counters.push_back(19627); internal_counters.push_back(19746); internal_counters.push_back(19865); internal_counters.push_back(19984); internal_counters.push_back(20103); internal_counters.push_back(20222); internal_counters.push_back(20341); internal_counters.push_back(20460); internal_counters.push_back(20579); internal_counters.push_back(20698); internal_counters.push_back(20817); internal_counters.push_back(20936); internal_counters.push_back(13440); internal_counters.push_back(13559); internal_counters.push_back(13678); internal_counters.push_back(13797); internal_counters.push_back(13916); internal_counters.push_back(14035); internal_counters.push_back(14154); internal_counters.push_back(14273); internal_counters.push_back(14392); internal_counters.push_back(14511); internal_counters.push_back(14630); internal_counters.push_back(14749); internal_counters.push_back(14868); internal_counters.push_back(14987); internal_counters.push_back(15106); internal_counters.push_back(15225); internal_counters.push_back(15344); internal_counters.push_back(15463); internal_counters.push_back(15582); internal_counters.push_back(15701); internal_counters.push_back(15820); internal_counters.push_back(15939); internal_counters.push_back(16058); internal_counters.push_back(16177); internal_counters.push_back(16296); internal_counters.push_back(16415); internal_counters.push_back(16534); internal_counters.push_back(16653); internal_counters.push_back(16772); internal_counters.push_back(16891); internal_counters.push_back(17010); internal_counters.push_back(17129); internal_counters.push_back(17248); internal_counters.push_back(17367); internal_counters.push_back(17486); internal_counters.push_back(17605); internal_counters.push_back(17724); internal_counters.push_back(17843); internal_counters.push_back(17962); internal_counters.push_back(18081); internal_counters.push_back(18200); internal_counters.push_back(18319); internal_counters.push_back(18438); internal_counters.push_back(18557); internal_counters.push_back(18676); internal_counters.push_back(18795); internal_counters.push_back(18914); internal_counters.push_back(19033); internal_counters.push_back(19152); internal_counters.push_back(19271); internal_counters.push_back(19390); internal_counters.push_back(19509); internal_counters.push_back(19628); internal_counters.push_back(19747); internal_counters.push_back(19866); internal_counters.push_back(19985); internal_counters.push_back(20104); internal_counters.push_back(20223); internal_counters.push_back(20342); internal_counters.push_back(20461); internal_counters.push_back(20580); internal_counters.push_back(20699); internal_counters.push_back(20818); internal_counters.push_back(20937); internal_counters.push_back(13441); internal_counters.push_back(13560); internal_counters.push_back(13679); internal_counters.push_back(13798); internal_counters.push_back(13917); internal_counters.push_back(14036); internal_counters.push_back(14155); internal_counters.push_back(14274); internal_counters.push_back(14393); internal_counters.push_back(14512); internal_counters.push_back(14631); internal_counters.push_back(14750); internal_counters.push_back(14869); internal_counters.push_back(14988); internal_counters.push_back(15107); internal_counters.push_back(15226); internal_counters.push_back(15345); internal_counters.push_back(15464); internal_counters.push_back(15583); internal_counters.push_back(15702); internal_counters.push_back(15821); internal_counters.push_back(15940); internal_counters.push_back(16059); internal_counters.push_back(16178); internal_counters.push_back(16297); internal_counters.push_back(16416); internal_counters.push_back(16535); internal_counters.push_back(16654); internal_counters.push_back(16773); internal_counters.push_back(16892); internal_counters.push_back(17011); internal_counters.push_back(17130); internal_counters.push_back(17249); internal_counters.push_back(17368); internal_counters.push_back(17487); internal_counters.push_back(17606); internal_counters.push_back(17725); internal_counters.push_back(17844); internal_counters.push_back(17963); internal_counters.push_back(18082); internal_counters.push_back(18201); internal_counters.push_back(18320); internal_counters.push_back(18439); internal_counters.push_back(18558); internal_counters.push_back(18677); internal_counters.push_back(18796); internal_counters.push_back(18915); internal_counters.push_back(19034); internal_counters.push_back(19153); internal_counters.push_back(19272); internal_counters.push_back(19391); internal_counters.push_back(19510); internal_counters.push_back(19629); internal_counters.push_back(19748); internal_counters.push_back(19867); internal_counters.push_back(19986); internal_counters.push_back(20105); internal_counters.push_back(20224); internal_counters.push_back(20343); internal_counters.push_back(20462); internal_counters.push_back(20581); internal_counters.push_back(20700); internal_counters.push_back(20819); internal_counters.push_back(20938); internal_counters.push_back(13442); internal_counters.push_back(13561); internal_counters.push_back(13680); internal_counters.push_back(13799); internal_counters.push_back(13918); internal_counters.push_back(14037); internal_counters.push_back(14156); internal_counters.push_back(14275); internal_counters.push_back(14394); internal_counters.push_back(14513); internal_counters.push_back(14632); internal_counters.push_back(14751); internal_counters.push_back(14870); internal_counters.push_back(14989); internal_counters.push_back(15108); internal_counters.push_back(15227); internal_counters.push_back(15346); internal_counters.push_back(15465); internal_counters.push_back(15584); internal_counters.push_back(15703); internal_counters.push_back(15822); internal_counters.push_back(15941); internal_counters.push_back(16060); internal_counters.push_back(16179); internal_counters.push_back(16298); internal_counters.push_back(16417); internal_counters.push_back(16536); internal_counters.push_back(16655); internal_counters.push_back(16774); internal_counters.push_back(16893); internal_counters.push_back(17012); internal_counters.push_back(17131); internal_counters.push_back(17250); internal_counters.push_back(17369); internal_counters.push_back(17488); internal_counters.push_back(17607); internal_counters.push_back(17726); internal_counters.push_back(17845); internal_counters.push_back(17964); internal_counters.push_back(18083); internal_counters.push_back(18202); internal_counters.push_back(18321); internal_counters.push_back(18440); internal_counters.push_back(18559); internal_counters.push_back(18678); internal_counters.push_back(18797); internal_counters.push_back(18916); internal_counters.push_back(19035); internal_counters.push_back(19154); internal_counters.push_back(19273); internal_counters.push_back(19392); internal_counters.push_back(19511); internal_counters.push_back(19630); internal_counters.push_back(19749); internal_counters.push_back(19868); internal_counters.push_back(19987); internal_counters.push_back(20106); internal_counters.push_back(20225); internal_counters.push_back(20344); internal_counters.push_back(20463); internal_counters.push_back(20582); internal_counters.push_back(20701); internal_counters.push_back(20820); internal_counters.push_back(20939); internal_counters.push_back(13443); internal_counters.push_back(13562); internal_counters.push_back(13681); internal_counters.push_back(13800); internal_counters.push_back(13919); internal_counters.push_back(14038); internal_counters.push_back(14157); internal_counters.push_back(14276); internal_counters.push_back(14395); internal_counters.push_back(14514); internal_counters.push_back(14633); internal_counters.push_back(14752); internal_counters.push_back(14871); internal_counters.push_back(14990); internal_counters.push_back(15109); internal_counters.push_back(15228); internal_counters.push_back(15347); internal_counters.push_back(15466); internal_counters.push_back(15585); internal_counters.push_back(15704); internal_counters.push_back(15823); internal_counters.push_back(15942); internal_counters.push_back(16061); internal_counters.push_back(16180); internal_counters.push_back(16299); internal_counters.push_back(16418); internal_counters.push_back(16537); internal_counters.push_back(16656); internal_counters.push_back(16775); internal_counters.push_back(16894); internal_counters.push_back(17013); internal_counters.push_back(17132); internal_counters.push_back(17251); internal_counters.push_back(17370); internal_counters.push_back(17489); internal_counters.push_back(17608); internal_counters.push_back(17727); internal_counters.push_back(17846); internal_counters.push_back(17965); internal_counters.push_back(18084); internal_counters.push_back(18203); internal_counters.push_back(18322); internal_counters.push_back(18441); internal_counters.push_back(18560); internal_counters.push_back(18679); internal_counters.push_back(18798); internal_counters.push_back(18917); internal_counters.push_back(19036); internal_counters.push_back(19155); internal_counters.push_back(19274); internal_counters.push_back(19393); internal_counters.push_back(19512); internal_counters.push_back(19631); internal_counters.push_back(19750); internal_counters.push_back(19869); internal_counters.push_back(19988); internal_counters.push_back(20107); internal_counters.push_back(20226); internal_counters.push_back(20345); internal_counters.push_back(20464); internal_counters.push_back(20583); internal_counters.push_back(20702); internal_counters.push_back(20821); internal_counters.push_back(20940); internal_counters.push_back(13444); internal_counters.push_back(13563); internal_counters.push_back(13682); internal_counters.push_back(13801); internal_counters.push_back(13920); internal_counters.push_back(14039); internal_counters.push_back(14158); internal_counters.push_back(14277); internal_counters.push_back(14396); internal_counters.push_back(14515); internal_counters.push_back(14634); internal_counters.push_back(14753); internal_counters.push_back(14872); internal_counters.push_back(14991); internal_counters.push_back(15110); internal_counters.push_back(15229); internal_counters.push_back(15348); internal_counters.push_back(15467); internal_counters.push_back(15586); internal_counters.push_back(15705); internal_counters.push_back(15824); internal_counters.push_back(15943); internal_counters.push_back(16062); internal_counters.push_back(16181); internal_counters.push_back(16300); internal_counters.push_back(16419); internal_counters.push_back(16538); internal_counters.push_back(16657); internal_counters.push_back(16776); internal_counters.push_back(16895); internal_counters.push_back(17014); internal_counters.push_back(17133); internal_counters.push_back(17252); internal_counters.push_back(17371); internal_counters.push_back(17490); internal_counters.push_back(17609); internal_counters.push_back(17728); internal_counters.push_back(17847); internal_counters.push_back(17966); internal_counters.push_back(18085); internal_counters.push_back(18204); internal_counters.push_back(18323); internal_counters.push_back(18442); internal_counters.push_back(18561); internal_counters.push_back(18680); internal_counters.push_back(18799); internal_counters.push_back(18918); internal_counters.push_back(19037); internal_counters.push_back(19156); internal_counters.push_back(19275); internal_counters.push_back(19394); internal_counters.push_back(19513); internal_counters.push_back(19632); internal_counters.push_back(19751); internal_counters.push_back(19870); internal_counters.push_back(19989); internal_counters.push_back(20108); internal_counters.push_back(20227); internal_counters.push_back(20346); internal_counters.push_back(20465); internal_counters.push_back(20584); internal_counters.push_back(20703); internal_counters.push_back(20822); internal_counters.push_back(20941); c.DefineDerivedCounter("TexAveAnisotropy", "TextureUnit", "The average degree of anisotropy applied. A number between 1 and 16. The anisotropic filtering algorithm only applies samples where they are required (e.g. there will be no extra anisotropic samples if the view vector is perpendicular to the surface) so this can be much lower than the requested anisotropy.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,(2),64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,sum64,*,+,(4),128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,sum64,*,+,(6),192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,sum64,*,+,(8),256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,sum64,*,+,(10),320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,sum64,*,+,(12),384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,sum64,*,+,(14),448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,sum64,*,+,(16),512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,sum64,*,+,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,sum64,+,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,sum64,+,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,sum64,+,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,sum64,+,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,sum64,+,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,sum64,+,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,sum64,+,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,sum64,+,/", "7ca2a2b9-a4eb-ce23-d163-59147e672396"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39289); internal_counters.push_back(39546); internal_counters.push_back(39803); internal_counters.push_back(40060); internal_counters.push_back(40317); internal_counters.push_back(40574); internal_counters.push_back(40831); internal_counters.push_back(41088); internal_counters.push_back(41345); internal_counters.push_back(41602); internal_counters.push_back(41859); internal_counters.push_back(42116); internal_counters.push_back(42373); internal_counters.push_back(42630); internal_counters.push_back(42887); internal_counters.push_back(43144); internal_counters.push_back(49743); c.DefineDerivedCounter("DepthStencilTestBusy", "Timing", "Percentage of time GPU spent performing depth and stencil tests relative to GPUBusy.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "6834fb52-42e8-bb50-fd48-ec2f2904e7e0"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39289); internal_counters.push_back(39546); internal_counters.push_back(39803); internal_counters.push_back(40060); internal_counters.push_back(40317); internal_counters.push_back(40574); internal_counters.push_back(40831); internal_counters.push_back(41088); internal_counters.push_back(41345); internal_counters.push_back(41602); internal_counters.push_back(41859); internal_counters.push_back(42116); internal_counters.push_back(42373); internal_counters.push_back(42630); internal_counters.push_back(42887); internal_counters.push_back(43144); c.DefineDerivedCounter("DepthStencilTestBusyCount", "Timing", "Number of GPU cycles spent performing depth and stencil tests.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "e02860fa-c7bd-90ea-2149-69b4e98a636c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39160); internal_counters.push_back(39417); internal_counters.push_back(39674); internal_counters.push_back(39931); internal_counters.push_back(40188); internal_counters.push_back(40445); internal_counters.push_back(40702); internal_counters.push_back(40959); internal_counters.push_back(41216); internal_counters.push_back(41473); internal_counters.push_back(41730); internal_counters.push_back(41987); internal_counters.push_back(42244); internal_counters.push_back(42501); internal_counters.push_back(42758); internal_counters.push_back(43015); internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("HiZTilesAccepted", "DepthAndStencil", "Percentage of tiles accepted by HiZ and will be rendered to the depth or color buffers.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,/,(100),*", "56176f45-d7ff-813d-4f05-3b2f046067e7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("HiZTilesAcceptedCount", "DepthAndStencil", "Count of tiles accepted by HiZ and will be rendered to the depth or color buffers.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "95d4e3f6-b2f0-f26e-8423-aacdfaf79ea3"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39160); internal_counters.push_back(39417); internal_counters.push_back(39674); internal_counters.push_back(39931); internal_counters.push_back(40188); internal_counters.push_back(40445); internal_counters.push_back(40702); internal_counters.push_back(40959); internal_counters.push_back(41216); internal_counters.push_back(41473); internal_counters.push_back(41730); internal_counters.push_back(41987); internal_counters.push_back(42244); internal_counters.push_back(42501); internal_counters.push_back(42758); internal_counters.push_back(43015); c.DefineDerivedCounter("HiZTilesRejectedCount", "DepthAndStencil", "Count of tiles not accepted by HiZ.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "156ba142-7eeb-aa6e-a00a-f8aea4e41e0b"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); internal_counters.push_back(39173); internal_counters.push_back(39430); internal_counters.push_back(39687); internal_counters.push_back(39944); internal_counters.push_back(40201); internal_counters.push_back(40458); internal_counters.push_back(40715); internal_counters.push_back(40972); internal_counters.push_back(41229); internal_counters.push_back(41486); internal_counters.push_back(41743); internal_counters.push_back(42000); internal_counters.push_back(42257); internal_counters.push_back(42514); internal_counters.push_back(42771); internal_counters.push_back(43028); c.DefineDerivedCounter("PreZTilesDetailCulled", "DepthAndStencil", "Percentage of tiles rejected because the associated prim had no contributing area.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "cad7f54d-a044-7574-c472-6f2065cbeeac"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39173); internal_counters.push_back(39430); internal_counters.push_back(39687); internal_counters.push_back(39944); internal_counters.push_back(40201); internal_counters.push_back(40458); internal_counters.push_back(40715); internal_counters.push_back(40972); internal_counters.push_back(41229); internal_counters.push_back(41486); internal_counters.push_back(41743); internal_counters.push_back(42000); internal_counters.push_back(42257); internal_counters.push_back(42514); internal_counters.push_back(42771); internal_counters.push_back(43028); c.DefineDerivedCounter("PreZTilesDetailCulledCount", "DepthAndStencil", "Count of tiles rejected because the associated primitive had no contributing area.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "49262c8a-b1e6-90dd-f096-0fc4921715e9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39149); internal_counters.push_back(39406); internal_counters.push_back(39663); internal_counters.push_back(39920); internal_counters.push_back(40177); internal_counters.push_back(40434); internal_counters.push_back(40691); internal_counters.push_back(40948); internal_counters.push_back(41205); internal_counters.push_back(41462); internal_counters.push_back(41719); internal_counters.push_back(41976); internal_counters.push_back(42233); internal_counters.push_back(42490); internal_counters.push_back(42747); internal_counters.push_back(43004); c.DefineDerivedCounter("PreZTilesDetailSurvivingCount", "DepthAndStencil", "Count of tiles surviving because the associated primitive had contributing area.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "f803eaa4-bbed-bd39-775f-a64df92e2c08"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsCulled", "DepthAndStencil", "Percentage of quads that did not have to continue on in the pipeline after HiZ. They may be written directly to the depth buffer, or culled completely. Consistently low values here may suggest that the Z-range is not being fully utilized.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "fa0e319b-5573-6d34-5bab-904769925036"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsCulledCount", "DepthAndStencil", "Count of quads that did not have to continue on in the pipeline after HiZ. They may be written directly to the depth buffer, or culled completely. Consistently low values here may suggest that the Z-range is not being fully utilized.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max", "73b0b39d-6df2-3e24-0b5c-7cb0ac8b6f39"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("HiZQuadsAcceptedCount", "DepthAndStencil", "Count of quads that did continue on in the pipeline after HiZ.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "59049ad9-42b5-c7cb-3616-6a8f6a8e4894"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsCulled", "DepthAndStencil", "Percentage of quads rejected based on the detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,sum16,16,17,18,19,sum4,-,(0),max,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,/,(100),*", "4e77547b-ec55-5663-f034-af59be66d77d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsCulledCount", "DepthAndStencil", "Count of quads rejected based on the detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,sum4,+", "1bf169e6-9304-834e-df5f-0c44d7890a08"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); internal_counters.push_back(1506); internal_counters.push_back(1903); internal_counters.push_back(2300); internal_counters.push_back(2697); internal_counters.push_back(1507); internal_counters.push_back(1904); internal_counters.push_back(2301); internal_counters.push_back(2698); internal_counters.push_back(1508); internal_counters.push_back(1905); internal_counters.push_back(2302); internal_counters.push_back(2699); internal_counters.push_back(1509); internal_counters.push_back(1906); internal_counters.push_back(2303); internal_counters.push_back(2700); c.DefineDerivedCounter("PreZQuadsSurvivingCount", "DepthAndStencil", "Count of quads surviving detailZ and earlyZ tests.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,-,(0),max", "50e25e51-3713-89cb-7f92-559cde5e5532"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); internal_counters.push_back(1430); internal_counters.push_back(1827); internal_counters.push_back(2224); internal_counters.push_back(2621); internal_counters.push_back(1431); internal_counters.push_back(1828); internal_counters.push_back(2225); internal_counters.push_back(2622); internal_counters.push_back(1432); internal_counters.push_back(1829); internal_counters.push_back(2226); internal_counters.push_back(2623); internal_counters.push_back(1433); internal_counters.push_back(1830); internal_counters.push_back(2227); internal_counters.push_back(2624); c.DefineDerivedCounter("PostZQuads", "DepthAndStencil", "Percentage of quads for which the pixel shader will run and may be postZ tested.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,sum4,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,sum16,/,(100),*", "58f0d34b-eeb8-e8db-abce-cb72584144be"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(1530); internal_counters.push_back(1927); internal_counters.push_back(2324); internal_counters.push_back(2721); c.DefineDerivedCounter("PostZQuadCount", "DepthAndStencil", "Count of quads for which the pixel shader will run and may be postZ tested.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,sum4", "08404526-ce35-939b-34c8-a7a35a0ff4d6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39322); internal_counters.push_back(39579); internal_counters.push_back(39836); internal_counters.push_back(40093); internal_counters.push_back(40350); internal_counters.push_back(40607); internal_counters.push_back(40864); internal_counters.push_back(41121); internal_counters.push_back(41378); internal_counters.push_back(41635); internal_counters.push_back(41892); internal_counters.push_back(42149); internal_counters.push_back(42406); internal_counters.push_back(42663); internal_counters.push_back(42920); internal_counters.push_back(43177); c.DefineDerivedCounter("PreZSamplesPassing", "DepthAndStencil", "Number of samples tested for Z before shading and passed.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "3bfe6c4d-7422-ca03-7ea5-e67ff1a00136"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39324); internal_counters.push_back(39581); internal_counters.push_back(39838); internal_counters.push_back(40095); internal_counters.push_back(40352); internal_counters.push_back(40609); internal_counters.push_back(40866); internal_counters.push_back(41123); internal_counters.push_back(41380); internal_counters.push_back(41637); internal_counters.push_back(41894); internal_counters.push_back(42151); internal_counters.push_back(42408); internal_counters.push_back(42665); internal_counters.push_back(42922); internal_counters.push_back(43179); c.DefineDerivedCounter("PreZSamplesFailingS", "DepthAndStencil", "Number of samples tested for Z before shading and failed stencil test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "df7f705e-5162-d3b5-da8b-63466cf9c4e5"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39323); internal_counters.push_back(39580); internal_counters.push_back(39837); internal_counters.push_back(40094); internal_counters.push_back(40351); internal_counters.push_back(40608); internal_counters.push_back(40865); internal_counters.push_back(41122); internal_counters.push_back(41379); internal_counters.push_back(41636); internal_counters.push_back(41893); internal_counters.push_back(42150); internal_counters.push_back(42407); internal_counters.push_back(42664); internal_counters.push_back(42921); internal_counters.push_back(43178); c.DefineDerivedCounter("PreZSamplesFailingZ", "DepthAndStencil", "Number of samples tested for Z before shading and failed Z test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "4484e950-f7a4-3800-bc74-78dd297f017e"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39319); internal_counters.push_back(39576); internal_counters.push_back(39833); internal_counters.push_back(40090); internal_counters.push_back(40347); internal_counters.push_back(40604); internal_counters.push_back(40861); internal_counters.push_back(41118); internal_counters.push_back(41375); internal_counters.push_back(41632); internal_counters.push_back(41889); internal_counters.push_back(42146); internal_counters.push_back(42403); internal_counters.push_back(42660); internal_counters.push_back(42917); internal_counters.push_back(43174); c.DefineDerivedCounter("PostZSamplesPassing", "DepthAndStencil", "Number of samples tested for Z after shading and passed.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "4995d5d6-2330-b986-508b-fae24856f44c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39321); internal_counters.push_back(39578); internal_counters.push_back(39835); internal_counters.push_back(40092); internal_counters.push_back(40349); internal_counters.push_back(40606); internal_counters.push_back(40863); internal_counters.push_back(41120); internal_counters.push_back(41377); internal_counters.push_back(41634); internal_counters.push_back(41891); internal_counters.push_back(42148); internal_counters.push_back(42405); internal_counters.push_back(42662); internal_counters.push_back(42919); internal_counters.push_back(43176); c.DefineDerivedCounter("PostZSamplesFailingS", "DepthAndStencil", "Number of samples tested for Z after shading and failed stencil test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "ae558af4-f4be-3dd4-7316-b2c4dcf0def8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39320); internal_counters.push_back(39577); internal_counters.push_back(39834); internal_counters.push_back(40091); internal_counters.push_back(40348); internal_counters.push_back(40605); internal_counters.push_back(40862); internal_counters.push_back(41119); internal_counters.push_back(41376); internal_counters.push_back(41633); internal_counters.push_back(41890); internal_counters.push_back(42147); internal_counters.push_back(42404); internal_counters.push_back(42661); internal_counters.push_back(42918); internal_counters.push_back(43175); c.DefineDerivedCounter("PostZSamplesFailingZ", "DepthAndStencil", "Number of samples tested for Z after shading and failed Z test.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "b3684c94-814a-c695-c85d-a5b6ab798b35"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39191); internal_counters.push_back(39448); internal_counters.push_back(39705); internal_counters.push_back(39962); internal_counters.push_back(40219); internal_counters.push_back(40476); internal_counters.push_back(40733); internal_counters.push_back(40990); internal_counters.push_back(41247); internal_counters.push_back(41504); internal_counters.push_back(41761); internal_counters.push_back(42018); internal_counters.push_back(42275); internal_counters.push_back(42532); internal_counters.push_back(42789); internal_counters.push_back(43046); internal_counters.push_back(49743); c.DefineDerivedCounter("ZUnitStalled", "DepthAndStencil", "The percentage of GPUTime the depth buffer spends waiting for the color buffer to be ready to accept data. High figures here indicate a bottleneck in color buffer operations.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "5e86c3ad-1726-3157-1d01-7ed188bf854d"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39191); internal_counters.push_back(39448); internal_counters.push_back(39705); internal_counters.push_back(39962); internal_counters.push_back(40219); internal_counters.push_back(40476); internal_counters.push_back(40733); internal_counters.push_back(40990); internal_counters.push_back(41247); internal_counters.push_back(41504); internal_counters.push_back(41761); internal_counters.push_back(42018); internal_counters.push_back(42275); internal_counters.push_back(42532); internal_counters.push_back(42789); internal_counters.push_back(43046); c.DefineDerivedCounter("ZUnitStalledCycles", "DepthAndStencil", "Number of GPU cycles the depth buffer spends waiting for the color buffer to be ready to accept data. Larger numbers indicate a bottleneck in color buffer operations.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "4351fa7f-6737-2c3e-3ffb-b3addbdceedd"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39193); internal_counters.push_back(39450); internal_counters.push_back(39707); internal_counters.push_back(39964); internal_counters.push_back(40221); internal_counters.push_back(40478); internal_counters.push_back(40735); internal_counters.push_back(40992); internal_counters.push_back(41249); internal_counters.push_back(41506); internal_counters.push_back(41763); internal_counters.push_back(42020); internal_counters.push_back(42277); internal_counters.push_back(42534); internal_counters.push_back(42791); internal_counters.push_back(43048); internal_counters.push_back(39200); internal_counters.push_back(39457); internal_counters.push_back(39714); internal_counters.push_back(39971); internal_counters.push_back(40228); internal_counters.push_back(40485); internal_counters.push_back(40742); internal_counters.push_back(40999); internal_counters.push_back(41256); internal_counters.push_back(41513); internal_counters.push_back(41770); internal_counters.push_back(42027); internal_counters.push_back(42284); internal_counters.push_back(42541); internal_counters.push_back(42798); internal_counters.push_back(43055); c.DefineDerivedCounter("DBMemRead", "DepthAndStencil", "Number of bytes read from the depth buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(256),*,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,(32),*,+", "dcdb4ee7-bd50-00f7-c028-9e5f4ce888c0"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(39205); internal_counters.push_back(39462); internal_counters.push_back(39719); internal_counters.push_back(39976); internal_counters.push_back(40233); internal_counters.push_back(40490); internal_counters.push_back(40747); internal_counters.push_back(41004); internal_counters.push_back(41261); internal_counters.push_back(41518); internal_counters.push_back(41775); internal_counters.push_back(42032); internal_counters.push_back(42289); internal_counters.push_back(42546); internal_counters.push_back(42803); internal_counters.push_back(43060); internal_counters.push_back(39208); internal_counters.push_back(39465); internal_counters.push_back(39722); internal_counters.push_back(39979); internal_counters.push_back(40236); internal_counters.push_back(40493); internal_counters.push_back(40750); internal_counters.push_back(41007); internal_counters.push_back(41264); internal_counters.push_back(41521); internal_counters.push_back(41778); internal_counters.push_back(42035); internal_counters.push_back(42292); internal_counters.push_back(42549); internal_counters.push_back(42806); internal_counters.push_back(43063); c.DefineDerivedCounter("DBMemWritten", "DepthAndStencil", "Number of bytes written to the depth buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,(32),*,+", "de5717f8-8a49-ee44-4645-10de51b37dcf"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43385); internal_counters.push_back(43781); internal_counters.push_back(44177); internal_counters.push_back(44573); internal_counters.push_back(44969); internal_counters.push_back(45365); internal_counters.push_back(45761); internal_counters.push_back(46157); internal_counters.push_back(46553); internal_counters.push_back(46949); internal_counters.push_back(47345); internal_counters.push_back(47741); internal_counters.push_back(48137); internal_counters.push_back(48533); internal_counters.push_back(48929); internal_counters.push_back(49325); c.DefineDerivedCounter("CBMemRead", "ColorBuffer", "Number of bytes read from the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "84b531d8-a1f8-7f49-7c27-7bc97801f1e6"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43516); internal_counters.push_back(43912); internal_counters.push_back(44308); internal_counters.push_back(44704); internal_counters.push_back(45100); internal_counters.push_back(45496); internal_counters.push_back(45892); internal_counters.push_back(46288); internal_counters.push_back(46684); internal_counters.push_back(47080); internal_counters.push_back(47476); internal_counters.push_back(47872); internal_counters.push_back(48268); internal_counters.push_back(48664); internal_counters.push_back(49060); internal_counters.push_back(49456); internal_counters.push_back(43383); internal_counters.push_back(43779); internal_counters.push_back(44175); internal_counters.push_back(44571); internal_counters.push_back(44967); internal_counters.push_back(45363); internal_counters.push_back(45759); internal_counters.push_back(46155); internal_counters.push_back(46551); internal_counters.push_back(46947); internal_counters.push_back(47343); internal_counters.push_back(47739); internal_counters.push_back(48135); internal_counters.push_back(48531); internal_counters.push_back(48927); internal_counters.push_back(49323); internal_counters.push_back(43384); internal_counters.push_back(43780); internal_counters.push_back(44176); internal_counters.push_back(44572); internal_counters.push_back(44968); internal_counters.push_back(45364); internal_counters.push_back(45760); internal_counters.push_back(46156); internal_counters.push_back(46552); internal_counters.push_back(46948); internal_counters.push_back(47344); internal_counters.push_back(47740); internal_counters.push_back(48136); internal_counters.push_back(48532); internal_counters.push_back(48928); internal_counters.push_back(49324); internal_counters.push_back(43385); internal_counters.push_back(43781); internal_counters.push_back(44177); internal_counters.push_back(44573); internal_counters.push_back(44969); internal_counters.push_back(45365); internal_counters.push_back(45761); internal_counters.push_back(46157); internal_counters.push_back(46553); internal_counters.push_back(46949); internal_counters.push_back(47345); internal_counters.push_back(47741); internal_counters.push_back(48137); internal_counters.push_back(48533); internal_counters.push_back(48929); internal_counters.push_back(49325); c.DefineDerivedCounter("CBColorAndMaskRead", "ColorBuffer", "Total number of bytes read from the color and mask buffers.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,(32),*", "da41660e-eb6f-32ec-8a64-b32ca17bd7eb"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43375); internal_counters.push_back(43771); internal_counters.push_back(44167); internal_counters.push_back(44563); internal_counters.push_back(44959); internal_counters.push_back(45355); internal_counters.push_back(45751); internal_counters.push_back(46147); internal_counters.push_back(46543); internal_counters.push_back(46939); internal_counters.push_back(47335); internal_counters.push_back(47731); internal_counters.push_back(48127); internal_counters.push_back(48523); internal_counters.push_back(48919); internal_counters.push_back(49315); c.DefineDerivedCounter("CBMemWritten", "ColorBuffer", "Number of bytes written to the color buffer.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "550f8ff8-60b6-a6bf-87d0-25ac9e87de70"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43514); internal_counters.push_back(43910); internal_counters.push_back(44306); internal_counters.push_back(44702); internal_counters.push_back(45098); internal_counters.push_back(45494); internal_counters.push_back(45890); internal_counters.push_back(46286); internal_counters.push_back(46682); internal_counters.push_back(47078); internal_counters.push_back(47474); internal_counters.push_back(47870); internal_counters.push_back(48266); internal_counters.push_back(48662); internal_counters.push_back(49058); internal_counters.push_back(49454); internal_counters.push_back(43373); internal_counters.push_back(43769); internal_counters.push_back(44165); internal_counters.push_back(44561); internal_counters.push_back(44957); internal_counters.push_back(45353); internal_counters.push_back(45749); internal_counters.push_back(46145); internal_counters.push_back(46541); internal_counters.push_back(46937); internal_counters.push_back(47333); internal_counters.push_back(47729); internal_counters.push_back(48125); internal_counters.push_back(48521); internal_counters.push_back(48917); internal_counters.push_back(49313); internal_counters.push_back(43374); internal_counters.push_back(43770); internal_counters.push_back(44166); internal_counters.push_back(44562); internal_counters.push_back(44958); internal_counters.push_back(45354); internal_counters.push_back(45750); internal_counters.push_back(46146); internal_counters.push_back(46542); internal_counters.push_back(46938); internal_counters.push_back(47334); internal_counters.push_back(47730); internal_counters.push_back(48126); internal_counters.push_back(48522); internal_counters.push_back(48918); internal_counters.push_back(49314); internal_counters.push_back(43375); internal_counters.push_back(43771); internal_counters.push_back(44167); internal_counters.push_back(44563); internal_counters.push_back(44959); internal_counters.push_back(45355); internal_counters.push_back(45751); internal_counters.push_back(46147); internal_counters.push_back(46543); internal_counters.push_back(46939); internal_counters.push_back(47335); internal_counters.push_back(47731); internal_counters.push_back(48127); internal_counters.push_back(48523); internal_counters.push_back(48919); internal_counters.push_back(49315); c.DefineDerivedCounter("CBColorAndMaskWritten", "ColorBuffer", "Total number of bytes written to the color and mask buffers.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,sum64,(32),*", "29a04b69-8f5f-b770-a0f2-3453e2c99e49"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43419); internal_counters.push_back(43815); internal_counters.push_back(44211); internal_counters.push_back(44607); internal_counters.push_back(45003); internal_counters.push_back(45399); internal_counters.push_back(45795); internal_counters.push_back(46191); internal_counters.push_back(46587); internal_counters.push_back(46983); internal_counters.push_back(47379); internal_counters.push_back(47775); internal_counters.push_back(48171); internal_counters.push_back(48567); internal_counters.push_back(48963); internal_counters.push_back(49359); internal_counters.push_back(43264); internal_counters.push_back(43660); internal_counters.push_back(44056); internal_counters.push_back(44452); internal_counters.push_back(44848); internal_counters.push_back(45244); internal_counters.push_back(45640); internal_counters.push_back(46036); internal_counters.push_back(46432); internal_counters.push_back(46828); internal_counters.push_back(47224); internal_counters.push_back(47620); internal_counters.push_back(48016); internal_counters.push_back(48412); internal_counters.push_back(48808); internal_counters.push_back(49204); c.DefineDerivedCounter("CBSlowPixelPct", "ColorBuffer", "Percentage of pixels written to the color buffer using a half-rate or quarter-rate format.", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,/,(100),*,(100),min", "5775943f-0313-7e52-9638-b24a449197bc"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(43419); internal_counters.push_back(43815); internal_counters.push_back(44211); internal_counters.push_back(44607); internal_counters.push_back(45003); internal_counters.push_back(45399); internal_counters.push_back(45795); internal_counters.push_back(46191); internal_counters.push_back(46587); internal_counters.push_back(46983); internal_counters.push_back(47379); internal_counters.push_back(47775); internal_counters.push_back(48171); internal_counters.push_back(48567); internal_counters.push_back(48963); internal_counters.push_back(49359); c.DefineDerivedCounter("CBSlowPixelCount", "ColorBuffer", "Number of pixels written to the color buffer using a half-rate or quarter-rate format.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "47eacbb0-28c8-22b4-5c69-c00d5813bb1c"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36038); internal_counters.push_back(36230); internal_counters.push_back(36422); internal_counters.push_back(36614); internal_counters.push_back(36806); internal_counters.push_back(36998); internal_counters.push_back(37190); internal_counters.push_back(37382); internal_counters.push_back(37574); internal_counters.push_back(37766); internal_counters.push_back(37958); internal_counters.push_back(38150); internal_counters.push_back(38342); internal_counters.push_back(38534); internal_counters.push_back(38726); internal_counters.push_back(38918); c.DefineDerivedCounter("FetchSize", "GlobalMemory", "The total bytes fetched from the video memory. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "664bb3ef-6eca-86b1-1e2d-30cb897b5fa9"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36029); internal_counters.push_back(36221); internal_counters.push_back(36413); internal_counters.push_back(36605); internal_counters.push_back(36797); internal_counters.push_back(36989); internal_counters.push_back(37181); internal_counters.push_back(37373); internal_counters.push_back(37565); internal_counters.push_back(37757); internal_counters.push_back(37949); internal_counters.push_back(38141); internal_counters.push_back(38333); internal_counters.push_back(38525); internal_counters.push_back(38717); internal_counters.push_back(38909); c.DefineDerivedCounter("WriteSize", "GlobalMemory", "The total bytes written to the video memory. This is measured with all extra fetches and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeBytes, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,(32),*", "f96f2c16-b1b4-4ec4-229c-fc82e6f80a82"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheHit", "GlobalMemory", "The percentage of fetch, write, atomic, and other instructions that hit the data cache. Value range: 0% (no hit) to 100% (optimal).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,+,/,(100),*", "dfbeebab-f7c1-1211-e502-4aae361e2ad7"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheMiss", "GlobalMemory", "The percentage of fetch, write, atomic, and other instructions that miss the data cache. Value range: 0% (optimal) to 100% (all miss).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,sum16,+,/,(100),*", "aebc0a53-7f87-60bd-4c4b-2b956846ef83"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36021); internal_counters.push_back(36213); internal_counters.push_back(36405); internal_counters.push_back(36597); internal_counters.push_back(36789); internal_counters.push_back(36981); internal_counters.push_back(37173); internal_counters.push_back(37365); internal_counters.push_back(37557); internal_counters.push_back(37749); internal_counters.push_back(37941); internal_counters.push_back(38133); internal_counters.push_back(38325); internal_counters.push_back(38517); internal_counters.push_back(38709); internal_counters.push_back(38901); c.DefineDerivedCounter("CacheHitCount", "GlobalMemory", "Count of fetch, write, atomic, and other instructions that hit the data cache.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "43437652-1024-9737-2eb0-0899c0c1feae"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36022); internal_counters.push_back(36214); internal_counters.push_back(36406); internal_counters.push_back(36598); internal_counters.push_back(36790); internal_counters.push_back(36982); internal_counters.push_back(37174); internal_counters.push_back(37366); internal_counters.push_back(37558); internal_counters.push_back(37750); internal_counters.push_back(37942); internal_counters.push_back(38134); internal_counters.push_back(38326); internal_counters.push_back(38518); internal_counters.push_back(38710); internal_counters.push_back(38902); c.DefineDerivedCounter("CacheMissCount", "GlobalMemory", "Count of fetch, write, atomic, and other instructions that miss the data cache.", kGpaDataTypeFloat64, kGpaUsageTypeItems, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,sum16", "d0f8a812-f41b-644f-09d1-14ee03ea3671"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); internal_counters.push_back(49743); c.DefineDerivedCounter("MemUnitBusy", "GlobalMemory", "The percentage of GPUTime the memory unit is active. The result includes the stall time (MemUnitStalled). This is measured with all extra fetches and writes and any cache or memory effects taken into account. Value range: 0% to 100% (fetch-bound).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,/,(100),*", "a1efa380-4a72-e066-e06a-2ab71a488521"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(13362); internal_counters.push_back(13481); internal_counters.push_back(13600); internal_counters.push_back(13719); internal_counters.push_back(13838); internal_counters.push_back(13957); internal_counters.push_back(14076); internal_counters.push_back(14195); internal_counters.push_back(14314); internal_counters.push_back(14433); internal_counters.push_back(14552); internal_counters.push_back(14671); internal_counters.push_back(14790); internal_counters.push_back(14909); internal_counters.push_back(15028); internal_counters.push_back(15147); internal_counters.push_back(15266); internal_counters.push_back(15385); internal_counters.push_back(15504); internal_counters.push_back(15623); internal_counters.push_back(15742); internal_counters.push_back(15861); internal_counters.push_back(15980); internal_counters.push_back(16099); internal_counters.push_back(16218); internal_counters.push_back(16337); internal_counters.push_back(16456); internal_counters.push_back(16575); internal_counters.push_back(16694); internal_counters.push_back(16813); internal_counters.push_back(16932); internal_counters.push_back(17051); internal_counters.push_back(17170); internal_counters.push_back(17289); internal_counters.push_back(17408); internal_counters.push_back(17527); internal_counters.push_back(17646); internal_counters.push_back(17765); internal_counters.push_back(17884); internal_counters.push_back(18003); internal_counters.push_back(18122); internal_counters.push_back(18241); internal_counters.push_back(18360); internal_counters.push_back(18479); internal_counters.push_back(18598); internal_counters.push_back(18717); internal_counters.push_back(18836); internal_counters.push_back(18955); internal_counters.push_back(19074); internal_counters.push_back(19193); internal_counters.push_back(19312); internal_counters.push_back(19431); internal_counters.push_back(19550); internal_counters.push_back(19669); internal_counters.push_back(19788); internal_counters.push_back(19907); internal_counters.push_back(20026); internal_counters.push_back(20145); internal_counters.push_back(20264); internal_counters.push_back(20383); internal_counters.push_back(20502); internal_counters.push_back(20621); internal_counters.push_back(20740); internal_counters.push_back(20859); c.DefineDerivedCounter("MemUnitBusyCycles", "GlobalMemory", "Number of GPU cycles the memory unit is active. The result includes the stall time (MemUnitStalledCycles). This is measured with all extra fetches and writes and any cache or memory effects taken into account.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64", "168f077c-4797-b2f5-717f-105c725266c8"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); internal_counters.push_back(49743); c.DefineDerivedCounter("MemUnitStalled", "GlobalMemory", "The percentage of GPUTime the memory unit is stalled. Try reducing the number or size of fetches and writes if possible. Value range: 0% (optimal) to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64,64,/,(100),*", "465ba54f-d250-1453-790a-731b10d230b1"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(24486); internal_counters.push_back(24666); internal_counters.push_back(24846); internal_counters.push_back(25026); internal_counters.push_back(25206); internal_counters.push_back(25386); internal_counters.push_back(25566); internal_counters.push_back(25746); internal_counters.push_back(25926); internal_counters.push_back(26106); internal_counters.push_back(26286); internal_counters.push_back(26466); internal_counters.push_back(26646); internal_counters.push_back(26826); internal_counters.push_back(27006); internal_counters.push_back(27186); internal_counters.push_back(27366); internal_counters.push_back(27546); internal_counters.push_back(27726); internal_counters.push_back(27906); internal_counters.push_back(28086); internal_counters.push_back(28266); internal_counters.push_back(28446); internal_counters.push_back(28626); internal_counters.push_back(28806); internal_counters.push_back(28986); internal_counters.push_back(29166); internal_counters.push_back(29346); internal_counters.push_back(29526); internal_counters.push_back(29706); internal_counters.push_back(29886); internal_counters.push_back(30066); internal_counters.push_back(30246); internal_counters.push_back(30426); internal_counters.push_back(30606); internal_counters.push_back(30786); internal_counters.push_back(30966); internal_counters.push_back(31146); internal_counters.push_back(31326); internal_counters.push_back(31506); internal_counters.push_back(31686); internal_counters.push_back(31866); internal_counters.push_back(32046); internal_counters.push_back(32226); internal_counters.push_back(32406); internal_counters.push_back(32586); internal_counters.push_back(32766); internal_counters.push_back(32946); internal_counters.push_back(33126); internal_counters.push_back(33306); internal_counters.push_back(33486); internal_counters.push_back(33666); internal_counters.push_back(33846); internal_counters.push_back(34026); internal_counters.push_back(34206); internal_counters.push_back(34386); internal_counters.push_back(34566); internal_counters.push_back(34746); internal_counters.push_back(34926); internal_counters.push_back(35106); internal_counters.push_back(35286); internal_counters.push_back(35466); internal_counters.push_back(35646); internal_counters.push_back(35826); c.DefineDerivedCounter("MemUnitStalledCycles", "GlobalMemory", "Number of GPU cycles the memory unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,max64", "2745659a-0e40-bace-3b9b-86a54f8e4623"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); internal_counters.push_back(49743); c.DefineDerivedCounter("WriteUnitStalled", "GlobalMemory", "The percentage of GPUTime the Write unit is stalled. Value range: 0% to 100% (bad).", kGpaDataTypeFloat64, kGpaUsageTypePercentage, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16,16,/,(100),*", "594ad3ce-d1ec-10fc-7d59-25738e397d72"); } { vector<GpaUInt32> internal_counters; internal_counters.push_back(36031); internal_counters.push_back(36223); internal_counters.push_back(36415); internal_counters.push_back(36607); internal_counters.push_back(36799); internal_counters.push_back(36991); internal_counters.push_back(37183); internal_counters.push_back(37375); internal_counters.push_back(37567); internal_counters.push_back(37759); internal_counters.push_back(37951); internal_counters.push_back(38143); internal_counters.push_back(38335); internal_counters.push_back(38527); internal_counters.push_back(38719); internal_counters.push_back(38911); c.DefineDerivedCounter("WriteUnitStalledCycles", "GlobalMemory", "Number of GPU cycles the Write unit is stalled.", kGpaDataTypeFloat64, kGpaUsageTypeCycles, internal_counters, "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,max16", "ede3305e-abd4-d6bf-6b00-ffc57a29fce3"); } }
51.388749
5,062
0.708009
AdamJMiles
d672c802c84915fc4e0b55e4bc0f6d3631ff8741
43,112
cpp
C++
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
7
2015-03-10T03:36:16.000Z
2021-11-05T01:16:58.000Z
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
1
2020-06-23T10:02:33.000Z
2020-06-24T02:05:47.000Z
MonoNative/mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.cpp
brunolauze/MonoNative
959fb52c2c1ffe87476ab0d6e4fcce0ad9ce1e66
[ "BSD-2-Clause" ]
null
null
null
#include <mscorlib/Microsoft/Win32/mscorlib_Microsoft_Win32_RegistryKey.h> #include <mscorlib/System/mscorlib_System_String.h> #include <mscorlib/Microsoft/Win32/SafeHandles/mscorlib_Microsoft_Win32_SafeHandles_SafeRegistryHandle.h> #include <mscorlib/System/Security/AccessControl/mscorlib_System_Security_AccessControl_RegistrySecurity.h> #include <mscorlib/System/Runtime/Remoting/mscorlib_System_Runtime_Remoting_ObjRef.h> #include <mscorlib/System/mscorlib_System_Type.h> namespace mscorlib { namespace Microsoft { namespace Win32 { //Public Methods void RegistryKey::Dispose() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Dispose", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::Flush() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Flush", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::Close() { Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "Close", __native_object__, 0, NULL, NULL, NULL); } void RegistryKey::SetValue(mscorlib::System::String name, mscorlib::System::Object value) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)value; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(const char *name, mscorlib::System::Object value) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)value; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(mscorlib::System::String name, mscorlib::System::Object value, mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ valueKind) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameter_types__[2] = Global::GetType(typeid(valueKind).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)value; mscorlib::System::Int32 __param_valueKind__ = valueKind; __parameters__[2] = &__param_valueKind__; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); } void RegistryKey::SetValue(const char *name, mscorlib::System::Object value, mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ valueKind) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(value).name()); __parameter_types__[2] = Global::GetType(typeid(valueKind).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)value; mscorlib::System::Int32 __param_valueKind__ = valueKind; __parameters__[2] = &__param_valueKind__; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::System::Boolean writable) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(writable).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = reinterpret_cast<void*>(writable); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::System::Boolean writable) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(writable).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = reinterpret_cast<void*>(writable); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name, mscorlib::System::Object defaultValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)defaultValue; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name, mscorlib::System::Object defaultValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)defaultValue; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(mscorlib::System::String name, mscorlib::System::Object defaultValue, mscorlib::Microsoft::Win32::RegistryValueOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = (MonoObject*)defaultValue; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::System::Object RegistryKey::GetValue(const char *name, mscorlib::System::Object defaultValue, mscorlib::Microsoft::Win32::RegistryValueOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(defaultValue).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = (MonoObject*)defaultValue; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValue", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::System::Object(__result__); } mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ RegistryKey::GetValueKind(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueKind", __native_object__, 1, __parameter_types__, __parameters__, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__ RegistryKey::GetValueKind(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueKind", __native_object__, 1, __parameter_types__, __parameters__, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryValueKind::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; __parameters__[2] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; __parameters__[2] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ options) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(options).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_options__ = options; __parameters__[2] = &__param_options__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(mscorlib::System::String subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ registryOptions, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[4]; void *__parameters__[4]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registryOptions).name()); __parameter_types__[3] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)subkey; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_registryOptions__ = registryOptions; __parameters__[2] = &__param_registryOptions__; __parameters__[3] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 4, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::CreateSubKey(const char *subkey, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::Microsoft::Win32::RegistryOptions::__ENUM__ registryOptions, mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[4]; void *__parameters__[4]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(registryOptions).name()); __parameter_types__[3] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_registryOptions__ = registryOptions; __parameters__[2] = &__param_registryOptions__; __parameters__[3] = (MonoObject*)registrySecurity; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "CreateSubKey", __native_object__, 4, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } void RegistryKey::DeleteSubKey(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(mscorlib::System::String subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = (MonoObject*)subkey; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKey(const char *subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(mscorlib::System::String subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameters__[0] = (MonoObject*)subkey; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(const char *subkey) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(mscorlib::System::String subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(subkey).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = (MonoObject*)subkey; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteSubKeyTree(const char *subkey, mscorlib::System::Boolean throwOnMissingSubKey) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingSubKey).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), subkey); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingSubKey); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteSubKeyTree", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(mscorlib::System::String name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameters__[0] = (MonoObject*)name; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(const char *name) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameters__[0] = mono_string_new(Global::GetDomain(), name); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 1, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(mscorlib::System::String name, mscorlib::System::Boolean throwOnMissingValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingValue).name()); __parameters__[0] = (MonoObject*)name; __parameters__[1] = reinterpret_cast<void*>(throwOnMissingValue); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } void RegistryKey::DeleteValue(const char *name, mscorlib::System::Boolean throwOnMissingValue) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(throwOnMissingValue).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); __parameters__[1] = reinterpret_cast<void*>(throwOnMissingValue); Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "DeleteValue", __native_object__, 2, __parameter_types__, __parameters__, NULL); } mscorlib::System::Security::AccessControl::RegistrySecurity RegistryKey::GetAccessControl() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetAccessControl", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::Security::AccessControl::RegistrySecurity(__result__); } mscorlib::System::Security::AccessControl::RegistrySecurity RegistryKey::GetAccessControl(mscorlib::System::Security::AccessControl::AccessControlSections::__ENUM__ includeSections) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(includeSections).name()); mscorlib::System::Int32 __param_includeSections__ = includeSections; __parameters__[0] = &__param_includeSections__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetAccessControl", __native_object__, 1, __parameter_types__, __parameters__, NULL); return mscorlib::System::Security::AccessControl::RegistrySecurity(__result__); } std::vector<mscorlib::System::String*> RegistryKey::GetSubKeyNames() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetSubKeyNames", __native_object__, 0, NULL, NULL, NULL); MonoArray *__array_ptr__ = (MonoArray*)__result__; uintptr_t __array_length__ = mono_array_length(__array_ptr__); std::vector<mscorlib::System::String*> __array_result__(__array_length__); for(uintptr_t __array_index__ = 0; __array_index__ < __array_length__; __array_index__++) { MonoObject *__array_item__ = mono_array_get(__array_ptr__,MonoObject*,__array_index__); __array_result__.push_back(new mscorlib::System::String (__array_item__)); } return __array_result__; } std::vector<mscorlib::System::String*> RegistryKey::GetValueNames() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "GetValueNames", __native_object__, 0, NULL, NULL, NULL); MonoArray *__array_ptr__ = (MonoArray*)__result__; uintptr_t __array_length__ = mono_array_length(__array_ptr__); std::vector<mscorlib::System::String*> __array_result__(__array_length__); for(uintptr_t __array_index__ = 0; __array_index__ < __array_length__; __array_index__++) { MonoObject *__array_item__ = mono_array_get(__array_ptr__,MonoObject*,__array_index__); __array_result__.push_back(new mscorlib::System::String (__array_item__)); } return __array_result__; } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::FromHandle(mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle handle) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(handle).name()); __parameters__[0] = (MonoObject*)handle; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "FromHandle", NullMonoObject, 1, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::FromHandle(mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle handle, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(handle).name()); __parameter_types__[1] = Global::GetType(typeid(view).name()); __parameters__[0] = (MonoObject*)handle; mscorlib::System::Int32 __param_view__ = view; __parameters__[1] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "FromHandle", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::System::String machineName) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(machineName).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = (MonoObject*)machineName; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, const char *machineName) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType("mscorlib", "System", "String"); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = mono_string_new(Global::GetDomain(), machineName); MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::System::String machineName, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(machineName).name()); __parameter_types__[2] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = (MonoObject*)machineName; mscorlib::System::Int32 __param_view__ = view; __parameters__[2] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenRemoteBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, const char *machineName, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[2] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; __parameters__[1] = mono_string_new(Global::GetDomain(), machineName); mscorlib::System::Int32 __param_view__ = view; __parameters__[2] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenRemoteBaseKey", NullMonoObject, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenBaseKey(mscorlib::Microsoft::Win32::RegistryHive::__ENUM__ hKey, mscorlib::Microsoft::Win32::RegistryView::__ENUM__ view) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(hKey).name()); __parameter_types__[1] = Global::GetType(typeid(view).name()); mscorlib::System::Int32 __param_hKey__ = hKey; __parameters__[0] = &__param_hKey__; mscorlib::System::Int32 __param_view__ = view; __parameters__[1] = &__param_view__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenBaseKey", NullMonoObject, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = (MonoObject*)name; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck) { MonoType *__parameter_types__[2]; void *__parameters__[2]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 2, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(mscorlib::System::String name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistryRights::__ENUM__ rights) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType(typeid(name).name()); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(rights).name()); __parameters__[0] = (MonoObject*)name; mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_rights__ = rights; __parameters__[2] = &__param_rights__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } mscorlib::Microsoft::Win32::RegistryKey RegistryKey::OpenSubKey(const char *name, mscorlib::Microsoft::Win32::RegistryKeyPermissionCheck::__ENUM__ permissionCheck, mscorlib::System::Security::AccessControl::RegistryRights::__ENUM__ rights) { MonoType *__parameter_types__[3]; void *__parameters__[3]; __parameter_types__[0] = Global::GetType("mscorlib", "System", "String"); __parameter_types__[1] = Global::GetType(typeid(permissionCheck).name()); __parameter_types__[2] = Global::GetType(typeid(rights).name()); __parameters__[0] = mono_string_new(Global::GetDomain(), name); mscorlib::System::Int32 __param_permissionCheck__ = permissionCheck; __parameters__[1] = &__param_permissionCheck__; mscorlib::System::Int32 __param_rights__ = rights; __parameters__[2] = &__param_rights__; MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "OpenSubKey", __native_object__, 3, __parameter_types__, __parameters__, NULL); return mscorlib::Microsoft::Win32::RegistryKey(__result__); } void RegistryKey::SetAccessControl(mscorlib::System::Security::AccessControl::RegistrySecurity registrySecurity) { MonoType *__parameter_types__[1]; void *__parameters__[1]; __parameter_types__[0] = Global::GetType(typeid(registrySecurity).name()); __parameters__[0] = (MonoObject*)registrySecurity; Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "SetAccessControl", __native_object__, 1, __parameter_types__, __parameters__, NULL); } mscorlib::System::String RegistryKey::ToString() { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "ToString", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::String(__result__); } //Get Set Properties Methods // Get:Name mscorlib::System::String RegistryKey::get_Name() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_Name", __native_object__, 0, NULL, NULL, NULL); return mscorlib::System::String(__result__); } // Get:SubKeyCount mscorlib::System::Int32 RegistryKey::get_SubKeyCount() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_SubKeyCount", __native_object__, 0, NULL, NULL, NULL); return *(mscorlib::System::Int32*)mono_object_unbox(__result__); } // Get:ValueCount mscorlib::System::Int32 RegistryKey::get_ValueCount() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_ValueCount", __native_object__, 0, NULL, NULL, NULL); return *(mscorlib::System::Int32*)mono_object_unbox(__result__); } // Get:Handle mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle RegistryKey::get_Handle() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_Handle", __native_object__, 0, NULL, NULL, NULL); return mscorlib::Microsoft::Win32::SafeHandles::SafeRegistryHandle(__result__); } // Get:View mscorlib::Microsoft::Win32::RegistryView::__ENUM__ RegistryKey::get_View() const { MonoObject *__result__ = Global::InvokeMethod("mscorlib", "Microsoft.Win32", "RegistryKey", 0, NULL, "get_View", __native_object__, 0, NULL, NULL, NULL); return static_cast<mscorlib::Microsoft::Win32::RegistryView::__ENUM__>(*(mscorlib::System::Int32*)mono_object_unbox(__result__)); } } } }
58.024226
332
0.733531
brunolauze
d6745d17c58f01e1db5ecffae723aa7d863d1165
662
hpp
C++
components/operators/include/ftl/operators/colours.hpp
knicos/voltu
70b39da7069f8ffd7e33aeb5bdacc84fe4a78f01
[ "MIT" ]
4
2020-12-28T15:29:15.000Z
2021-06-27T12:37:15.000Z
components/operators/include/ftl/operators/colours.hpp
knicos/voltu
70b39da7069f8ffd7e33aeb5bdacc84fe4a78f01
[ "MIT" ]
null
null
null
components/operators/include/ftl/operators/colours.hpp
knicos/voltu
70b39da7069f8ffd7e33aeb5bdacc84fe4a78f01
[ "MIT" ]
2
2021-01-13T05:28:39.000Z
2021-05-04T03:37:11.000Z
#ifndef _FTL_OPERATORS_COLOURS_HPP_ #define _FTL_OPERATORS_COLOURS_HPP_ #include <ftl/operators/operator.hpp> namespace ftl { namespace operators { class ColourChannels : public ftl::operators::Operator { public: explicit ColourChannels(ftl::operators::Graph *g, ftl::Configurable *cfg); ~ColourChannels(); inline Operator::Type type() const override { return Operator::Type::OneToOne; } bool apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, cudaStream_t stream) override; static void configuration(ftl::Configurable*) {} private: cv::cuda::GpuMat temp_; cv::cuda::GpuMat rbuf_; }; } } #endif // _FTL_OPERATORS_COLOURS_HPP_
22.827586
90
0.732628
knicos
d675c0f05cc5632fade00bea7c317d693f6243a2
1,156
cpp
C++
src/managers/environmentmanager.cpp
alexhuntley/GameplayFootball
67a3c123e31384b757b1d223c53acf9f7fcb8b41
[ "Apache-2.0" ]
56
2020-07-22T22:11:06.000Z
2022-03-09T08:11:43.000Z
src/managers/environmentmanager.cpp
alexhuntley/GameplayFootball
67a3c123e31384b757b1d223c53acf9f7fcb8b41
[ "Apache-2.0" ]
9
2021-04-22T07:06:25.000Z
2022-01-22T12:54:52.000Z
src/managers/environmentmanager.cpp
alexhuntley/GameplayFootball
67a3c123e31384b757b1d223c53acf9f7fcb8b41
[ "Apache-2.0" ]
18
2020-10-15T08:11:07.000Z
2022-03-23T14:49:46.000Z
// written by bastiaan konings schuiling 2008 - 2014 // this work is public domain. the code is undocumented, scruffy, untested, and should generally not be used for anything important. // i do not offer support, so don't ask. to be used for inspiration :) #include "environmentmanager.hpp" #include <SDL2/SDL.h> #include <boost/thread.hpp> namespace blunted { template<> EnvironmentManager* Singleton<EnvironmentManager>::singleton = 0; EnvironmentManager::EnvironmentManager() { quit.SetData(false); startTime = boost::posix_time::microsec_clock::local_time(); }; EnvironmentManager::~EnvironmentManager() { }; unsigned long EnvironmentManager::GetTime_ms() { boost::posix_time::ptime now = boost::posix_time::microsec_clock::local_time(); boost::posix_time::time_duration msdiff = now - startTime; return msdiff.total_milliseconds(); } void EnvironmentManager::Pause_ms(int duration) { boost::this_thread::sleep(boost::posix_time::milliseconds(duration)); } void EnvironmentManager::SignalQuit() { quit.SetData(true); } bool EnvironmentManager::GetQuit() { return quit.GetData(); } }
28.195122
132
0.728374
alexhuntley
d681b4c481a663360a6bde5e70e62c9f370957c6
71
hh
C++
extern/typed-geometry/src/typed-geometry/feature/quadric.hh
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
extern/typed-geometry/src/typed-geometry/feature/quadric.hh
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
extern/typed-geometry/src/typed-geometry/feature/quadric.hh
rovedit/Fort-Candle
445fb94852df56c279c71b95c820500e7fb33cf7
[ "MIT" ]
null
null
null
#pragma once #include <typed-geometry/functions/quadrics/quadrics.hh>
17.75
56
0.802817
rovedit
d6865d54633d83c67f32ba92125a8af7c29bfb48
1,658
hpp
C++
lib/libcpp/Alat/Alat/vectorallvariables.hpp
beckerrh/simfemsrc
d857eb6f6f8627412d4f9d89a871834c756537db
[ "MIT" ]
null
null
null
lib/libcpp/Alat/Alat/vectorallvariables.hpp
beckerrh/simfemsrc
d857eb6f6f8627412d4f9d89a871834c756537db
[ "MIT" ]
1
2019-01-31T10:59:11.000Z
2019-01-31T10:59:11.000Z
lib/libcpp/Alat/Alat/vectorallvariables.hpp
beckerrh/simfemsrc
d857eb6f6f8627412d4f9d89a871834c756537db
[ "MIT" ]
null
null
null
#ifndef __Alat_VectorAllVariables_h #define __Alat_VectorAllVariables_h #include "Alat/vector.hpp" #include "Alat/vectoronevariableinterface.hpp" /*--------------------------------------------------------------------------*/ namespace alat { class StringSet; class StringVector; class VectorAllVariables : public alat::Vector<std::shared_ptr<alat::VectorOneVariableInterface> > { public: ~VectorAllVariables(); VectorAllVariables(); VectorAllVariables(int nvars); VectorAllVariables( const VectorAllVariables& vectorallvariables); VectorAllVariables& operator=( const VectorAllVariables& vectorallvariables); std::string getClassName() const; VectorAllVariables* clone() const; const alat::VectorOneVariableInterface* get(int i) const; alat::VectorOneVariableInterface* get(int i); void fillzeros(); double norm() const; double dot(const alat::VectorAllVariables* v) const; void equal(const alat::VectorAllVariables* v); void equal(double d); void add(const double& d, const alat::VectorAllVariables* v); // void scalePerVariables(const alat::Vector<alat::armavec>& scales); // void scalePerVariablesInverse(const alat::Vector<alat::armavec>& scales); void loadhdf5(const std::string& filename, const alat::StringVector& names); void savehdf5(const std::string& filename, const alat::StringVector& names) const; void save(std::ostream& os, arma::file_type datatype = arma::arma_binary) const; }; std::ostream& operator<<(std::ostream& s, const VectorAllVariables& v); } /*--------------------------------------------------------------------------*/ #endif
36.844444
100
0.670084
beckerrh
d68692797d902cfeddae8fd0168be39a934a1a97
1,146
hpp
C++
Frameworks/include/Helmet/Workbench/I_Controller.hpp
hatboysoftware/helmet
97f26d134742fdb732abc6177bb2adaeb67b3187
[ "Zlib" ]
2
2018-02-07T01:19:37.000Z
2018-02-09T14:27:48.000Z
Frameworks/include/Helmet/Workbench/I_Controller.hpp
hatboysoftware/helmet
97f26d134742fdb732abc6177bb2adaeb67b3187
[ "Zlib" ]
null
null
null
Frameworks/include/Helmet/Workbench/I_Controller.hpp
hatboysoftware/helmet
97f26d134742fdb732abc6177bb2adaeb67b3187
[ "Zlib" ]
null
null
null
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ // Helmet Software Framework // // Copyright (C) 2018 Hat Boy Software, Inc. // // @author Matthew Alan Gray - <[email protected]> // @author Tony Richards - <[email protected]> //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ #pragma once #include <Helmet/Workbench/Configuration.hpp> //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ namespace Helmet { namespace Workbench { //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ class HELMET_WORKBENCH_DLL_LINK I_Controller { /// @name Types /// @{ public: /// @} /// @name I_Controller interface /// @{ public: /// @} /// @name 'Structors /// @{ protected: I_Controller(); virtual ~I_Controller(); /// @} }; // interface I_Controller //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ } // namespace Workbench } // namespace Helmet //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
26.651163
80
0.358639
hatboysoftware
d6886cc1f91b158f4a09fc12593b5889ecc6d387
4,414
cpp
C++
test/dcu/level1/doti_s_dcu_test.cpp
xupinjie/AlphaSparse
06bf06a57f9112c2f940741841485243d8073c7c
[ "MIT" ]
18
2022-02-22T15:10:18.000Z
2022-03-29T07:54:57.000Z
test/dcu/level1/doti_s_dcu_test.cpp
xupinjie/AlphaSparse
06bf06a57f9112c2f940741841485243d8073c7c
[ "MIT" ]
null
null
null
test/dcu/level1/doti_s_dcu_test.cpp
xupinjie/AlphaSparse
06bf06a57f9112c2f940741841485243d8073c7c
[ "MIT" ]
2
2022-02-23T09:25:57.000Z
2022-02-25T08:01:03.000Z
/** * @brief ict dcu mv csr test * @author HPCRC, ICT */ #include <hip/hip_runtime_api.h> #include <rocsparse.h> #include <stdio.h> #include <stdlib.h> #include <iomanip> #include <iostream> #include <vector> #include "rocsparse.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include <alpha_spblas_dcu.h> const char *file; bool check; int iter; // sparse vector ALPHA_INT nnz; ALPHA_INT *alpha_x_idx; rocsparse_int *roc_x_idx; float *x_val, *y; float roc_res = 1., alpha_res = 2.; ALPHA_INT idx_n = 10000; static void roc_doti() { // rocSPARSE handle rocsparse_handle handle; rocsparse_create_handle(&handle); hipDeviceProp_t devProp; int device_id = 0; hipGetDevice(&device_id); hipGetDeviceProperties(&devProp, device_id); std::cout << "Device: " << devProp.name << std::endl; // Offload data to device rocsparse_int *dx_idx = NULL; float *dx_val = NULL; float *dy = NULL; hipMalloc((void **)&dx_idx, sizeof(rocsparse_int) * idx_n); hipMalloc((void **)&dx_val, sizeof(float) * idx_n); hipMalloc((void **)&dy, sizeof(float) * idx_n * 20); hipMemcpy(dx_idx, roc_x_idx, sizeof(rocsparse_int) * idx_n, hipMemcpyHostToDevice); hipMemcpy(dx_val, x_val, sizeof(float) * idx_n, hipMemcpyHostToDevice); hipMemcpy(dy, y, sizeof(float) * idx_n * 20, hipMemcpyHostToDevice); // Call rocsparse csrmv roc_call_exit(rocsparse_sdoti(handle, idx_n, dx_val, dx_idx, dy, &roc_res, rocsparse_index_base_zero), "rocsparse_sdoti"); // Device synchronization hipDeviceSynchronize(); // Clear up on device hipFree(dx_val); hipFree(dx_idx); hipFree(dy); rocsparse_destroy_handle(handle); } static void alpha_doti() { // rocSPARSE handle alphasparse_dcu_handle_t handle; init_handle(&handle); alphasparse_dcu_get_handle(&handle); hipDeviceProp_t devProp; int device_id = 0; hipGetDevice(&device_id); hipGetDeviceProperties(&devProp, device_id); std::cout << "Device: " << devProp.name << std::endl; // Offload data to device ALPHA_INT *dx_idx = NULL; float *dx_val = NULL; float *dy = NULL; hipMalloc((void **)&dx_idx, sizeof(ALPHA_INT) * idx_n); hipMalloc((void **)&dx_val, sizeof(float) * idx_n); hipMalloc((void **)&dy, sizeof(float) * idx_n * 20); hipMemcpy(dx_idx, roc_x_idx, sizeof(ALPHA_INT) * idx_n, hipMemcpyHostToDevice); hipMemcpy(dx_val, x_val, sizeof(float) * idx_n, hipMemcpyHostToDevice); hipMemcpy(dy, y, sizeof(float) * idx_n * 20, hipMemcpyHostToDevice); // Call rocsparse csrmv alphasparse_dcu_s_doti(handle, idx_n, dx_val, dx_idx, dy, &alpha_res, ALPHA_SPARSE_INDEX_BASE_ZERO); // Device synchronization hipDeviceSynchronize(); // Clear up on device hipFree(dx_val); hipFree(dx_idx); hipFree(dy); alphasparse_dcu_destory_handle(handle); } int main(int argc, const char *argv[]) { // args args_help(argc, argv); file = args_get_data_file(argc, argv); check = args_get_if_check(argc, argv); iter = args_get_iter(argc, argv); alpha_x_idx = (ALPHA_INT *)alpha_memalign(sizeof(ALPHA_INT) * idx_n, DEFAULT_ALIGNMENT); roc_x_idx = (rocsparse_int *)alpha_memalign(sizeof(rocsparse_int) * idx_n, DEFAULT_ALIGNMENT); x_val = (float *)alpha_memalign(sizeof(float) * idx_n, DEFAULT_ALIGNMENT); y = (float *)alpha_memalign(sizeof(float) * idx_n * 20, DEFAULT_ALIGNMENT); alpha_fill_random_s(y, 1, idx_n * 20); alpha_fill_random_s(x_val, 1, idx_n); for (ALPHA_INT i = 0; i < idx_n; i++) { alpha_x_idx[i] = i * 20; roc_x_idx[i] = i * 20; } alpha_doti(); // if (check) { // roc_doti(); // bool status = fabs(alpha_res - roc_res) > 1e-2; // if (!status) { // fprintf(stderr, "doti_s correct, %f\n", fabs(alpha_res - roc_res)); // fprintf(stderr, "roc : %f, ict : %f\n", roc_res, alpha_res); // } else { // fprintf(stderr, "doti_s error\n"); // fprintf(stderr, "roc : %f, ict : %f\n", roc_res, alpha_res); // } // } printf("\n"); alpha_free(x_val); alpha_free(roc_x_idx); alpha_free(alpha_x_idx); return 0; } #ifdef __cplusplus } #endif /*__cplusplus */
26.914634
106
0.636611
xupinjie
d68aad3695242540de0ebb362edf43045a21f280
1,959
cpp
C++
Mrf_DS18B20.cpp
RodNewHampshire/MRF101-150W-HF-Broadband-Amplifier
769ac0ea2b5d09ef193aa78ef23563b83cec6d2d
[ "MIT" ]
3
2021-08-15T17:40:53.000Z
2022-01-20T14:45:33.000Z
Mrf_DS18B20.cpp
RodNewHampshire/MRF101-150W-HF-Broadband-Amplifier
769ac0ea2b5d09ef193aa78ef23563b83cec6d2d
[ "MIT" ]
null
null
null
Mrf_DS18B20.cpp
RodNewHampshire/MRF101-150W-HF-Broadband-Amplifier
769ac0ea2b5d09ef193aa78ef23563b83cec6d2d
[ "MIT" ]
null
null
null
/****************************************************************************** * * MRF101 Amplifier by AD5GH * * ARDUINO MEGA DISPLAY & CONTROL BOARD SOFTWARE * DS18B20+ ONE WIRE TEMPERATURE SENSOR FUNCTION ROUTINES * * Distributed under the terms of the MIT License: * http://www.opensource.org/licenses/mit-license * * See http://www.ad5gh.com for further details * * VERSION 1.4.0 * June 4, 2021 * ******************************************************************************/ #include <OneWire.h> #include <Mrf_DS18B20.h> Mrf_DS18B20::Mrf_DS18B20(void) { } float Mrf_DS18B20::getTemp(int DS18S20_Pin) // returns the temperature from one DS18B20 in DEG C { OneWire ds(DS18S20_Pin); // set digital pin byte data[12]; byte addr[8]; if ( !ds.search(addr)) { ds.reset_search(); if( !ds.search(addr)) // try a second time if first try fails { ds.reset_search(); return -10; } } if ( OneWire::crc8( addr, 7) != addr[7]) { Serial.println("Invalid CRC"); return -20; } if ( addr[0] != 0x10 && addr[0] != 0x28) { Serial.print("Device not recognized"); return -30; } ds.reset(); ds.select(addr); ds.write(0x44,1); // start conversion, with parasite power on at the end byte present = ds.reset(); ds.select(addr); ds.write(0xBE); // read Scratchpad for (int i = 0; i < 9; i++) { // we need 9 bytes data[i] = ds.read(); } ds.reset_search(); byte MSB = data[1]; byte LSB = data[0]; float tempRead = ((MSB << 8) | LSB); // using two's compliment float TemperatureSum = tempRead / 16; return (TemperatureSum); // return temperature in degrees C }
25.441558
118
0.48392
RodNewHampshire