 |
www.gpgpu.org General Purpose Computation on GPUs
|
| View previous topic :: View next topic |
| Author |
Message |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Fri Mar 16, 2007 9:19 am Post subject: MRT - CG error: "The program could not load" |
|
|
Hello everyone,
I'm having troubles with my CG fragment program which should output different colors to different textures (I simplified the shader for testing purposes). Therefor I set up my framebuffer object for multiple render targets.
The CG Compiler uses the fragment profile "CG_PROFILE_ARBFP1" which supports 4 Color Attachments. But erverytime I run my application, I get an CG compiler error which says "The program could not load".
Here is my fragment shader code:
| Code: | void pixel_main( out float4 color1 : COLOR0,
out float4 color2 : COLOR1)
{
color1 = float4(0,1,1,1);
color2 = float4(1,0,0,1);
} |
if I run my program without the color2 = float4(1,0,0,1); statement, the shader is compiled without an error.
Even if i did not set up the fbo correct, the shader should compile, right?
well, i dont guess, that there is an error in my fbo code, because it works fine with my other shaders (which dont use mrt).
could anyone please help me solving this problem?
thanks in advance  |
|
| Back to top |
|
 |
Chris Dodd GP
Joined: 17 Feb 2005 Posts: 161
|
Posted: Tue Mar 20, 2007 6:43 pm Post subject: |
|
|
| That error means that the program compiled just fine, but there was some problem loading it into the driver. I would guess that you're trying to run on hardware that does not support multiple render targets. What hardware are you trying to use? Does glxinfo show support for ARB_draw_buffers? |
|
| Back to top |
|
 |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Wed Mar 21, 2007 9:59 am Post subject: |
