<commit_before>#include "kernel/renderer.h"

namespace idaten {
	void Renderer::update(
		GLuint gltex,
		int width, int height,
		const aten::CameraParameter& camera,
		const std::vector<aten::GeomParameter>& shapes,
		const std::vector<aten::MaterialParameter>& mtrls,
		const std::vector<aten::LightParameter>& lights,
		const std::vector<std::vector<aten::GPUBvhNode>>& nodes,
		const std::vector<aten::PrimitiveParamter>& prims,
		const std::vector<aten::vertex>& vtxs,
		const std::vector<aten::mat4>& mtxs,
		const std::vector<TextureResource>& texs,
		const EnvmapResource& envmapRsc)
	{
#if 0
		size_t size_stack = 0;
		checkCudaErrors(cudaThreadGetLimit(&size_stack, cudaLimitStackSize));
		checkCudaErrors(cudaThreadSetLimit(cudaLimitStackSize, 12928));
		checkCudaErrors(cudaThreadGetLimit(&size_stack, cudaLimitStackSize));

		AT_PRINTF("Stack size %d\n", size_stack);
#endif

#if 0
		dst.init(sizeof(float4) * width * height);
#else
		//glimg.init(gltex, CudaGLRscRegisterType::WriteOnly);
		m_glimg.init(gltex, CudaGLRscRegisterType::ReadWrite);
#endif

		m_cam.init(sizeof(camera));
		m_cam.writeByNum(&camera, 1);
		m_camParam = camera;

		m_shapeparam.init(shapes.size());
		m_shapeparam.writeByNum(&shapes[0], shapes.size());

		m_mtrlparam.init(mtrls.size());
		m_mtrlparam.writeByNum(&mtrls[0], mtrls.size());

		m_lightparam.init(lights.size());
		m_lightparam.writeByNum(&lights[0], lights.size());

		if (!prims.empty()) {
			m_primparams.init(prims.size());
			m_primparams.writeByNum(&prims[0], prims.size());
		}

		if (!mtxs.empty()) {
			m_mtxparams.init(mtxs.size());
			m_mtxparams.writeByNum(&mtxs[0], mtxs.size());
		}

		for (int i = 0; i < nodes.size(); i++) {
			m_nodeparam.push_back(idaten::CudaTextureResource());
			m_nodeparam[i].init((aten::vec4*)&nodes[i][0], sizeof(aten::GPUBvhNode) / sizeof(float4), nodes[i].size());
		}
		m_nodetex.init(nodes.size());

		if (!vtxs.empty()) {
			// TODO
			std::vector<aten::vec4> pos;
			std::vector<aten::vec4> nml;
<commit_msg>Add check if there are lights.<commit_after>#include "kernel/renderer.h"

namespace idaten {
	void Renderer::update(
		GLuint gltex,
		int width, int height,
		const aten::CameraParameter& camera,
		const std::vector<aten::GeomParameter>& shapes,
		const std::vector<aten::MaterialParameter>& mtrls,
		const std::vector<aten::LightParameter>& lights,
		const std::vector<std::vector<aten::GPUBvhNode>>& nodes,
		const std::vector<aten::PrimitiveParamter>& prims,
		const std::vector<aten::vertex>& vtxs,
		const std::vector<aten::mat4>& mtxs,
		const std::vector<TextureResource>& texs,
		const EnvmapResource& envmapRsc)
	{
#if 0
		size_t size_stack = 0;
		checkCudaErrors(cudaThreadGetLimit(&size_stack, cudaLimitStackSize));
		checkCudaErrors(cudaThreadSetLimit(cudaLimitStackSize, 12928));
		checkCudaErrors(cudaThreadGetLimit(&size_stack, cudaLimitStackSize));

		AT_PRINTF("Stack size %d\n", size_stack);
#endif

#if 0
		dst.init(sizeof(float4) * width * height);
#else
		//glimg.init(gltex, CudaGLRscRegisterType::WriteOnly);
		m_glimg.init(gltex, CudaGLRscRegisterType::ReadWrite);
#endif

		m_cam.init(sizeof(camera));
		m_cam.writeByNum(&camera, 1);
		m_camParam = camera;

		m_shapeparam.init(shapes.size());
		m_shapeparam.writeByNum(&shapes[0], shapes.size());

		m_mtrlparam.init(mtrls.size());
		m_mtrlparam.writeByNum(&mtrls[0], mtrls.size());

		AT_ASSERT_LOG(!lights.empty(), "No Lights!!");

		m_lightparam.init(lights.size());
		m_lightparam.writeByNum(&lights[0], lights.size());

		if (!prims.empty()) {
			m_primparams.init(prims.size());
			m_primparams.writeByNum(&prims[0], prims.size());
		}

		if (!mtxs.empty()) {
			m_mtxparams.init(mtxs.size());
			m_mtxparams.writeByNum(&mtxs[0], mtxs.size());
		}

		for (int i = 0; i < nodes.size(); i++) {
			m_nodeparam.push_back(idaten::CudaTextureResource());
			m_nodeparam[i].init((aten::vec4*)&nodes[i][0], sizeof(aten::GPUBvhNode) / sizeof(float4), nodes[i].size());
		}
		m_nodetex.init(nodes.size());

		if (!vtxs.empty()) {
			// TODO
			std::vector<aten::vec4> pos;
			std::vector<aten::vec4> nml;

{'fraction_non_alphanumeric': 0.17339202739056003, 'fraction_numerical': 0.010760577158229395, 'mean_word_length': 5.979522184300341, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1863361', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1544, 'n_words': 234}