• Create Account

## dramatic fps drop when using transparent texture

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

39 replies to this topic

### #21fip  Members

Posted 13 December 2012 - 09:24 AM

Hi again,

more testing:
[source lang="cpp"]SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1);[/source]
does not have any effect. I think it should be enough with SDL_OPENGL but just in case.

- i ve run the executable on a notebook with only one GPU and i keep getting the "GDI generic" for GL_RENDERER.
So maybe it's not an issue of having dual gpus, furthermore in case it was using the intel HD integrated graphics card i should be getting "Intel" as the GL_VENDOR right?

OK, one problem here is that you're using SDL_Delay to control framerate.

For your GL context problem, I'll have a look over your code later on today and see if I can spot anything (assuming someone else doesn't come up with the solution before then).

Thanks for your time, this is the problem i want to fix!!

### #22fip  Members

Posted 13 December 2012 - 09:32 AM

I tested this other SDL+Opengl code and still get GDI generic for GL_RENDERER.

Can someone try to run this code and see what do you get for GL_RENDERER?

I want to know if the problem is in the code or it's in my laptop configuration somehow.

### #23mhagain  Members

Posted 13 December 2012 - 11:14 AM

Here's what I get on one machine:

Vendor : ATI Technologies Inc.
Renderer : AMD Radeon HD 6450
Version : 4.2.11931 Compatibility Profile Context
SDL_GL_RED_SIZE: requested 5, got 8
SDL_GL_GREEN_SIZE: requested 5, got 8
SDL_GL_BLUE_SIZE: requested 5, got 8
SDL_GL_DEPTH_SIZE: requested 16, got 24
SDL_GL_DOUBLEBUFFER: requested 1, got 1

What looks possible here is that you're requesting default modes that may not be available in hardware-accelerated versions. 16-bit modes are really really old these days (the last video card that didn't support 32-bit colour was the Voodoo 3) and there should be no reason to go looking for one - try bumping RGB to 8/8/8 and see what that gets you.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #24kunos  Members

Posted 13 December 2012 - 11:19 AM

the most likely cause is that you don't have a driver from nvidia. Go on the nvidia website, download and install your driver and enjoy hardware accelerated OpenGL.

### #25fip  Members

Posted 13 December 2012 - 11:29 AM

Hi mhagain,
Here is what i get after increasing the depth size to 24:

Screen BPP: 24
Vendor : Microsoft Corporation
Renderer : GDI Generic
Version : 1.1.0
Extensions : GL_WIN_swap_hint GL_EXT_bgr
SDL_GL_RED_SIZE: requested 8, got 8
SDL_GL_GREEN_SIZE: requested 8, got 8
SDL_GL_BLUE_SIZE: requested 8, got 8
SDL_GL_DEPTH_SIZE: requested 24, got 32
SDL_GL_DOUBLEBUFFER: requested 1, got 1

I think i have spotted the problem.
In the official opengl documentation site ive found this http://www.opengl.org/archives/resources/faq/technical/mswindows.htm specially the point "5.030 How do I enable and disable hardware rendering on a Wintel card?"
It says that hardware acceleration depends on choosing a right PIXEL FORMAT. Now is it possible to do this when you are using GLUT? Which config do i need when using SDL to get hardware acceleration?

### #26fip  Members

Posted 13 December 2012 - 11:38 AM

the most likely cause is that you don't have a driver from nvidia. Go on the nvidia website, download and install your driver and enjoy hardware accelerated OpenGL.

Hi Kunos,
the thing is, i already have a driver from nvidia installed. And if i run code that creates rendering context for windows it runs in the gpu!! The problem has to be with choosing the right pixel format. But ill try to download latest drivers from nvidia anyway to check it.

### #27mhagain  Members

Posted 13 December 2012 - 11:46 AM

Both GLUT and SDL should automatically prefer to give you a hardware accelerated pixel format if one is available.

Looking at http://sdl.beuc.net/sdl.wiki/SDL_GLattr I see that SDL_GL_SetAttribute has an SDL_GL_ACCELERATED_VISUAL attribute available, so you can try using that.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #28fip  Members

Posted 13 December 2012 - 12:22 PM

Looking at http://sdl.beuc.net/...wiki/SDL_GLattr I see that SDL_GL_SetAttribute has an SDL_GL_ACCELERATED_VISUAL attribute available, so you can try using that.

Already tried, nothing new . But the strangest thing is the output:

Screen BPP: 24

Vendor : Microsoft Corporation
Renderer : GDI Generic
Version : 1.1.0
Extensions : GL_WIN_swap_hint GL_EXT_bgra GL_E

SDL_GL_RED_SIZE: requested 8, got 8
SDL_GL_GREEN_SIZE: requested 8, got 8
SDL_GL_BLUE_SIZE: requested 8, got 8
SDL_GL_DEPTH_SIZE: requested 24, got 32
SDL_GL_DOUBLEBUFFER: requested 1, got 1
SDL_GL_ACCELERATED_VISUAL: requested 1, got 1 !!!!!!

Although it says "got 1" for SDL_GL_ACCELERATED_VISUAL i dont have hardware acceleration... :S

Edited by fip, 13 December 2012 - 12:29 PM.

### #29slicer4ever  GDNet+

Posted 13 December 2012 - 03:34 PM

you said that lesson 1 of the nehe tutorials does give you an hardware accelerated context.

looking at the tutorial, it seems to specify 16 BPP(doesn't specify bits per color component), and a 16 bit z-buffer.

don't know if that will help, but perhaps we should step back and see why that works, but sdl does not.

i've attached a program i wrote to test your video settings, tell me if it still gives you an generic rendering context.

#### Attached Files

Edited by slicer4ever, 13 December 2012 - 04:23 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #30fip  Members

Posted 14 December 2012 - 04:22 AM

you said that lesson 1 of the nehe tutorials does give you an hardware accelerated context.

looking at the tutorial, it seems to specify 16 BPP(doesn't specify bits per color component), and a 16 bit z-buffer.

don't know if that will help, but perhaps we should step back and see why that works, but sdl does not.

Yesterday i was playing a bit with the code that creates an accelerated rendering context changing the SUPPORT_OPENGL feature as well as the pixel format to PDF_FORMAT_GENERIC and i wasnt still getting HW ACCELERATION, i ll keep messing with it til i find a way to disable hardware acceleration.
That may be a way to investigate yes.

i've attached a program i wrote to test your video settings, tell me if it still gives you an generic rendering context.

Thanks, I ll try it as soon as i can.

Edited by fip, 14 December 2012 - 04:24 AM.

### #31fip  Members

Posted 14 December 2012 - 12:35 PM

i've attached a program i wrote to test your video settings, tell me if it still gives you an generic rendering context.

Hi slicer4ever, with your program i do get hardware acceleration!!! This program is running on my gpu.
Here is the output

VIDEO CONTEXT INFORMATION
VENDOR: NVIDIA Corporation
RENDER: GeForce GT555M/PCIe/SSE2
VERSION: 4.2.0
COLOR BITS: 32
DEPTH BITS: 24

Can you tell me what did you use to create the window?

Edited by fip, 14 December 2012 - 12:35 PM.

### #32slicer4ever  GDNet+

Posted 14 December 2012 - 05:12 PM

ok, so i've dug through sdl to figure out how it initializes the pfd, and similar things, and try these settings:
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 0); //Changed!
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 0); //Changed!
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 0 );  //Changed!
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 24 ); //Changed!
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if ( fsaa ) {
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
}
if ( accel ) {
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
}
if ( sync ) {
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
} else {
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
SDL_Quit();
exit(1);
}

their is one other thing i'm curiose about, after looking through the code, but let's try this first.
also, sorry about the late response.

Edited by slicer4ever, 14 December 2012 - 05:13 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #33fip  Members

Posted 15 December 2012 - 02:50 AM

Hi,
thanks for the response.
ive made the changes you suggested and still doesnt get HW acceleration. Ive also modified the "bpp" bits per pixel parameter and set it to 0 and get the same result i get by default 8 bpp.

So nothing changed. You want me to try anything else?

### #34slicer4ever  GDNet+

Posted 15 December 2012 - 03:46 AM

hmm, this is a perplexing problem, looking at sdl's source, it does a few things differently then my engine for creating a window/video context, but i don't see why this should cause you not to receive a hardware context.

i'm going to assume you are capable of compiling SDL, if not respond here and i'll see if i can't compile a binary for you with the changes.

note that i'm working with SDL-1.2.15(which a quick look at libsdl.org appears to be still the current version.)

so, my suspicion is that wglChoosePixelFormatARB is the culprit(or at least a parameter to it is causing the problem).

so let's comment out wglChoosePixelFormatARB, and use the default pixel format.
in SDL_wingl.c (src/video/wincommon/), comment lines 147-157.

this should be sufficient since it only uses the arb method if it's available for use(and i'm assuming it is available on most modern hardware), and defaults back to the regular PFD method instead.

so compile sdl, and run the test again, if this creates a hardware context, then it would appear this is the problem(or at least one of the parameter's it recieves creates a bad context). if not, i'm not really certain what the problem is, i'm no guru for sdl's internals, but by the look of things it should be similar to how i do things in my engine.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #35fip  Members

Posted 15 December 2012 - 09:34 AM

Hi slicer4ever,

I would rather prefer if u could provide me with the modified SDL library for x86 as im not very used to compile libraries with visual studio.

### #36slicer4ever  GDNet+

Posted 15 December 2012 - 05:00 PM

alright, i've compiled the changes:

http://www.sendspace.com/file/6vjaty

i also disabled directX since i don't have the sdk installed, and we arn't using directX, so i don't think it should be a problem.

(note the *D variants are debug versions)

Edited by slicer4ever, 15 December 2012 - 05:01 PM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #37fip  Members

Posted 16 December 2012 - 05:46 AM

Hi, ive replaced SDL.lib and SDLmain.lib in release mode and this is what i get with one of the code examples:

Screen BPP: 24
Vendor : Microsoft Corporation
Renderer : GDI Generic
Version : 1.1.0
Extensions : GL_WIN_swap_hint GL_EXT_bgra GL_EXT_paletted_texture
SDL_GL_RED_SIZE: requested 8, got 8
SDL_GL_GREEN_SIZE: requested 8, got 8
SDL_GL_BLUE_SIZE: requested 8, got 8
SDL_GL_DEPTH_SIZE: requested 24, got 32
SDL_GL_DOUBLEBUFFER: requested 1, got 1
SDL_GL_ACCELERATED_VISUAL: requested 1, got 1

still no hw acceleration.....

i dont know if i should ask in the nvidia forums or rather in the dell xps forums as it's more related to my computer configuration....

Do you have any other idea?

Edited by fip, 16 December 2012 - 05:47 AM.

### #38slicer4ever  GDNet+

Posted 16 December 2012 - 07:38 AM

it defiantly would be a good point to post in nvidia forums, i'm finding it difficult to successfully follow SDL's init pathways(so many IFDef's for different OS's/config flags =-/) from what i can tell, it's doing pretty much a 1:1(or very near anyways) with my own engine's window creation code, this is assuming that i'm following the correct config flags.

anyway, i'm going to post my window creation code(cleaned up to work as a stand-alone function):


unsigned char CreateVideoContextWindows(unsigned int BorderFlag=WS_OVERLAPPEDWINDOW, unsigned int BorderFlagEx=WS_EX_APPWINDOW|WS_EX_WINDOWEDGE, const char *ClassName, unsigned char StencilBits, unsigned char AccumBits, unsigned char DepthBits, unsigned char ColorBits){
unsigned int PixelFormat=0;
HINSTANCE m_HInstance = GetModuleHandle(0x0);
HWND m_HWnd = 0x0;
HDC m_HDc = 0x0;
HGLRC m_HGlrc = 0x0;
int m_x = 0;
int m_y = 0;
WNDCLASS WndClass={CS_HREDRAW|CS_VREDRAW|CS_OWNDC, QWWindowsProc, 0, 0, m_HInstance, LoadIcon(0x0, IDI_WINLOGO), LoadCursor(0x0, IDC_ARROW),0x0, 0x0, ClassName};
if(!RegisterClass(&WndClass)){
MessageBox(NULL, "Error: 'RegisterClass'", "ERROR", MB_OK|MB_ICONEXCLAMATION);
return 0;
}
RECT WndRect={0, 0, m_Width, m_Height};
if(!(m_HWnd = CreateWindowEx(BorderFlagEx, ClassName, m_Title, WS_CLIPSIBLINGS|WS_CLIPCHILDREN|BorderFlag, m_x, m_y, WndRect.right-WndRect.left, WndRect.bottom-WndRect.top, 0x0, 0x0, m_HInstance, 0x0))){
MessageBox(0x0, "Error: 'CreateWindowEx'", "ERROR", MB_OK|MB_ICONINFORMATION);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
PIXELFORMATDESCRIPTOR pfd={sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, ColorBits, 0, 0, 0, 0, 0, 0, 0, 0, AccumBits, 0, 0, 0, 0, DepthBits, StencilBits, 0, 0, 0, 0, 0, 0};
if(!(m_HDc=GetDC(m_HWnd))){
MessageBox(NULL, "Error: 'GetDC'", "ERROR", MB_OK|MB_ICONINFORMATION);
DestroyWindow(m_HWnd);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
if(!(PixelFormat=ChoosePixelFormat(m_HDc, &pfd))){
MessageBox(NULL, "Error: 'ChoosePixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
ReleaseDC(m_HWnd, m_HDc);
DestroyWindow(m_HWnd);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
if(!SetPixelFormat(m_HDc, PixelFormat, &pfd)){
MessageBox(NULL, "Error: 'SetPixelFormat'", "ERROR", MB_OK|MB_ICONINFORMATION);
ReleaseDC(m_HWnd, m_HDc);
DestroyWindow(m_HWnd);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
if(!(m_HGlrc=wglCreateContext(m_HDc))){
MessageBox(NULL, "Error: 'wglCreateContext'", "ERROR", MB_OK|MB_ICONINFORMATION);
ReleaseDC(m_HWnd, m_HDc);
DestroyWindow(m_HWnd);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
if(!(wglMakeCurrent(m_HDc, m_HGlrc))){
MessageBox(NULL, "Error: 'wglMakeCurrent'", "ERROR", MB_OK|MB_ICONINFORMATION);
wglDeleteContext(m_HGlrc);
ReleaseDC(m_HWnd, m_HDc);
DestroyWindow(m_HWnd);
UnregisterClass(ClassName, m_HInstance);
return 0;
}
SetForegroundWindow(m_HWnd);
SetFocus(m_HWnd);
return 1;
}


Edited by slicer4ever, 16 December 2012 - 07:39 AM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

### #39Sik_the_hedgehog  Members

Posted 16 December 2012 - 08:16 AM

As stupid as it may sound (and I may have skipped something in this thread)... did you try setting the color buffer to 32-bit instead of 24-bit? Also a 24-bit depth buffer only makes sense with an 8-bit stencil buffer if I recall correctly (both are shared making up a 32-bit buffer together).
Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.

### #40mhagain  Members

Posted 16 December 2012 - 11:02 AM

Also a 24-bit depth buffer only makes sense with an 8-bit stencil buffer if I recall correctly (both are shared making up a 32-bit buffer together).

Context creation should automatically give you 32 bit with 24 bits for depth and the remaining 8 either unused or for stencil (it's important to check this after creation as if it gives you stencil - even if you don't explicitly request it - you will want to clear stencil at the same time as depth in order to get fast clears, but that's a separate matter). Rarely it will give you 16 bit or 32 bit depth but it can happen too.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.