D3D VertexShader -> EXT_vertex_shader conversion

maphit

New member
Hi there,
I'm writing a tool that convert a D3D Vertex Shader code into tokens. Then these tokens are used to setup a gl shader (using the EXT_vertex_shader extension).
This works for some examples but i got a problem :
What are the official equivalent for LIT, EXPP, DST, and LOG (D3D versions) in this extension ?
I know that i need several micro op to reproduce these instructions, but it is not clear wether the result will get optimized to the right form.
In fact i'm not sure that all D3D program can be converted to that extension..
any clue ?
 
Re: D3D VertexShader -> EXT_vertex_shader conversion

maphit said:
Hi there,
I'm writing a tool that convert a D3D Vertex Shader code into tokens. Then these tokens are used to setup a gl shader (using the EXT_vertex_shader extension).
This works for some examples but i got a problem :
What are the official equivalent for LIT, EXPP, DST, and LOG (D3D versions) in this extension ?
I know that i need several micro op to reproduce these instructions, but it is not clear wether the result will get optimized to the right form.
In fact i'm not sure that all D3D program can be converted to that extension..
any clue ?

Aren't those instructions macors anyway (in D3D)?
 
No, though there are some (m4x4).. Of course, the underlying hardware implementation may split them into micro-ops.
As an example, expp dest, src.w results in :
- dest.x = 2^(int)src.w
- dest.y = fractionnal part(src.w)
- dest.z = 2^src.w
- dest.w = 1.0

With EXT_vertex_shader, we ain't got such an instruction, but we got instructions to take fractionnal part of a scalar,or to compute 2^x. But the docs don't says what is the best equivalent for expp using this language. In some docs it is said that ATI expects implementors to optimize the program, for example with swizzles, which are a seperate op in EXT_vertex_shader.. But if i found an equivalent for expp, how do i have the guarantee that it will get optimized correctly on hardware that internaly directly implement expp .. (hopes it make sens ..) ?
Morevover some D3D instructions don't seems to have an equivalent. For example, 'log' gives you exponent, log2, and mantissa for a scalar, but there is no intructions in EXT_vertex_shader to get mantissa of a scalar..
Well it doesn't seems that trivial to convert from D3D vertex shader code to EXT_vertex_shader..
 
Well the behaviour I described for 'logp' seems to apply to NV_vertex_program only. The definition in D3D is different ..
 
maphit said:
Well the behaviour I described for 'logp' seems to apply to NV_vertex_program only. The definition in D3D is different ..

From what I can tell, the equivenents don't quite exist. You can try and approximate the same effects using the existing instructions, though. With a maximum of 128 instructions you should be able to do the same things in EXT_vertex_shader as in D3D's vertex shader. I'm guessing that on the Radeon 9700 the ARB_vertex_program can achieve more of what you want much easier.
 
I think you're right. If have found some equivalent but i don't know if they are the best. What is still unclear is how to emulates the behaviour of log (D3D version), which allow to compute a higher precision result by using dest.x and dest.y.
In my implementation i just use GL_OP_LOG_BASE_2_EXT, and then i use glInsertComponentEXTto replicate the result to the four channel, but i don't know if it is correct, though it seems to do the job ..Another issue is with LIT : the D3D version clamp the exponent to [-127, 127], but there is no precision about that in the doc about GL_OP_POWER_EXT.. This is not a big issue anyway, if having a full range cost one less clamp instruction..
 
Back
Top