On Thu, 9 May 2019 at 13:06, Wayne Stambaugh <stambau...@gmail.com> wrote: > > Hi Henner, > > On 5/1/19 9:44 AM, Henner Zeller wrote: > > On Wed, 1 May 2019 at 06:14, John Beard <john.j.be...@gmail.com> wrote: > >> > >> On 01/05/2019 13:57, Mário Luzeiro wrote: > >>> Hi John, > >>> > >>> yeah the Morton code is to improve cache hits. > >>> > >>> Regarding the speed test, since OS are multi-tasking there could be some > >>> interference on the results so 1s difference is not a very measurable > >>> difference ( 4% ). > >>> A possibility would be to run the same scene multiple times and make an > >>> average of the times. > >> > >> Sure, it was just a fun observation. It does change a bit from run to > >> run, but I was at least expecting a small penalty. Next up, wipes[1] and > >> then perhaps Snake :-D > >> > >> A more robust benchmarking harness would probably be the way to go if we > >> really were serious about putting the pedal to the metal here. > >> > >> But I think the centre-first approach is certainly better usability, but > >> I'm unsure about the checkerboard. > > > > I agree, without checkerboard it makes it quicker to see what is going > > on in the center. Attached the (even simpler) just spiraling out from > > the center patch. > > I tested this patch and it works as advertised. Would you please fix a > few minor coding policy issues (missing spaces after opening and before > closing parentheses) and resubmit it? There is now a clang-format > (>=3.9) commit hook[1] that allows you to check your code formatting > before you commit.
Sorry for the formatting mess-up, attached you find the patch properly clang-tidied. I really like the new clang tidy script, much more seamless than the uncrustify stuff from the past. Thanks, Henner. > > Thanks, > > Wayne > > [1]: > http://docs.kicad-pcb.org/doxygen/md_Documentation_development_coding-style-policy.html#tools > > > > >> > >> Cheers, > >> > >> John > >> > >> [1]: https://www.youtube.com/watch?v=cGqAu9gj_F0 > >> > >> _______________________________________________ > >> Mailing list: https://launchpad.net/~kicad-developers > >> Post to : kicad-developers@lists.launchpad.net > >> Unsubscribe : https://launchpad.net/~kicad-developers > >> More help : https://help.launchpad.net/ListHelp > > > > _______________________________________________ > Mailing list: https://launchpad.net/~kicad-developers > Post to : kicad-developers@lists.launchpad.net > Unsubscribe : https://launchpad.net/~kicad-developers > More help : https://help.launchpad.net/ListHelp
diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp index 27b2ae4bc..3880eaf8c 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp @@ -28,10 +28,11 @@ */ #include <GL/glew.h> -#include <climits> +#include <algorithm> #include <atomic> -#include <thread> #include <chrono> +#include <climits> +#include <thread> #include "c3d_render_raytracing.h" #include "mortoncodes.h" @@ -2074,6 +2075,13 @@ bool C3D_RENDER_RAYTRACING::initializeOpenGL() } +static float distance( const SFVEC2UI& a, const SFVEC2UI& b ) +{ + const float dx = (float) a.x - (float) b.x; + const float dy = (float) a.y - (float) b.y; + return hypotf( dx, dy ); +} + void C3D_RENDER_RAYTRACING::initialize_block_positions() { @@ -2123,26 +2131,24 @@ void C3D_RENDER_RAYTRACING::initialize_block_positions() m_postshader_ssao.UpdateSize( m_realBufferSize ); - // Calc block positions + // Calc block positions for regular rendering. Choose an 'inside out' + // style of rendering // ///////////////////////////////////////////////////////////////////// m_blockPositions.clear(); - m_blockPositions.reserve( (m_realBufferSize.x / RAYPACKET_DIM) * - (m_realBufferSize.y / RAYPACKET_DIM) ); - - i = 0; - - while(1) - { - SFVEC2UI blockPos( DecodeMorton2X(i) * RAYPACKET_DIM, - DecodeMorton2Y(i) * RAYPACKET_DIM ); - i++; - - if( (blockPos.x >= m_realBufferSize.x) && (blockPos.y >= m_realBufferSize.y) ) - break; - - if( (blockPos.x < m_realBufferSize.x) && (blockPos.y < m_realBufferSize.y) ) - m_blockPositions.push_back( blockPos ); - } + const int blocks_x = m_realBufferSize.x / RAYPACKET_DIM; + const int blocks_y = m_realBufferSize.y / RAYPACKET_DIM; + m_blockPositions.reserve( blocks_x * blocks_y ); + + for( int x = 0; x < blocks_x; ++x ) + for( int y = 0; y < blocks_y; ++y ) + m_blockPositions.push_back( SFVEC2UI( x * RAYPACKET_DIM, y * RAYPACKET_DIM ) ); + + const SFVEC2UI center( m_realBufferSize.x / 2, m_realBufferSize.y / 2 ); + std::sort( m_blockPositions.begin(), m_blockPositions.end(), + [&]( const SFVEC2UI& a, const SFVEC2UI& b ) { + // Sort order: inside out. + return distance( a, center ) < distance( b, center ); + } ); // Create m_shader buffer delete[] m_shaderBuffer;
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : kicad-developers@lists.launchpad.net Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp