OpenGL Features

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

OpenGL Features

Post by radubolovan »

I saw this function:

Code: Select all

bool COpenGLExtensionHandler::queryFeature(E_VIDEO_DRIVER_FEATURE feature) const
{
	switch (feature)
	{
	case EVDF_RENDER_TO_TARGET:
		return true;
	case EVDF_MULTITEXTURE:
		return MultiTextureExtension;
	case EVDF_BILINEAR_FILTER:
		return true;
	case EVDF_MIP_MAP:
		return true;
	case EVDF_MIP_MAP_AUTO_UPDATE:
		return FeatureAvailable[IRR_SGIS_generate_mipmap];
	case EVDF_STENCIL_BUFFER:
		return StencilBuffer;
	case EVDF_ARB_VERTEX_PROGRAM_1:
		return FeatureAvailable[IRR_ARB_vertex_program];
	case EVDF_ARB_FRAGMENT_PROGRAM_1:
		return FeatureAvailable[IRR_ARB_fragment_program];
	case EVDF_ARB_GLSL:
		return FeatureAvailable[IRR_ARB_shading_language_100];
	case EVDF_TEXTURE_NPOT:
		return FeatureAvailable[IRR_ARB_texture_non_power_of_two];
	case EVDF_FRAMEBUFFER_OBJECT:
		return FeatureAvailable[IRR_EXT_framebuffer_object];
	case EVDF_VERTEX_BUFFER_OBJECT:
		return FeatureAvailable[IRR_ARB_vertex_buffer_object];
	default:
		return false;
	};
}
What about the rest?

Code: Select all

EVDF_HARDWARE_TL
EVDF_VERTEX_SHADER_1_1
EVDF_VERTEX_SHADER_2_0
EVDF_VERTEX_SHADER_3_0
EVDF_PIXEL_SHADER_1_1
EVDF_PIXEL_SHADER_1_2
EVDF_PIXEL_SHADER_1_3
EVDF_PIXEL_SHADER_1_4
EVDF_PIXEL_SHADER_2_0
EVDF_PIXEL_SHADER_3_0
EVDF_HLSL
They are not all false!!!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well Hardware T&L could be set to true, but it's a d3d term and the flag will be used for some d3d specific things only IMHO. The rest are d3d shader specifications, I don't know how we could map them to OpenGL. Any suggestions?
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

Post by radubolovan »

The D3D things should be false for OpenGL, but the others ...
The EVDF_VERTEX_SHADER_x_y and EVDF_PIXEL_SHADER_x_y are the version suported?
If, then you should "ask" the OpenGL and GLSL for versions ... I think...
I don't know very much about this problem :( ... those versions are only for D3D?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I don't think you can query OpenGL specifically for these things. GLSL is based on SM 3.0 anyway.

Oddly enough, its possible to query the shader model for GLSL from inside the pixel shader using a built in glsl #define. so one thing you can do is make a dummy shader file that output shader version info into an RTT and read it back to the cpu. Ofcourse thats well beyond the scope of this topic, and I wouldn't recommend something so silly.

For stuff like SM 4.0, you can query for the extension "GL_EXT_geometry_shader4" which would mean that geometry shaders are supported and hence the card should be SM 4.0 compatible.

There may be other extensions that indicate SM 2.0 or SM 3.0 support. We should assume minimum SM 2.0 support if GLSL is supported, because thats the minimum level card that can use GLSL.

Cheers
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

Post by radubolovan »

so the next code from shaders example isn't correct:

Code: Select all

if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) &&
		!driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1))
	{
		device->getLogger()->log("WARNING: Pixel shaders disabled "\
			"because of missing driver/hardware support.");
		psFileName = 0;
	}
	
	if (!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1) &&
		!driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
	{
		device->getLogger()->log("WARNING: Vertex shaders disabled "\
			"because of missing driver/hardware support.");
		vsFileName = 0;
	}
In OpenGL driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) and driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1) will always return false!
and one more think ... I think that should be || operator between the two queries ...
So the correct code might be:

Code: Select all

if( driverType == video::EDT_OPENGL )
{
   if( !driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1) )
	{
		device->getLogger()->log("WARNING: Pixel shaders disabled "\
			"because of missing driver/hardware support.");
		psFileName = 0;
	}
	
	if( !driver->queryFeature(video::EVDF_ARB_VERTEX_PROGRAM_1))
	{
		device->getLogger()->log("WARNING: Vertex shaders disabled "\
			"because of missing driver/hardware support.");
		vsFileName = 0;
	}
}
else
{
       //the code before now but with || operator between queries not &&
}
Am I right?
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

radubolovan wrote:Am I right?
No. Consider the following slightly more readable code.

Code: Select all

const bool ps_11_support = driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1);
const bool arb_1_support = driver->queryFeature(video::EVDF_ARB_FRAGMENT_PROGRAM_1);

if (!ps_11_support && !arb_1_support)
{
  // display warning
}
That code says if pixel shader 1.1 is not supported and arb fragment program 1 is not supported then display warning.

The only way you get into the error condition is if both ps_11_support and arb_1_support are false. Another thing that may help to make this easier to read is if you remember that (!a && !b) == !(a || b).

Travis
radubolovan
Posts: 60
Joined: Tue Nov 13, 2007 7:03 pm
Location: Bucharest - Romania
Contact:

Post by radubolovan »

I know that ... I thought that the warning must me displayed if at least one of the queries was false.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

No, but I agree there is something wrong with that example, because it should check the driver type before testing driver-specific features.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, the queryFeature is driver independent. This time it only checks for something which is constantly false. So we could remove that check, or decide to give the enum values some more general meaning.
Post Reply