@@ -54,7 +54,7 @@ THE SOFTWARE.
54
54
#define _USE_MATH_DEFINES
55
55
#include < math.h>
56
56
57
- #ifdef FR_EMBED_KERNELS
57
+ #ifdef RR_EMBED_KERNELS
58
58
#include " ./CL/cache/kernels.h"
59
59
#endif
60
60
@@ -605,92 +605,92 @@ void Update()
605
605
for (int i = 0; i < g_cfgs.size(); ++i)
606
606
{
607
607
g_cfgs[i].renderer->SetNumBounces(numbnc);
608
- }*/
609
- }
610
-
611
- if (g_num_samples == -1 || g_samplecount++ < g_num_samples)
612
- {
613
- g_cfgs[g_primary].renderer ->Render (*g_scene.get ());
614
- }
615
-
616
- // if (std::chrono::duration_cast<std::chrono::seconds>(time - updatetime).count() > 1)
617
- // {
618
- for (int i = 0 ; i < g_cfgs.size (); ++i)
619
- {
620
- if (g_cfgs[i].type == ConfigManager::kPrimary )
621
- continue ;
622
-
623
- int desired = 1 ;
624
- if (std::atomic_compare_exchange_strong (&g_ctrl[i].newdata , &desired, 0 ))
625
- {
626
- {
627
- // std::unique_lock<std::mutex> lock(g_ctrl[i].datamutex);
628
- // std::cout << "Start updating acc buffer\n"; std::cout.flush();
629
- g_cfgs[g_primary].context .WriteBuffer (0 , g_outputs[g_primary].copybuffer , &g_outputs[i].fdata [0 ], g_window_width * g_window_height);
630
- // std::cout << "Finished updating acc buffer\n"; std::cout.flush();
631
- }
632
-
633
- CLWKernel acckernel = g_cfgs[g_primary].renderer ->GetAccumulateKernel ();
608
+ }*/
609
+ }
634
610
635
- int argc = 0 ;
636
- acckernel. SetArg (argc++, g_outputs[g_primary]. copybuffer );
637
- acckernel. SetArg (argc++, g_window_width * g_window_width );
638
- acckernel. SetArg (argc++, g_outputs[g_primary]. output -> data ());
611
+ if (g_num_samples == - 1 || g_samplecount++ < g_num_samples)
612
+ {
613
+ g_cfgs[g_primary]. renderer -> Render (*g_scene. get () );
614
+ }
639
615
640
- int globalsize = g_window_width * g_window_height;
641
- g_cfgs[g_primary].context .Launch1D (0 , ((globalsize + 63 ) / 64 ) * 64 , 64 , acckernel);
642
- }
643
- }
616
+ // if (std::chrono::duration_cast<std::chrono::seconds>(time - updatetime).count() > 1)
617
+ // {
618
+ for (int i = 0 ; i < g_cfgs.size (); ++i)
619
+ {
620
+ if (g_cfgs[i].type == ConfigManager::kPrimary )
621
+ continue ;
622
+
623
+ int desired = 1 ;
624
+ if (std::atomic_compare_exchange_strong (&g_ctrl[i].newdata , &desired, 0 ))
625
+ {
626
+ {
627
+ // std::unique_lock<std::mutex> lock(g_ctrl[i].datamutex);
628
+ // std::cout << "Start updating acc buffer\n"; std::cout.flush();
629
+ g_cfgs[g_primary].context .WriteBuffer (0 , g_outputs[g_primary].copybuffer , &g_outputs[i].fdata [0 ], g_window_width * g_window_height);
630
+ // std::cout << "Finished updating acc buffer\n"; std::cout.flush();
631
+ }
632
+
633
+ CLWKernel acckernel = g_cfgs[g_primary].renderer ->GetAccumulateKernel ();
634
+
635
+ int argc = 0 ;
636
+ acckernel.SetArg (argc++, g_outputs[g_primary].copybuffer );
637
+ acckernel.SetArg (argc++, g_window_width * g_window_width);
638
+ acckernel.SetArg (argc++, g_outputs[g_primary].output ->data ());
639
+
640
+ int globalsize = g_window_width * g_window_height;
641
+ g_cfgs[g_primary].context .Launch1D (0 , ((globalsize + 63 ) / 64 ) * 64 , 64 , acckernel);
642
+ }
643
+ }
644
644
645
- // updatetime = time;
646
- // }
645
+ // updatetime = time;
646
+ // }
647
647
648
- if (!g_interop)
649
- {
650
- g_outputs[g_primary].output ->GetData (&g_outputs[g_primary].fdata [0 ]);
648
+ if (!g_interop)
649
+ {
650
+ g_outputs[g_primary].output ->GetData (&g_outputs[g_primary].fdata [0 ]);
651
651
652
- float gamma = 2 .2f ;
653
- for (int i = 0 ; i < (int )g_outputs[g_primary].fdata .size (); ++i)
654
- {
655
- g_outputs[g_primary].udata [4 * i] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].x / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
656
- g_outputs[g_primary].udata [4 * i + 1 ] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].y / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
657
- g_outputs[g_primary].udata [4 * i + 2 ] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].z / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
658
- g_outputs[g_primary].udata [4 * i + 3 ] = 1 ;
659
- }
652
+ float gamma = 2 .2f ;
653
+ for (int i = 0 ; i < (int )g_outputs[g_primary].fdata .size (); ++i)
654
+ {
655
+ g_outputs[g_primary].udata [4 * i] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].x / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
656
+ g_outputs[g_primary].udata [4 * i + 1 ] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].y / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
657
+ g_outputs[g_primary].udata [4 * i + 2 ] = (unsigned char )clamp (clamp (pow (g_outputs[g_primary].fdata [i].z / g_outputs[g_primary].fdata [i].w , 1 .f / gamma ), 0 .f , 1 .f ) * 255 , 0 , 255 );
658
+ g_outputs[g_primary].udata [4 * i + 3 ] = 1 ;
659
+ }
660
660
661
661
662
- glActiveTexture (GL_TEXTURE0);
662
+ glActiveTexture (GL_TEXTURE0);
663
663
664
- glBindTexture (GL_TEXTURE_2D, g_texture);
664
+ glBindTexture (GL_TEXTURE_2D, g_texture);
665
665
666
- glTexSubImage2D (GL_TEXTURE_2D, 0 , 0 , 0 , g_outputs[g_primary].output ->width (), g_outputs[g_primary].output ->height (), GL_RGBA, GL_UNSIGNED_BYTE, &g_outputs[g_primary].udata [0 ]);
666
+ glTexSubImage2D (GL_TEXTURE_2D, 0 , 0 , 0 , g_outputs[g_primary].output ->width (), g_outputs[g_primary].output ->height (), GL_RGBA, GL_UNSIGNED_BYTE, &g_outputs[g_primary].udata [0 ]);
667
667
668
- glBindTexture (GL_TEXTURE_2D, 0 );
669
- }
670
- else
671
- {
672
- std::vector<cl_mem> objects;
673
- objects.push_back (g_cl_interop_image);
674
- g_cfgs[g_primary].context .AcquireGLObjects (0 , objects);
668
+ glBindTexture (GL_TEXTURE_2D, 0 );
669
+ }
670
+ else
671
+ {
672
+ std::vector<cl_mem> objects;
673
+ objects.push_back (g_cl_interop_image);
674
+ g_cfgs[g_primary].context .AcquireGLObjects (0 , objects);
675
675
676
- CLWKernel copykernel = g_cfgs[g_primary].renderer ->GetCopyKernel ();
676
+ CLWKernel copykernel = g_cfgs[g_primary].renderer ->GetCopyKernel ();
677
677
678
- int argc = 0 ;
679
- copykernel.SetArg (argc++, g_outputs[g_primary].output ->data ());
680
- copykernel.SetArg (argc++, g_outputs[g_primary].output ->width ());
681
- copykernel.SetArg (argc++, g_outputs[g_primary].output ->height ());
682
- copykernel.SetArg (argc++, 2 .2f );
683
- copykernel.SetArg (argc++, g_cl_interop_image);
678
+ int argc = 0 ;
679
+ copykernel.SetArg (argc++, g_outputs[g_primary].output ->data ());
680
+ copykernel.SetArg (argc++, g_outputs[g_primary].output ->width ());
681
+ copykernel.SetArg (argc++, g_outputs[g_primary].output ->height ());
682
+ copykernel.SetArg (argc++, 2 .2f );
683
+ copykernel.SetArg (argc++, g_cl_interop_image);
684
684
685
- int globalsize = g_outputs[g_primary].output ->width () * g_outputs[g_primary].output ->height ();
686
- g_cfgs[g_primary].context .Launch1D (0 , ((globalsize + 63 ) / 64 ) * 64 , 64 , copykernel);
685
+ int globalsize = g_outputs[g_primary].output ->width () * g_outputs[g_primary].output ->height ();
686
+ g_cfgs[g_primary].context .Launch1D (0 , ((globalsize + 63 ) / 64 ) * 64 , 64 , copykernel);
687
687
688
- g_cfgs[g_primary].context .ReleaseGLObjects (0 , objects);
689
- g_cfgs[g_primary].context .Finish (0 );
690
- }
691
- // }
688
+ g_cfgs[g_primary].context .ReleaseGLObjects (0 , objects);
689
+ g_cfgs[g_primary].context .Finish (0 );
690
+ }
691
+ // }
692
692
693
- glutPostRedisplay ();
693
+ glutPostRedisplay ();
694
694
}
695
695
696
696
void RenderThread (ControlData& cd)
0 commit comments