00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Kutumov Alexey * 00003 * ru.pixel@gmail.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00033 #include "gl_Cg_shader_system/gl_Cg_code_instructor.h" 00034 00035 #include "gpucalc/task.h" 00036 00037 namespace gpucalc 00038 { 00039 namespace debugger 00040 { 00041 00042 const std::string GLCgCodeInstructor::mSourceFooter = "\ 00043 float4 float4_cast_debug(float x)\ 00044 {\ 00045 return float4(x,0,0,0);\ 00046 }\ 00047 float4 float4_cast_debug(float2 x)\ 00048 {\ 00049 return float4(x,0,0);\ 00050 }\ 00051 float4 float4_cast_debug(float3 x)\ 00052 {\ 00053 return float4(x,0);\ 00054 }\ 00055 float4 float4_cast_debug(float4 x)\ 00056 {\ 00057 return x;\ 00058 }\n\n"; 00059 00060 00061 GLCgCodeInstructor::GLCgCodeInstructor(): CodeInstructor(_GLCgCodeInstructorName), mOriginalSource() 00062 { 00063 } 00064 00065 00066 GLCgCodeInstructor::~GLCgCodeInstructor() 00067 { 00068 } 00069 00070 00071 std::string GLCgCodeInstructor::instruct(size_t line, const std::string & variable) 00072 { 00073 StringList ShaderSource = auxillary::StringUtil::split(mOriginalSource); 00074 ShaderSource.insert(ShaderSource.begin() + line - 1, std::string("debug(float4_cast_debug(" + variable + "));")); 00075 return mSourceFooter + auxillary::StringUtil::concatenate(ShaderSource); 00076 } 00077 00078 00079 bool GLCgCodeInstructor::isCycle(size_t line) const 00080 { 00081 return false; 00082 } 00083 00084 00085 bool GLCgCodeInstructor::isExternalFunctionCalling(size_t line) const 00086 { 00087 return false; 00088 } 00089 00090 00091 size_t GLCgCodeInstructor::getEndOfCycle(size_t line) const 00092 { 00093 return -1; 00094 } 00095 00096 00097 std::string GLCgCodeInstructor::getExternalFunctionName(size_t line) const 00098 { 00099 return ""; 00100 } 00101 00102 00103 size_t GLCgCodeInstructor::getExternalFunctionBody(const std::string & FunctionName) const 00104 { 00105 return -1; 00106 } 00107 } 00108 }