openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.56k forks source link

ofFBO crashing on allocate #653

Closed jvcleave closed 13 years ago

jvcleave commented 13 years ago

MacPro1,1 ATI Radeon X1900 XT:

Using this code

void testApp::setup(){
    ofSetLogLevel(OF_LOG_VERBOSE);
    fboObject.allocate(500, 500);
}

Console reads OF: OF_LOG_NOTICE: ofFbo::checkGLSupport() maxColorAttachments: 4 maxDrawBuffers: 4 maxSamples: 6

I get a EXC_BAD_ACCESS error on line 370 of ofFBO.cpp

Here is a screenshot of the debugger http://imbx.us/Xld.png

another with ofFBO::Settings expanded http://imbx.us/X9f1.png

ofTheo commented 13 years ago

hmm - quick check. does it work if the fbo is 512 x 512 ?

jvcleave commented 13 years ago

I am on a different machine (same model MacPro1,1 but with a NVIDIA GeForce 7300 GT) but it is still crashing in the same place (width/height set to 500 or 512).

OF: OF_LOG_NOTICE: ofFbo::checkGLSupport() maxColorAttachments: 4 maxDrawBuffers: 4 maxSamples: 0

I can re-check on the original machine in a few hours

ofTheo commented 13 years ago

can you try this:

//--------------------------------------------------------------
void testApp::setup(){
    fbo.allocate(500, 500, GL_RGBA);
}

//--------------------------------------------------------------
void testApp::update(){

}

//--------------------------------------------------------------
void testApp::draw(){

    fbo.begin();
        ofClear(255, 255, 255, 255);
        ofSetColor(255, 0, 0);
        ofCircle(mouseX, mouseY, 100);
    fbo.end();

    ofSetColor(255);
    fbo.draw(0, 0);
}
ofTheo commented 13 years ago

ps - did you pull from the latest git? also make sure you have ofFbo fbo; in testApp.h

jvcleave commented 13 years ago

I pulled earlier today and just ran the above code and got the same crash.

I just pulled again

From https://github.com/openframeworks/openFrameworks 263718d..ef806b1 master -> origin/master Updating 263718d..ef806b1

and cleaned all targets, ran again and got the same error

jvcleave commented 13 years ago

I've uploaded the test project here in case it helps https://github.com/jvcleave/FBOTest

ofTheo commented 13 years ago

hmm what OS are you running on ? can you post detailed info about your setup?

also maybe try ofDisableArbTex() at the beginning of testApp setup and try sizes of 512 512

jvcleave commented 13 years ago

Still crashing :/

Is there a 0062 project you would like me to try?

OS X 10.6.8

Model Name: Mac Pro Model Identifier: MacPro1,1 Processor Name: Dual-Core Intel Xeon Processor Speed: 2.66 GHz Number Of Processors: 2 Total Number Of Cores: 4 L2 Cache (per processor): 4 MB Memory: 7 GB Bus Speed: 1.33 GHz Boot ROM Version: MP11.005C.B08 SMC Version (system): 1.7f10

NVIDIA GeForce 7300 GT:

Chipset Model: NVIDIA GeForce 7300 GT Type: GPU Bus: PCIe Slot: Slot-1 PCIe Lane Width: x16 VRAM (Total): 256 MB Vendor: NVIDIA (0x10de) Device ID: 0x0393 Revision ID: 0x00a1 ROM Revision: 3008 Displays: Cinema: Resolution: 1680 x 1050 Pixel Depth: 32-Bit Color (ARGB8888) Display Serial Number: 2A7022K2UFZ Main Display: Yes Mirror: Off Online: Yes Rotation: Supported BenQ FP202W: Resolution: 1680 x 1050 @ 60 Hz Pixel Depth: 32-Bit Color (ARGB8888) Mirror: Off Online: Yes Rotation: Supported

jvcleave commented 13 years ago

I uploaded a 0062 version that uses ofxFbo that works with your example

https://github.com/jvcleave/FBOTest_0065

ofTheo commented 13 years ago

@memo @arturoc can you take a look at this?

arturoc commented 13 years ago

is working for me without problem, which line are you getting the crash? the line 370 which you tell about in the first comment is a comment in the current version

arturoc commented 13 years ago

i had some modifications in my code, sorry, so line 370 is:

glGenFramebuffers(1, &fbo);

right? is super weird that is crashing there as there's no heap memory allocation or nothing similar there. can you upload somewhere a screenshot of the backtrace to see some more info?

jvcleave commented 13 years ago

yeah - that is the line. I just tested on my Macbook Pro 2011 without any errors so may it's something with older cards?

Here are screens of me stepping through - is that what you needed or is there a way of getting more info? (sorry - finding a host for the images)

