2010-09-03 05:41:20 +08:00
|
|
|
/*
|
|
|
|
This file is part of Mitsuba, a physically based rendering system.
|
|
|
|
|
2011-04-14 21:15:59 +08:00
|
|
|
Copyright (c) 2007-2011 by Wenzel Jakob and others.
|
2010-09-03 05:41:20 +08:00
|
|
|
|
|
|
|
Mitsuba is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License Version 3
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
Mitsuba is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2011-04-14 21:15:59 +08:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2010-09-03 05:41:20 +08:00
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-08-10 01:38:37 +08:00
|
|
|
#include <mitsuba/hw/gpuprogram.h>
|
|
|
|
|
|
|
|
MTS_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
GPUProgram::GPUProgram(const std::string &name)
|
|
|
|
: m_name(name), m_maxVertices(0), m_bound(false) {
|
|
|
|
}
|
|
|
|
|
|
|
|
GPUProgram::~GPUProgram() {
|
|
|
|
}
|
2011-02-24 03:45:49 +08:00
|
|
|
|
|
|
|
void GPUProgram::setSourceFile(EType type, const fs::path &path) {
|
|
|
|
fs::ifstream ifs(path);
|
|
|
|
if (ifs.fail() || ifs.bad())
|
|
|
|
Log(EError, "Unable to load GPU program \"%s\"",
|
2011-07-27 23:11:57 +08:00
|
|
|
path.file_string().c_str());
|
2011-02-24 03:45:49 +08:00
|
|
|
std::string code, line;
|
|
|
|
|
|
|
|
while (getline(ifs, line)) {
|
|
|
|
code += line;
|
|
|
|
code += "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
ifs.close();
|
|
|
|
setSource(type, code);
|
|
|
|
}
|
2010-08-10 01:38:37 +08:00
|
|
|
|
|
|
|
std::string GPUProgram::toString() const {
|
|
|
|
std::ostringstream oss;
|
|
|
|
oss << "GPUProgram[name = '" << m_name<< "'";
|
|
|
|
if (m_maxVertices != 0)
|
|
|
|
oss << ", maxVertices=" << m_maxVertices;
|
|
|
|
oss << "]";
|
|
|
|
return oss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
MTS_IMPLEMENT_CLASS(GPUProgram, true, Object)
|
|
|
|
MTS_NAMESPACE_END
|