Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About billouparis

  • Rank
  1. Hello mhagain, and thank you for your answers. I tried the solution with mipmapping, unfortunately it really does not work for me. I changed the position of my glGenerateMipmap function call, which allowed me to get rid of the crash I had, which is a good thing. I used the glTexParameteri function parameters you suggested too. But the result is quite messy, my textures are not rendered correctly anylonger, there are part of texture missing, or completely mixed up. Also the rendering performance is very slow, even when I'm using smaller textures that worked without using mipmap. Maybe I forgot to set another state or something? Bill
  2. Hello Katie, from what I read here and there I kinda come to the same conclusion you exposed in your post, thank you so much for detailing the mechanism that may occur. Now I still need to go further and dig deeper to find answers to the following questions: 1 - how can I know the total amount of texture RAM managed by my GPU, 2 - how can I update the total amound of texture RAM managed by my GPU, 3 - what about texture units, what are they used for exactly, how could they help me in getting better performances, 4 - where is this texture RAM, is it simply a partition of my current board RAM, or has the GPU his own RAM. If it is only a partition, why can't my GPU basically access other part of my RAM, or why does the upload/swapping require so much time, since all my texture images are loaded into RAM in the first place? 5 - why can't I simply use mimaps in openGL ES 2.0? 6 - if I was to use different image sizes for the same texture and use them depending on the distance of the objects on the screen, how can I know this distance to be able to bind the right texture? Thank you, Bill
  3. Hello, I'm rather a newbie with openGL / openGL ES. I have one application with lots of objects being rendered in the same scene, and with lots of texture maps based on images. When i'm rendering my scene with 50 objects (all using different textures), the performances are alright (30 ms), when rendering 1 more object (so 51 objects), then suddenly I get a drop in performances (500ms), only for one more object added to the scene! I have very large texture images, like 10 textures are 1024x1024, some are 512x512, and very few are 128x128 or 256x256. If I reduce the size of the very large textures to 512x512 instead of 1024x1024, then the performances for 51 objects are again ok (30ms). Which basically solves my problem, but I would really like to understand why there is this drop in performances for only one more texture to draw. I have also tried to use mipmap textures, by calling the following methods: glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture( GL_TEXTURE_2D, textures[indexTextureBuffer] ); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, image2.width(), image2.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image2.bits()); but this previous code though compiles alright, but then I have a crash when running the application. So I removed the line glGenerateMipmap(GL_TEXTURE_2D); and changed the two following lines back to: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); I understand I have a problem with large size texture images, but what I don't understand is why it happens so suddenly, with such a drop in performances when I simply add a texture image (even if it is a large one, there are already other large textures in use), and why my issue is not progressive? Can somebody point me to some article that could explain this issue to me, so I can understand what openGL is doing at this moment that could explain this drop in performance? Thank you, Bill
  4. Ok so apparently my problem is related to the textures, I'm using now a single texture for all objects, and the whole thing is rendering very fast. I wonder why is there such a gap, when adding only one object with another texture. Anybody knows? Thank you, Bill
  5. I have done the following test: paint() { glFinish(); startClock(); draw3D(); glFinish() stopClock(); } case A -> draw3D draws 50 objects, clock is 40ms case B-> draw3D draws 51 objects, clock is 500 ms. The extra object is basically the same type as the others already drawn, no extra number of triangles, no specific texture involved. I really don't get it then, do you? [s]Also I tested my application in a very small viewport to be sure the fragment shader was not faulty at any time, when drawing inside a 50*30pxl frame, I get the exact same rendering time measures.[/s] This is apparently not true. I just re-tested my application with a very simple fragment shader simply displaying the same color for each fragment, and the speed is around 35ms with the whole scene objects. So the issue is maybe located in the textures processing. I am gonna try maybe to sort the objects depending on their textures to see if it can boost the whole rendering. Also I have some quite large images for the textures, in tiff format, and maybe this can also be the problem. Beside I did not use the texture units, I simply created my textures this way: glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture( GL_TEXTURE_2D, textures[indexTextureBuffer] ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, image2.width(), image2.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image2.bits()); And then I use them this way: glBindTexture( GL_TEXTURE_2D, texturesArray[group->material].texture /* textures[]*/ ); Bill
  6. Hello mhagain, the article is indeed very interesting, although I don't know what I could change in my code to try to follow these hints at this moment. Thank you, Bill
  7. Hello kdmiller3, thank you for your answer. Following your comments, I added a call to glFinish() in my code, and tried with only the first 50 objects, but in this case they are rendered very quickly. So I don't know if my problem is really related to the number of rendering commands in the openGL queue then. But let's considered this is really the problem, then I am not sure I understood your last suggestion to help get my problem solved? Because to create one frame of my scene I have to have all of my objects drawn. Let me give you another detail concerning my application: it is drawing a 3D scene with less than 17000 triangles, and some image textures (all stored in unit 0 as far as I understand this, well, at least I don't mention anything in my code for this so I guess it is what is done), and the user can move around the scene (changing the modelview matrix, applying a rotation computation). When the use begins to move the mouse the complete scene must be redrawn according to the new values of my modelview matrix. And the thing is, when drawing only 50 objects, it goes smoothly, but then if I add only one object, the redraw is performed very slowly, like one frame per 500 ms or so. I wonder how I could determine of the openGL rendering queue reaches its limit at some point, is there a method to test this? Thank you, Bill
  8. Hello, my problem has been solved.
    I did not bind/use the program before initializing the uniform variable. As simple as this!
    We can close this topic.
  9. Hello, I have this weird issue, working with openGL ES 2.0 on iMx51 Freescale board. My application is drawing around 80 complex 3D objects. based on VBO, and glDrawArrays. I can easely draw let's say something like 50 objects in a loop, with a very fast glDrawArrays (less than 1 ms each call to glDrawArrays even for object with more than 3000 triangles), now If I try to draw only one object more, so let's say a 51st object, then some calls to glDrawArrays suddenly require more time (around 30ms for most of these calls). This 51st object has nothing particular compared to the other, small amount of triangles. CASE A unsigned int index = 0; Foreach (object, in objectGroup) { if (index != 3) { ... glDrawArrays(GL_TRIANGLES, 0, object->numberOfTriangles * 3); } index++ } CASE B unsigned int index = 0; Foreach (object, in objectGroup) { if (1) { ... glDrawArrays(GL_TRIANGLES, 0, object->numberOfTriangles * 3); } index++ } In CASE A, each call to glDrawArrays require less than 1ms in CASE B, there are around 10 calls to glDrawArrays that suddenly require around 30ms, when index == 3 the glDrawArrays require less than 1 ms. There are no gl error after the calls to glDrawArrays. Any idea what could be the problem here? I removed all texture drawing, and replace them by unique color drawing, the problem is the same. Thank you for any hint how I could progress with this issue. Regards, Bill
  10. billouparis

    More than one shader programs [SOLVED]

    Thank you for your comments, I still have the issue though, but I finally ended with using a single program to get rid of my problems. Bill
  11. billouparis

    More than one shader programs [SOLVED]

    Anybody? Thanks, Bill
  12. billouparis

    More than one shader programs [SOLVED]

    Hello, i gathered up a small example program which presents the same defect, I will attach it to this email if you are willing to help me Inside the draw function, there is 4 defines macro, you can select one or the other, and see the result! Of course, you need Qt, to get it work. But you can still look at the source code. Thank you,
  13. billouparis

    More than one shader programs [SOLVED]

    No, no, no... you certainly don't need anything like this. You can swap shaders all you want and it won't invalidate anything, and you don't need to call glFlush or glFinish for any reason here. Once you issue a draw command, it will be drawn, and there's nothing you can do to stop it, intentionally or accidentally. You must be doing something else that you're not accounting for here that is causing your second object not to be rendered. There's nothing theoretically wrong with either of the program flows you've posted. If you can't figure it out, post your real code and let someone take a look at it. [/quote] Hello Karwosts, thank you for your answer. My code is based on Qt QGLWidget class, and the rendering method is a bit complex because it is based on some structures of 3D objects. But maybe it can still be useful by someone to help me with my issue, so here it goes: PaintGL() is called each time we want the scene redrawn, and an automatic swapbuffers is executed at the end of this function, I tried to simplify it as much as possible. As you can see I have two program already linked, one is used for most of the objects in the scene, the second one called qGLShaderProgramScreen is used only for one specific object (with index 59 in my list of objects in my scene): [color="#808000"]void myWidget::paintGL() { // Clear the colorbuffer and depth-buffer QColor bgColor(10,15,255,255); qglClearColor( bgColor ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); model->draw(qGLShaderProgramTextures, qGLShaderProgramScreen, fAngle, yValue, zValue); } Then the model->draw(...) call is as follow: [color="#808000"]void Model::draw(QGLShaderProgram *programTextures, QGLShaderProgram *programScreen, GLfloat fAngle, GLfloat yValue,GLfloat zValue) { bool status = false; QGLShaderProgram *program = NULL; qDebug("model draw"); QMatrix4x4 matModelViewStaticParts ( 1.0f, 0.0, 0.0, 0.0, /*second row*/ 0.0, 1.0, 0.0, yValue, /*thirs row*/ 0.0, 0.0, 1.0, zValue, /*last row*/ 0.0, 0.0, 0.0, 1.0); //Construct all textures only once static bool loop = 1; if (1 == loop) { constructAllTextures(); constructVBO(); loop = 0; } unsigned int index = 0; GLMgroup* group; group = model->groups; unsigned int indexColor = 0; //main loop through all objects in the scene to render foreach(ModelGroup grp, groups) { //Here we swap between shaderprogram when object to be drawn is index 59 if (index != 59) { program = programTextures; } else { program = programScreen; } //bind either program1 or program2 depending on the object to render status = program->bind(); if (status == false) { qDebug()<<"Error while binding program "; exit(1); } //retrieve the corresponding material/texture //qDebug()<<model->materials[group->material].colorMapFilename; if (strcmp (model->materials[group->material].colorMapFilename, "default") != 0) { glBindTexture( GL_TEXTURE_2D, textures[group->material] ); } else { glBindTexture( GL_TEXTURE_2D, NULL ); } // Set the sampler texture unit to 0 GLint g_hSamplerLoc = 0; g_hSamplerLoc = program->uniformLocation("s_texture"); program->setUniformValue(g_hSamplerLoc, 0); g_hSamplerLoc = program->uniformLocation("g_matModelView"); program->setUniformValue( g_hSamplerLoc, *composeeScene); //vertices //bind vertex buffer object status = buf[index]->bind(); if (status == false) { qDebug()<<"error binding buffer"; } program->enableAttributeArray(0); program->setAttributeBuffer(0, GL_FLOAT, 0, 3, 0); program->enableAttributeArray(1); program->setAttributeBuffer(1, GL_FLOAT, group->numtriangles * 3*3*sizeof(float), 3, 0); program->enableAttributeArray(2); program->setAttributeBuffer(2, GL_FLOAT, 2 * group->numtriangles * 3*3*sizeof(float), 3, 0); glDrawArrays(GL_TRIANGLES, 0, group->numtriangles*3); program->disableAttributeArray(0); program->disableAttributeArray(1); program->disableAttributeArray(2); index++; group = group->next; indexColor++; } } So when running the previous code, all my objects are drawn, and object index 59 is not rendered at all. Now if I change this: [color="#008000"]//main loop through all objects in the scene to render [color="#808000"]foreach[color="#000000"](ModelGroup grp[color="#000000"], groups[color="#000000"]) [color="#000000"]{ [color="#006400"]//Here we swap between shaderprogram when object to be drawn is index 59 [color="#c0c0c0"] [color="#808000"]if [color="#000000"](index [color="#000000"]!= [color="#000080"]59[color="#000000"]) [color="#000000"] { program [color="#000000"]= programTextures[color="#000000"]; [color="#000000"]} [color="#808000"]else [color="#000000"]{ program [color="#000000"]= programScreen[color="#000000"]; [color="#000000"]} with this: [color="#008000"]//main loop through all objects in the scene to render program = programTextures; [color="#808000"]foreach[color="#000000"](ModelGroup grp[color="#000000"], groups[color="#000000"]) [color="#000000"]{ [color="#c0c0c0"] [color="#006400"]//Here we swap between shaderprogram when object to be drawn is index 59 [color="#c0c0c0"] [color="#808000"]if [color="#000000"](index [color="#000000"]== [color="#000080"]59[color="#000000"]) [color="#000000"]{ [color="#c0c0c0"] program [color="#000000"]= programScreen[color="#000000"]; [color="#c0c0c0"] [color="#000000"]} [color="#000000"]Then all objects from index 59 to the end of my list of objects are drawn with the second shader program.
  14. Hello, I've been searching for an answer for this since days, and I am still stuck. I simply want to display 3 objects, using two different shader programs just like this: My first use-case was actually wrong, I spent a lot of time on this, and the use cases are as follow: draw() { glUseProgram(program1); drawObject1(); glUseProgram(program2) drawObject2(); drawObject3(); } In this case, object 1 is drawn using program 1, and object 2 and object 3 are drawn using program 2. which is fine! But now I have this other use case causing the issue: draw() { glUseProgram(program1); drawObject1(); glUseProgram(program2) drawObject2(); glUseProgram(program1) drawObject3(); } then object 1 and object 3 are drawn using program1, whereas object 2 is not drawn at all. It looks like the fact to swap back to another program (program1) before the end of draw function would sort of invalidate the drawing made by program2. Maybe I should add some method to force the rendering in program2, before swapping back to program1? I tried to add some glFinish, and/or glFlush before swapping programs, but none of them helped in anyway to get my object 2 drawn…. Yes, I am Desperate! Any idea? Thank you!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!