|
|
hello,
thanks for your reply
i am using a sapphire graphics card with an ATI Radeon X1950 Pro GPU. And yes, it supports the GL_ARB_draw_buffers extension (detected with OpenGL Extension viewer and glGetString(GL_EXTENSIONS) ^^ ). I also googled for the CG_PROFILE_ARBFP1 which the CG compiler uses for compiling the fragment program. I read several times, that MRT is supportet by this profile. I even compiled the program thrugh the command line, and it compiles without errors.
maybe theres an error in my framebuffer code. so i decided to shrink down the code and just do the necessary things (setting up OpenGL, glew, framebuffer and cg).
Maybe someone could have a look at this, that would be nice
the code initializes GLUT, GL and Glew.
then 2 Textures are created and attached to the framebuffer.
finally the CGcontext is created and the fragmentprogram is loaded.
and this is the point where i get an error message telling me "CG Error : The program could not load".
| Code: |
void main(int argc, char** argv)
{
initGLUT(argc, argv);
InitGL();
initGlew();
//create Textures
GLuint tex1, tex2;
//texture settings
GLenum texTarget = GL_TEXTURE_2D;
GLenum texInternalFormat = 3;
GLenum texFormat = GL_RGB;
//texture1
glGenTextures(1, &tex1);
glBindTexture(texTarget,tex1);
// turn off filtering and wrap modes
glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(texTarget, 0, texInternalFormat, 512, 512, 0, texFormat, GL_UNSIGNED_BYTE, 0);
if (glGetError() != GL_NO_ERROR)
printf("error creating tex1\n");
//texture2
glGenTextures(1, &tex2);
glBindTexture(texTarget, tex2);
// turn off filtering and wrap modes
glTexParameteri(texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(texTarget, 0, texInternalFormat, 512, 512, 0, texFormat, GL_UNSIGNED_BYTE, 0);
if (glGetError() != GL_NO_ERROR)
printf("error creating tex2\n");
//framebuffer
GLuint fb;
glGenFramebuffersEXT(1, &fb);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, texTarget, tex1, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, texTarget, tex2, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
GLenum drawbuffers[] = { GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT};
glDrawBuffers(2, drawbuffers);
CheckFramebufferStatus(); // returns: framebuffer COMPLETE
//setup CG
cgSetErrorCallback(cgErrorCallback);
cgContext = cgCreateContext();
fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
if (fragmentProfile == CG_PROFILE_UNKNOWN)
printf("error loading fragmentprofile\n");
cgGLSetOptimalOptions(fragmentProfile);
//Load Shader
CGprogram fragmentProgram;
fragmentProgram = cgCreateProgramFromFile(cgContext, CG_SOURCE, "CGShaders/ShaderMRTTest.cg", fragmentProfile, "pixel_main", 0);
cgGLLoadProgram(fragmentProgram);
}
|
the shadercode is the same as the one in my previous post.
i would be sooooo happy if anyone could point me out an error in my code
thank you |
|
| Back to top |
|
 |
Chris Dodd GP
Joined: 17 Feb 2005 Posts: 161
|
Posted: Wed Mar 21, 2007 6:19 pm Post subject: |
|
|
Assuming that the compile succeeded (and it sounds like it did), that error means that the Cg runtime's call to glProgramStringARB failed, usually due to the driver not liking the asm code produced by the compiler for some reason. You can use
| Code: | | cgGetProgramString(fragmentProgram, CG_COMPILED_PROGRAM |
to get the assembly string and
| Code: | | glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos) |
to get the driver's error position in the asm string.
Its possible this could be either a compiler bug (generating invalid asm code) or a driver bug (not accepting valid asm code) |
|
| Back to top |
|
 |
ppfb .
Joined: 21 Jan 2007 Posts: 22 Location: Brazil
|
Posted: Thu Mar 22, 2007 1:39 am Post subject: |
|
|
How can you see that you are using the CG_PROFILE_ARBFP1?
Using the "fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); ", CG_GL_FRAGMENT = CG_PROFILE_ARBFP1?
I tought that using this: "cgGLSetOptimalOptions(cgFragmentProfile);" after that code i would use the "best" profile for my video board.
I know that this isn't the best place to ask this, but thanks anyway |
|
| Back to top |
|
 |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Thu Mar 22, 2007 9:20 am Post subject: |
|
|
@ppfb:
i just debuged my application and set a breakpoint at the line "fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);". After this command, the variable fragmentProfile contained the value "CG_PROFILE_ARBFP1". I guess that cgGLGetLatestProfile loads the best profile for your graphics card and cgGLSetOptimalOptions sets up the compiler for this profile. Please correct me if i am wrong.
@Chris Dodd
I just added the two lines of code from your post at the end of my function and got the following output:
| Code: |
CG ERROR : The program could not load.
ASM Code:
------------------------------
!!ARBfp1.0
OPTION ARB_draw_buffers;
# cgc version 2.0.0001, build date Jan 22 2007 00:22:23
# command line args: -q -profile arbfp1 -entry pixel_main NumTemps=64 NumInstructionSlots=1024 MaxLocalParams=64 NumTexInstructionSlots
=512 NumMathInstructionSlots=512 MaxTexIndirections=512 MaxDrawBuffers=4
# source file: CGShaders/ShaderMRTTest.cg
#vendor NVIDIA Corporation
#version 2.0.0.1
#profile arbfp1
#program pixel_main
#var float4 color0 : $vout.COLOR0 : COL : 0 : 1
#var float4 color1 : $vout.COLOR1 : COL1 : 1 : 1
#const c[0] = 1 0
PARAM c[1] = { { 1, 0 } };
MOV result.color[1], c[0].xyyx;
MOV result.color, c[0].yxxx;
END
# 2 instructions, 0 R-regs
------------------------------
error pos: 18
Press any key to continue
|
As you can see, glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos) returned the value 18. If I run my application without "color2 = float4(1,0,0,1); " in my fragmentshader code, the returned value is -1.
I dont know what this error position 18 should tell me, because the code listing only contains 17 loc.
maybe you or anyone else could tell me
EDIT:
why is the vendor "NVIDIA Corporation". I am using an ATI graphics card. Or is vendor == vendor of profile "CG_GL_FRAGMENT"? i am confused  |
|
| Back to top |
|
 |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Thu Mar 22, 2007 12:17 pm Post subject: |
|
|
ok some news according my problem:
i just ported my CG shader stuff to GLSL, AND IT WORKS. Unfortunatly, i dont want to use GLSL because my whole framework and shaders are written for CG.
So, obviously the CG compiler has some big problems compiling the mrt shader code for my specific graphics card (Sapphire ATI Radeon X1950 Pro). i am not familiar with assembler, but surely someone else is. maybe, if compiling wont work, i can adjust the previous posted asm code and then parse the parameter CG_OBJECT instead of CG_SOURCE to the shader loading routine.
anyway, i would prefer a better solution, like parsing several additional compiler parameters.
please help me
thank you all |
|
| Back to top |
|
 |
Chris Dodd GP
Joined: 17 Feb 2005 Posts: 161
|
Posted: Thu Mar 22, 2007 5:03 pm Post subject: |
|
|
| 18 is the location in the string in characters, so the error is at the 'A' in the line "OPTION ARB_draw_buffers" -- apparently your driver doesn't accept that option. You could try compiling your program with extra options "-po", "ATI_draw_buffers" to get it to use that extension instead. Sounds like a bug in the ATI driver where it advertises support for ARB_draw_buffers but doesn't accept it (only ATI_draw_buffers). |
|
| Back to top |
|
 |