jvcleave commented 13 years ago

Here is a set of the screenshots http://www.flickr.com/photos/jvcleave/5953145814/in/set-72157627228766992/lightbox/

jvcleave commented 13 years ago

Just did this.

in testApp.h

GLuint fbo;

and in testApp::setup

glGenFramebuffers(1, &fbo);

007 crashed, 0062 was fine

jvcleave commented 13 years ago

So it looks like my version of 007 is using glGenFramebuffers from openFrameworks/libs/glew/include/GL/glew.h

and my 0062 install is using glGenFramebuffers from /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/glext.h

ofTheo commented 13 years ago

oh interesting. in testApp::setup can you try putting this line first?

glewInit();

arturoc commented 13 years ago

mmh, glewInit should have been called by then. does fbo's work at all in that computer with 0062?

i think that function is null because it's not supported, probably we need to check if it exists before trying to call it

arturoc commented 13 years ago

can you test with the last commit? i've added some functionality to check if the graphics card supports fbos

ofTheo commented 13 years ago

but for him it does exist - in 0062 its being defined by: /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/glext.h

and that works.

it could be a bug with glew setting a different address than glext

ofTheo commented 13 years ago

hmm could it be related to this: http://www.gamedev.net/topic/570462-glgenframebuffers-null-pointer-in-32-context-but-works-with-31/page__p__4644630#entry4644630

can you also try this: http://www.gamedev.net/topic/570462-glgenframebuffers-null-pointer-in-32-context-but-works-with-31/page__p__4644653#entry4644653

arturoc commented 13 years ago

yes, i guess so, just wanted to test if gl is detecting the extension at all.

also can you see what's the address of that function? i guess you can just see it by passing the mouse over it or adding a watch in the debugger

El mar, 19-07-2011 a las 05:29 -0700, ofTheo escribió:

but for him it does exist - in 0062 its being defined by: /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/glext.h

and that works.

it could be a bug with glew setting a different address than glext

arturoc commented 13 years ago

yeah, that seems like it, try adding:

glewExperimental= GL_TRUE;

before glewInit in ofAppRunner.cpp line 96

jvcleave commented 13 years ago

Test 1 NVIDIA GeForce 7300 GT

pulled OF

From https://github.com/openframeworks/openFrameworks ef806b1..51ffdb7 master -> origin/master Updating ef806b1..51ffdb7

Cleaned all targets

Still crashes

Console output:

OF: OF_VERBOSE: FBO supported OF: OF_LOG_NOTICE: ofFbo::checkGLSupport() maxColorAttachments: 4 maxDrawBuffers: 4 maxSamples: 0

glew.h leads to openFrameworks/libs/glew/include/GL/glew.h via Apple+clicking glGenFramebuffers in Xcode

//=====================

Test 2 NVIDIA GeForce 7300 GT

void testApp::setup(){ ofSetLogLevel(OF_LOG_VERBOSE); glewInit(); fbo.allocate(500, 500, GL_RGBA); }

Still crashes

I then re-ran with a breakpoint on glewInit and get this while stepping in the debugger

1 0x0001f82e in _glewInit_GL_VERSION_1_2 at iostream:77

//===================== Test 3

Changed openFrameworks/libs/openFrameworks/app/ofAppRunner.cpp

void ofSetupOpenGL(ofPtr windowPtr, int w, int h, int screenMode){ window = windowPtr; window->setupOpenGL(w, h, screenMode); glewExperimental= GL_TRUE;

ifndef TARGET_OPENGLES

GLenum err = glewInit();
if (GLEW_OK != err)
{
    /\* Problem: glewInit failed, something is seriously wrong. */
    ofLog(OF_LOG_ERROR, "Error: %s\n", glewGetErrorString(err));
}

endif

ofSetCurrentRenderer(ofPtr<ofBaseRenderer>(new ofGLRenderer(false)));
//Default colors etc are now in ofGraphics - ofSetupGraphicDefaults
//ofSetupGraphicDefaults();

}

Cleaned all targets

SUCCESS! TEST RAN!

Console output OF: OF_VERBOSE: FBO supported OF: OF_LOG_NOTICE: ofFbo::checkGLSupport() maxColorAttachments: 4 maxDrawBuffers: 4 maxSamples: 0 OF: OF_LOG_NOTICE: FRAMEBUFFER_COMPLETE - OK

Thanks guys! will test on other machine as well - need anything else?

arturoc commented 13 years ago

cool, thanks, have just uploaded the fix

jvcleave commented 13 years ago

Just wanted to confirm this also worked on the original system with the ATI Radeon X1900 XT.

Thanks again!