Jump to content

  • Log In with Google      Sign In   
  • Create Account

Help: Abstracting DirectX9/OpenGL and DirectX11 shader interfaces


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.

  • You cannot reply to this topic
4 replies to this topic

#1 Shanee   Members   -  Reputation: 207

Like
0Likes
Like

Posted 22 June 2013 - 06:13 AM

Hello,

 

I have started implementing DirectX 11 at last and I have found myself at a puzzle.

 

Currently the engine supports OpenGL and DirectX 9.0c, which both have a very simple way of setting parameters on the shaders by asking for the name of the parameter for example DirectX9 has the ID3DXBaseEffect::GetParameterByName

http://msdn.microsoft.com/en-us/library/windows/desktop/bb205696(v=vs.85).aspx

Which you can use and then set the parameter.

Similarly, OpenGL uses glGetAttribLocation which gets you the handle by the name of the variable and then we can set it.

 

In DirectX11 however, I have only found registers and buffers, or at least that's what I have found to be compatible both with Win32 and the Mobile/Windows Store version.

 

Anyone has any insight I may have been missing, or an advice on bridging the three?

 

Thanks! :)



Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31822

Like
0Likes
Like

Posted 22 June 2013 - 08:00 AM

IMHO, the D3D11 abstraction of buffers of uniform values is superior to the GL2.x and D3D9 ways of doing things (GL3.x has UBO's, which are the same as D3D11 cbuffers), so I emulate cbuffers on these older APIs.



#3 Shanee   Members   -  Reputation: 207

Like
0Likes
Like

Posted 22 June 2013 - 08:18 AM

This was actually my first idea too, though I am a bit lost on how to do this for OpenGL, and sorry I wasn't clear, I meant OpenGL ES 2.0 for mobile. As I know it doesn't support registers - would you have any good example for it?


Edited by Shanee, 22 June 2013 - 08:20 AM.


#4 BornToCode   Members   -  Reputation: 948

Like
0Likes
Like

Posted 23 June 2013 - 11:09 AM

For Windows store app, you cannot use any of the Compile functions. You have to used Precompiled shaders. Also since D3DCompiler.h is not allowed in windows store app, you cannot reflect your compile shader to get variable names from it like glGetUniformLocation would do. Your only options are to save that information into some external file yourself and load it along with your shader. Or when you set up your shader, you set the name directly.



#5 Hodgman   Moderators   -  Reputation: 31822

Like
0Likes
Like

Posted 25 June 2013 - 09:17 AM


I meant OpenGL ES 2.0 for mobile. As I know it doesn't support registers - would you have any good example for it?
The old GL method for managing uniform variables is very hard to handle efficiently... it's just bad :(

I'd probably stick with my cbuffer emulation, design, which would require me to keep around one mapping of names-to-cbuffer-rows, and at runtime generate a second mapping of names-to-uniform-indices, and then from both generate a mapping of cbuffer-row-to-uniform-indices, which I'd use to copy values out of my buffers and into glUniform/etc calls.






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.



PARTNERS