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

Datagenerator library #200

Merged

Conversation

AvKhokhlov
Copy link
Contributor

No description provided.

/// @param lights - lights range
/// 'spp' - spp vector
/// 'gamma_correction_enabled' - flag to enable/disable gamma correction
/// 'start_cam_id' - the number starting from will be named generated samples
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, actualize options description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

std::uint32_t num_bounces,
unsigned device_idx);

void AttachLight(LightObject* light);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this function. it should be done before datagenerator creation in the client code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope


DataGeneratorImpl::DataGeneratorImpl(SceneObject* scene,
size_t output_width,
size_t output_height,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output_width -> width, output_height -> height

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


rpr_camera* cameras;
unsigned cameras_num;
int cameras_start_output_idx;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int -> unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int cameras_start_output_idx;

rpr_light* lights;
unsigned lights_num;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this section before cameras

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
public:
explicit ConfigLoader(const DGenConfig& config);
char const* output_dir;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it before progress callback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already done

#include <vector>


struct OutputInfo
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to anonymous namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

void DataGeneratorImpl::GenerateSample(CameraObject* camera,
int camera_idx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int -> unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

DataGeneratorImpl::DataGeneratorImpl(SceneObject* scene,
size_t output_width,
size_t output_height,
std::uint32_t num_bounces,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const std::filesystem::path& output_dir);

SceneObject* m_scene = nullptr;
std::uint32_t m_width, m_height;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


SceneObject* m_scene = nullptr;
std::uint32_t m_width, m_height;
std::uint32_t m_num_bounces;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

bool gamma_correction_enabled) const;

void GenerateSample(CameraObject* camera,
int camera_idx,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

// log render settings
auto* render_attribute = doc.NewElement("renderer");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderer_attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const std::string& scene_name,
unsigned cameras_start_idx,
unsigned cameras_end_idx,
int cameras_index_offset,
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cameras_start_idx, cameras_end_idx and cameras_index_offset are not used here. Please, remove them

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

doc.SaveFile(bdg_metadata_file_name.string().c_str());
}

void DataGeneratorImpl::GenerateSample(CameraObject* camera,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenerateSample -> GenerateCameraData

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
assert(m_width);
assert(m_height);
assert(num_bounces);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useless asserts, because checks are done in the data_generator.cpp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

int camera_idx,
const std::vector<unsigned>& spp,
const std::filesystem::path& output_dir,
bool gamma_correction_enabled);
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output_dir, gamma_correction_enabled and spp should be members of class

/// 'start_cam_id' - the number starting from will be named generated samples

void SaveMetadata(const std::filesystem::path& output_dir,
const std::string& scene_name,
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output_dir and scene_name should be member of class

// 'scene_file' - full path till .obj/.objm or some kind of this files with scene
// 'output_width' - width of outputs which will be saved on disk
// 'output_height' - height of outputs which will be saved on disk
// 'num_bounces' - number of bounces for each ray
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, actualize options descriptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're correct


// Render outputs for every specified SPP at the given
// camera position and save them to separate files
int camera_idx = params->cameras_start_output_idx + i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


unsigned gamma_correction;

void (*progress_callback)(int /* camera_idx */);
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets change signature to:
void (*progress_callback)(unsigned start_idx, unsigned current_idx, end_idx);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

auto app_metadata_file_name = m_app_config.output_dir;
app_metadata_file_name.append("app_metadata.xml");

auto* root = doc.NewElement("app_metadata");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app_metadata -> metadata

m_rpr_cameras.push_back(&camera);
}

SaveAppMetadata(range.begin, range.end);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

range.end - 1

params->gamma_correction != 0);

// Attach given lights to the scene
for (size_t i = 0; i < params->lights_num; ++i)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it before data_generator creation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

// camera_end_idx is index of the last rendered camera
unsigned camera_end_idx = params->cameras_num - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

auto* camera = CameraObject::Cast<CameraObject>(params->cameras[i]);
if (camera == nullptr)
{
return kDataGeneratorBadCameras;
Copy link
Contributor

@achernigin1987 achernigin1987 Sep 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets check all cameras before data generator creation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

bool gamma_correction_enable)
: m_scene(scene),
m_scene_name(scene_name),
m_width(width), m_height(height),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move m_height on next line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

m_renderer->SetMaxBounces(num_bounces);
}

void DataGeneratorImpl::AttachLight(LightObject* light)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


#include <vector>

#define DEFAULT_START_OUTPUT_IDX (-1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets use const int

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
params->progress_callback(0,
i + 1,
params->cameras_num);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong indices

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yozhijk yozhijk merged commit 371fb99 into GPUOpen-LibrariesAndSDKs:master Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants