Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled control for number of passes with F6 / F7 and -np command line argument #48

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions App/PT/ptrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ namespace Baikal
};

// Constructor
PtRenderer::PtRenderer(CLWContext context, int devidx)
PtRenderer::PtRenderer(CLWContext context, int devidx, int num_bounces)
: m_context(context)
, m_output(nullptr)
, m_render_data(new RenderData)
, m_vidmemws(0)
, m_resetsampler(true)
, m_scene_tracker(context, devidx)
, m_num_bounces(num_bounces)
{

// Create parallel primitives
Expand Down Expand Up @@ -144,6 +145,11 @@ namespace Baikal
m_resetsampler = true;
}

void PtRenderer::SetNumBounces(int num_bounces)
{
m_num_bounces = num_bounces;
}

void PtRenderer::Preprocess(Scene const& scene)
{
}
Expand All @@ -169,7 +175,7 @@ namespace Baikal
m_context.FillBuffer(0, m_render_data->hitcount, maxrays, 1);

// Initialize first pass
for (int pass = 0; pass < 5; ++pass)
for (int pass = 0; pass < m_num_bounces; ++pass)
{
// Clear ray hits buffer
m_context.FillBuffer(0, m_render_data->hits, 0, m_render_data->hits.GetElementCount());
Expand Down
7 changes: 6 additions & 1 deletion App/PT/ptrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Baikal
{
public:
// Constructor
PtRenderer(CLWContext context, int devidx);
PtRenderer(CLWContext context, int devidx, int num_bounces);
// Destructor
~PtRenderer();

Expand All @@ -55,6 +55,8 @@ namespace Baikal
void Render(Scene const& scene) override;
// Set output
void SetOutput(Output* output) override;
// Set number of light bounces
void SetNumBounces(int num_bounces);
// Interop function
CLWKernel GetCopyKernel();
// Add function
Expand Down Expand Up @@ -105,6 +107,9 @@ namespace Baikal
// Vidmem usage
// Working set
size_t m_vidmemws;

private:
int m_num_bounces;
};

}
4 changes: 2 additions & 2 deletions App/config_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ THE SOFTWARE.
#include <GL/glx.h>
#endif

void ConfigManager::CreateConfigs(Mode mode, bool interop, std::vector<Config>& configs)
void ConfigManager::CreateConfigs(Mode mode, bool interop, std::vector<Config>& configs, int initial_num_bounces)
{
std::vector<CLWPlatform> platforms;

Expand Down Expand Up @@ -157,6 +157,6 @@ void ConfigManager::CreateConfigs(Mode mode, bool interop, std::vector<Config>&

for (int i = 0; i < configs.size(); ++i)
{
configs[i].renderer = new Baikal::PtRenderer(configs[i].context, configs[i].devidx);
configs[i].renderer = new Baikal::PtRenderer(configs[i].context, configs[i].devidx, initial_num_bounces);
}
}
2 changes: 1 addition & 1 deletion App/config_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ConfigManager

};

static void CreateConfigs(Mode mode, bool interop, std::vector<Config>& renderers);
static void CreateConfigs(Mode mode, bool interop, std::vector<Config>& renderers, int initial_num_bounces);

private:

Expand Down
8 changes: 4 additions & 4 deletions App/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int g_num_shadow_rays = 1;
int g_num_ao_rays = 1;
int g_ao_enabled = false;
int g_progressive = false;
int g_num_bounces = 2;
int g_num_bounces = 5;
int g_num_samples = -1;
int g_samplecount = 0;
float g_ao_radius = 1.f;
Expand Down Expand Up @@ -264,7 +264,7 @@ void InitGraphics()

void InitCl()
{
ConfigManager::CreateConfigs(g_mode, g_interop, g_cfgs);
ConfigManager::CreateConfigs(g_mode, g_interop, g_cfgs, g_num_bounces);

std::cout << "Running on devices: \n";

Expand Down Expand Up @@ -453,7 +453,7 @@ void OnKeyUp(int key, int x, int y)
++g_num_bounces;
for (int i = 0; i < g_cfgs.size(); ++i)
{
//g_cfgs[i].renderer->SetNumBounces(g_num_bounces);
g_cfgs[i].renderer->SetNumBounces(g_num_bounces);
g_cfgs[i].renderer->Clear(float3(0, 0, 0), *g_outputs[i].output);
}
g_samplecount = 0;
Expand All @@ -466,7 +466,7 @@ void OnKeyUp(int key, int x, int y)
--g_num_bounces;
for (int i = 0; i < g_cfgs.size(); ++i)
{
//g_cfgs[i].renderer->SetNumBounces(g_num_bounces);
g_cfgs[i].renderer->SetNumBounces(g_num_bounces);
g_cfgs[i].renderer->Clear(float3(0, 0, 0), *g_outputs[i].output);
}
g_samplecount = 0;
Expand Down