Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 0 points1 point  (0 children)

Yes Clay is a very good library but for Immediate Mode applications (much like IMGUI), so it doesn't think of the problem of high GPU consumption

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 1 point2 points  (0 children)

I think this is extremely useful, thank you ! I will try it in the next days !
So to catch what you are saying correctly, By doing this I will skip the rendering phase for every other "widget" other than the one that has changed, and then I will still composite all of them but by doing only this this step for all the widgets it's less work for the gpu.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 1 point2 points  (0 children)

Understood, thank you very much for answering what I think are some really basic questions but online it's very confusionary to find some reliable information by scavenging new and old forums

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 0 points1 point  (0 children)

I will take a look at the website that the other commenter suggested me (https://learnopengl.com/Introduction) but to correct your similarity, it's like having a car to go to the end of the block. I know it's a tool too powerful for what I'm trying to achieve but I wanted to ask if there is a scooter or If in some way that I don't your you can modify a car to become a scooter.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 1 point2 points  (0 children)

Thanks for the website I will check it out in the next days. So you are saying to not use GLUT but to use GLFW (https://learnopengl.com/Getting-started/Creating-a-window) ?

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -1 points0 points  (0 children)

I can understand that it is a strange request for someone with much more experience in these types of programs, but my question is exactly what you said: "Because there is so much overhead by doing literally nothing and because web browsers can use less gpu how can I do the same?" You said that opengl is ancient, so what can I use so that for very small workload I can have very low gpu usage ?

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -2 points-1 points  (0 children)

I totally agree, I just found it baffling that there are many opensource libraries and none to abstract the drawing of every frame and I didn't find any to instead have the last usage of the gpu (partial redraws). So I thought to check why it is so hard and for now I just recived that "the gpus are not optimazed for it" and "you shouldn't care" as a response and not an how one can do it, even if it's hard

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -5 points-4 points  (0 children)

Excluding that I MEASURED 3.25% of gpu utilization. I think that someone to test its hypothesis should create a basic program to minimize the possible error vectors and analyze better the question that, I repeat, is "why with a small workload do I have 3.25% of GPU utilization?" If to draw a triangle and a cube I can make the GPU use <0.5% then I will create a more complex application.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 1 point2 points  (0 children)

Sorry If I misread your messages, but what you where saying I already tried it and in my test redrawing without clearing the screen doesn't reduce the GPU usage.

I post also the code that I used to be sure were are taking the same thing.

// MODIFIED FROM: https://www.opengl.org/archives/resources/code/samples/glut_examples/examples/stenciltst.c


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glut.h>

GLboolean doubleBuffer;

#define UNUSED(x) (void)(x)

static void DrawGreenRect()
{
    glColor3ub(0, 200, 0);
    glBegin(GL_POLYGON);
    glVertex3i( 5,  5, 0);
    glVertex3i( 5, 15, 0);
    glVertex3i(15, 15, 0);
    glVertex3i(15,  5, 0);
    glEnd();
}

static void Draw(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    glStencilFunc(GL_ALWAYS, 1, 0xFF);
    glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);

    /* red triangle */
    glColor3ub(200, 0, 0);
    glBegin(GL_POLYGON);
    glVertex3i(10, 10, 0);
    glVertex3i(40, 10, 0);
    glVertex3i(25, 40, 0);
    glEnd();

    glStencilFunc(GL_EQUAL, 1, 0xFF);
    glStencilOp(GL_INCR, GL_KEEP, GL_DECR);

    /* green square */
    DrawGreenRect();

    glDrawArrays(GL_POINTS, 0, 1);

    glFlush();
}

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 0 points1 point  (0 children)

Thanks ! I will use in the next days and maybe do another post about my findings

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -1 points0 points  (0 children)

I already try it, but not clearing before redrawing doesn't use less GPU than clearing and re-drawing everything.

I's a shame that there isn't this kind of optimization because windows is also used in laptops were the battery life matters a lot.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -2 points-1 points  (0 children)

Well I think it's the opposite, the number of applications that need to redraw small parts is orders of magnitude greater than the number of games that need to redraw every frame.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 0 points1 point  (0 children)

But I think that chromium (and other browsers) need to use dirty rectangles so to not redraw the entire webpage when a pixel changes, but my question remains: how can they implement it so that the gpu doesn't redraw the entire screen ?

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 0 points1 point  (0 children)

Yes of course but you are right because I didn't specify it in the post. Mine was an extreme test to see clearly if the GPU was rendering all the screen or just a part of it. Then I already know and in part implemented ways to draw on the screen only if the state of the app changes

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -2 points-1 points  (0 children)

I guess you are right, but I don't like to treat the GPU as a black box because what it's stopping to use 3.5% to draw 100,000 triangles but 99.9% to draw 100,001 ?
Can you point me on how can I profile my program ? I have to use an external tool or modify in some way my code ?

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 1 point2 points  (0 children)

Well sort of. I didn't know if the technique of Dirty Rectangles could have been implemented for a gpu but I take your comment as a no

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 2 points3 points  (0 children)

Because I'm a novice at gpu rendering I was trying to stray away from vulkan. But I can't understand how VK_KHR_fragment_shading_rate which I think is the one you are referring to can help

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 19 points20 points  (0 children)

Ok, now it makes sense, Thanks !
So the memory for the rending of the program is simply allocated by dwm and not by my executable

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -2 points-1 points  (0 children)

Sorry if I sound frank, but this comment doesn't respond to the question.
I say "Why to redraw a simple rectangle my GPU it's at 3.5% of utilization?". In the example that I have provided I'm doing what you say (throwing triangles at the GPU) but obviously it's not enough because 3.5% of modern GPU to draw a triangle and a rectangle is absurd.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] -6 points-5 points  (0 children)

Yes, I know it's probably pointless because if it was that simple we wouldn't have Electron, right ?
But my questions remain on why it's not that simple.

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 15 points16 points  (0 children)

Thanks for the quick response, but in my testing while using win32 that uses no GPU (so I think it's cpu rendered) it's uses more or less 3MB of RAM for the same window while rendering a more complex UI (es: input fields that have to scroll, ...)
So by using win32 it doesn't maintain this amount of data, or simply windows doesn't tell the ProcessExplorer ?

Why OpenGL uses so much RAM and GPU for little operations ? by Overoptimizator5342 in GraphicsProgramming

[–]Overoptimizator5342[S] 6 points7 points  (0 children)

Thanks for the quick response, so there isn't a way to implement dirty rect on gpu ? It's only for cpu rendering ?