ppfb .
Joined: 21 Jan 2007 Posts: 22 Location: Brazil
|
Posted: Fri Mar 23, 2007 2:20 am Post subject: |
|
|
jan3D, Thanks for the information...but, what is the command to see the profile loaded? Are you using cgGetProfileString()? or comparing to every profile to see wich one is iqual?
Thanks again |
|
| Back to top |
|
 |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Fri Mar 23, 2007 9:52 am Post subject: |
|
|
Nice, nice
it works. thanks a lot Chris Dodd, you saved my life
To whom it meight interest, here is the code which makes the compiler use "ATI_draw_buffers" instead of "ARB_draw_buffers"
| Code: |
const char* compilerArguments[] = {"-po", "ATI_draw_buffers", 0};
fragmentProgram = cgCreateProgramFromFile( cgContext,
CG_SOURCE,
"CGShaders/ShaderMRTTest.cg",
fragmentProfile,
"pixel_main",
compilerArguments);
|
@ppfb
after you called
| Code: | | fragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); |
the variable contains the loaded profile. you could use cgGetProfileString(fragmentProfile) to print the profile to the console or even compare it to every existing profile, thats up to you. I dont use neither of them. For me, it was just important to know which profile the compiler uses. So i could assure that my profile supports MRTs. The fastest solution for me was letting my visual studio 2003 debug the code ^^ |
|
| Back to top |
|
 |
shahzadmasih .
Joined: 26 Mar 2007 Posts: 1 Location: UK
|
|
| Back to top |
|
 |
jan3D .
Joined: 16 Mar 2007 Posts: 8 Location: Mannheim University, Germany
|
Posted: Tue Mar 27, 2007 7:32 am Post subject: |
|
|
| I dont know if I can help you, so why dont you just post your question/-s in this thread? |
|
| Back to top |
|
 |
Spooky .
Joined: 08 Dec 2007 Posts: 3
|
Posted: Sat Dec 08, 2007 4:13 pm Post subject: |
|
|
| jan3D wrote: | Nice, nice
it works. thanks a lot Chris Dodd, you saved my life
To whom it meight interest, here is the code which makes the compiler use "ATI_draw_buffers" instead of "ARB_draw_buffers"
| Code: |
const char* compilerArguments[] = {"-po", "ATI_draw_buffers", 0};
fragmentProgram = cgCreateProgramFromFile( cgContext,
CG_SOURCE,
"CGShaders/ShaderMRTTest.cg",
fragmentProfile,
"pixel_main",
compilerArguments);
|
|
Hello,
as I already posted in another thread, I am having trouble using 4 render targets with the ARBFP1 profile. It always says | Quote: | ./shader/shader.cg(36) : error C5102: output semantic attribute "COLOR" has too big of a numeric index (2)
./shader/shader.cg(37) : error C5102: output semantic attribute "COLOR" has too big of a numeric index (3) | when using COLOR2 and COLOR3 as output variables. I get this error when I use cgCreateProgram/cgCreateProgramFromFile, I already tried the arguments | Code: | | const char* fragment_options[] = {"-po","ATI_draw_buffers","-profileopts","MaxDrawBuffers=4",0}; | but it has no effect. However, when I use cgc.exe manually, the program is compiled without any errors (and I see "OPTION ATI_draw_buffers" in the output). What could I be doing wrong? |
|
| Back to top |
|
 |
Chris Dodd GP
Joined: 17 Feb 2005 Posts: 161
|
Posted: Mon Dec 10, 2007 9:16 pm Post subject: |
|
|
| My best guess is that you have an old version of Cg installed on your machine which doesn't support MRT, and you're getting that version of cg.dll when you run your program and the newer version of cgc.exe when you run that for comparison. |
|
| Back to top |
|
 |
Spooky .
Joined: 08 Dec 2007 Posts: 3
|
Posted: Mon Dec 10, 2007 10:53 pm Post subject: |
|
|
| Chris Dodd wrote: | | My best guess is that you have an old version of Cg installed on your machine which doesn't support MRT, and you're getting that version of cg.dll when you run your program and the newer version of cgc.exe when you run that for comparison. |
Nah, I figured it out already, and... well I am embarrassed . It was a copy & paste error... I accidentally used the Vertex profile when loading the fragment program. It all works fine now  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|