C++ links: Coroutines
https://github.com/MattPD/cpplinks / C++ Standard / C++20 / Coroutines
(draft; work in progress)
#coroutines (C++ Slack): https://cpplang.slack.com/archives/C5JS5JXT5
// | |
// Lookup Tables for Marching Cubes | |
// | |
// These tables differ from the original paper (Marching Cubes: A High Resolution 3D Surface Construction Algorithm) | |
// | |
// The co-ordinate system has the more convenient properties: | |
// | |
// i = cube index [0, 7] | |
// x = (i & 1) >> 0 | |
// y = (i & 2) >> 1 |
using System.IO; | |
using System.Text; | |
using UnityEditor; | |
using UnityEditor.Experimental; | |
using UnityEngine; | |
public class LibraryPathsForAsset_2020_2 | |
{ | |
[MenuItem("AssetDatabase/OutputLibraryPathsForAsset")] | |
public static void OutputLibraryPathsForAsset() |
https://github.com/MattPD/cpplinks / C++ Standard / C++20 / Coroutines
(draft; work in progress)
#coroutines (C++ Slack): https://cpplang.slack.com/archives/C5JS5JXT5
why doesn't radfft support AVX on PC?
So there's two separate issues here: using instructions added in AVX and using 256-bit wide vectors. The former turns out to be much easier than the latter for our use case.
Problem number 1 was that you positively need to put AVX code in a separate file with different compiler settings (/arch:AVX for VC++, -mavx for GCC/Clang) that make all SSE code emitted also use VEX encoding, and at the time radfft was written there was no way in CDep to set compiler flags for just one file, just for the overall build.
[There's the GCC "target" annotations on individual funcs, which in principle fix this, but I ran into nasty problems with this for several compiler versions, and VC++ has no equivalent, so we're not currently using that and just sticking with different compilation units.]
The other issue is to do with CPU power management.
// | |
// TinyCRT, revamp and TinyWin support by Don Williamson, 2011 | |
// Based on http://www.codeproject.com/KB/library/tlibc.aspx and LIBCTINY by Matt Pietrek | |
// | |
#pragma once | |
#ifdef USE_DEFAULT_CRT |
#include <Corrade/Utility/Assert.h> | |
#include <Corrade/PluginManager/Manager.h> | |
#include <Magnum/Magnum.h> | |
#include <Magnum/ImageView.h> | |
#include <Magnum/PixelFormat.h> | |
#include <Magnum/Math/Color.h> | |
#include <Magnum/Trade/AbstractImageConverter.h> | |
#include <MagnumExternal/Vulkan/flextVk.h> | |
#include <MagnumExternal/Vulkan/flextVkGlobal.h> |
Setup: | |
1. Index buffer containing N quads (each 2 triangles), where N is the max amount of spheres. Repeating pattern of {0,1,2,1,3,2} + K*4. | |
2. No vertex buffer. | |
Render N*2 triangles, where N is the number of spheres you have. | |
Vertex shader: | |
1. Sphere index = N/4 (N = SV_VertexId) | |
2. Quad coord: Q = float2(N%2, (N%4)/2) * 2.0 - 1.0 | |
3. Transform sphere center -> pos |
// TransientFuction: A light-weight alternative to std::function [C++11] | |
// Pass any callback - including capturing lambdas - cheaply and quickly as a | |
// function argument | |
// | |
// Based on: | |
// https://deplinenoise.wordpress.com/2014/02/23/using-c11-capturing-lambdas-w-vanilla-c-api-functions/ | |
// | |
// - No instantiation of called function at each call site | |
// - Simple to use - use TransientFunction<> as the function argument | |
// - Low cost: cheap setup, one indirect function call to invoke |
// Put this in an editor folder | |
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
using UnityEngine.Experimental.LowLevel; | |
using UnityEngine.Profiling; |
/*Copyright 2018 Neil North | |
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 OTHE |