3 #ifndef RENDERER_STATE_HOST_H
4 #define RENDERER_STATE_HOST_H
9 #include "renderer_state_base.h"
10 #include "renderer_detail_trace.h"
11 #include "renderer_detail_normal_mrf.h"
47 template<
int t_ColorFormat,
int t_Platform >
49 uint8_t*
const colors,
51 unsigned int const pitch,
52 Synchronized::Heap< t_Platform >
const& heap,
53 Synchronized::TextureHeap< t_ColorFormat, t_Platform >
const& textureHeap,
67 State< PLATFORM_HOST >::State() {
71 template<
int t_ColorFormat,
int t_Platform >
72 void State< PLATFORM_HOST >::TraceScreen(
73 uint8_t*
const colors,
75 unsigned int const pitch,
76 Synchronized::Heap< t_Platform >
const& heap,
77 Synchronized::TextureHeap< t_ColorFormat, t_Platform >
const& textureHeap,
88 double const spread = 2 * ( fieldOfView / dimension ).Minimum();
90 std::unique_ptr< float[] > depths(
new float[ dimension.
Product() ] );
92 #pragma omp parallel for
93 for (
int ii = 0; ii < static_cast< int >( dimension[ 1 ] ); ++ii ) {
95 unsigned int const offset = ii * pitch;
96 for (
int jj = 0; jj < static_cast< int >( dimension[ 0 ] ); ++jj ) {
99 Vector< double, 2 > const direction = ( ( coordinates + 0.5 ) * 2 / dimension - 1 ) * fieldOfView;
102 uint8_t*
const colorDestination = colors + offset + jj * 4;
103 colorDestination[ 0 ] = 0x00;
104 colorDestination[ 1 ] = 0x00;
105 colorDestination[ 2 ] = 0x00;
106 colorDestination[ 3 ] = 0xff;
108 float*
const depthDestination = depths.get() + coordinates[ 1 ] * dimension[ 0 ] + coordinates[ 0 ];
109 *depthDestination = std::numeric_limits< float >::infinity();
111 detail::Trace< t_ColorFormat, t_Platform >( colorDestination, depthDestination, pRoot, spread, position, ray );
124 #endif // RENDERER_STATE_HOST_H