Motherboard Forums


Reply
Thread Tools Display Modes

Programmatically get shader assembly ?

 
 





















Skybuck Flying
Guest
Posts: n/a

 
      11-05-2009, 08:36 AM


Hello,

I would like to know how/what the assembly looks like which will be
generated by a cg compiler or gl sl compiler.

This is to give me an idea of the efficiency of written shaders and what
it's doing.

I wonder if there is programmatically a way to retrieve the assembly via
dll's/api calls ?

The only possibility I have found so far is using the cgc compiler and
specify -entry <id> -o assembly.txt <shader.cg>

I also wonder what to do in the case of opengl sl ? Which I might look into
in the future ?

Bye,
Skybuck.



 
Reply With Quote
 
Wolfgang Draxinger
Guest
Posts: n/a

 
      11-06-2009, 10:00 AM
Skybuck Flying wrote:

> Hello,
>
> I would like to know how/what the assembly looks like which will be
> generated by a cg compiler or gl sl compiler.


The GLSL compiler in NVidia's drivers are actually also performing a
conversion to assembly. The shader source code can be retrieved from OpenGL
(I'm not going to tell you how, because, if you understood how the OpenGL
API has been designed you mind would start looking for a function starting
with glGet...).

> This is to give me an idea of the efficiency of written shaders and what
> it's doing.


It won't. The assembly used in the OpenGL API is just an abstract
representation of the program which is transformed further into the real
machine code. And the latter one is totally depending on the used GPU and
without exact knowledge of that's innver workings you won't give you the
slightest idea, what's performant and what's not.

Also a GPU-specific GLSL compiler may be able to create more performant GPU-
machine code directly, as if it took the bypass of a intermediate ARB-like
assembler. If you want to optimize, don't look at the assembly level.
Instead profile your code and try optimizing the algorithms. This statement
holds for both the GPUs ans CPUs. Microoptimization won't gain you much.

> I also wonder what to do in the case of opengl sl ? Which I might look
> into in the future ?


Definitely GLSL. Cg is a dead track. (Just it is NVidia's CUDA compared to
OpenCL).


Wolfgang

 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      11-08-2009, 09:52 PM
There are to ways to compile a shader as for as I know:

1. nvidia's cg compiler which is an executable called cgc.exe
(The compiler has option -o to output assembly.)

2. nvidia's cg dll which is an library/dll cg.dll or so...

My question(s) are:

1. Does the cg dll have api call(s) to get the assembly text after it's
load/compiled ?

2. Does opengl dll/api have api call(s)to get the assemble text after it's
load/compiled ?

3. Does opengl have a shading language compiler executable like cg ?

Bye,
Skybuck.


 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      11-08-2009, 09:58 PM
Oh sorry, I banned that wolfgang guy... didn't see his reply...

I thought you were asking me for clarification... never mind then

Bye,
Skybuck.

"Dave Eberly" <> wrote in message
news:1pnJm.6804$...
> "Wolfgang Draxinger" <> wrote in message
> news:. ..
>
>> Definitely GLSL. Cg is a dead track. (Just it is NVidia's CUDA compared
>> to
>> OpenCL).

>
> Would you please explain your statement about Cg? Do you mean the
> Cg compiler or the Cg runtime (or both)? Why do you believe it is a
> "dead track".
>
> Did you mean to say "Just as it is with NVidia's CUDA ..."? Do you
> believe that CUDA is a "dead track"? If so, why?
>
> Thanks for any clarification.
>
> --
> Dave Eberly
> http://www.geometrictools.com
>
>
>



 
Reply With Quote
 
Skybuck Flying
Guest
Posts: n/a

 
      11-08-2009, 10:02 PM
Anyway,

There is this opengl api:

glGetShaderSource

Does it return gl sl language shader ?

Or does it return assembly ?

Maybe I try it out sometime...

Bye,
Skybuck.


 
Reply With Quote
 
fungus
Guest
Posts: n/a

 
      11-08-2009, 11:03 PM
On Nov 8, 10:58*pm, "Skybuck Flying" <BloodySh...@hotmail.com> wrote:
> Oh sorry, I banned that wolfgang guy... didn't see his reply...
>
> I thought you were asking me for clarification... never mind then
>


*YOU* banned *US*???

LOL!



--
<\___/>
/ O O \
\_____/ FTB.

 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When to attach the fan heatsink assembly? Santas Helper Intel 2 12-21-2007 09:30 PM
Intel Assembly gip Intel 3 09-27-2007 09:31 PM
[600x] proper LCD cable assembly Joshua Robin IBM Thinkpad 0 01-15-2006 12:52 PM
Re: opening up 600e--removing keyboard assembly Capt. Wild Bill Kelso, USAAC IBM Thinkpad 2 04-10-2004 09:57 PM
programmatically establishing file associations in OS 10.2+ Dan Greenblatt Apple 2 02-26-2004 05:48 PM


All times are GMT. The time now is 08:49 PM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43