Logo by Trifox - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Follow us on Twitter
 
*
Welcome, Guest. Please login or register. April 23, 2024, 05:32:53 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2 3   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Frag to GPU asm dump  (Read 7069 times)
Description: a little bit of code to dump GPU asm from fragmentarium
0 Members and 1 Guest are viewing this topic.
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« on: April 26, 2015, 10:08:28 AM »

Would this be useful to anyone? diff patch available for testing against Fragmentarium-master.
edit1:attached diff (rename as dump-frag-asm.diff)
edit2:this works for OpenGL 4.0 and up, not sure what will happen for versions below 4.0
edit3:as pointed out by _revers_ this only works for nVidia so I have enabled the menu option only if there is nVidia card present.


* dump-frag-asm.jpg (237.2 KB, 1280x800 - viewed 330 times.)
* dump-frag-asm.txt (10.68 KB - downloaded 123 times.)
« Last Edit: June 11, 2015, 06:40:33 AM by 3dickulus » Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #1 on: April 27, 2015, 05:42:33 PM »

Neat - I usually use NVEmulate for this, but this looks handy.
Logged
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #2 on: April 27, 2015, 05:43:52 PM »

i consider stuff like that as "too much" wink but a development tool should feature that, and still there are hand-coded optimizations that could be edited, i believe this shader asm file can be send to compile as well ? perhaps think about an editor feature for a asm shader...
Logged

---

divide and conquer - iterate and rule - chaos is No random!
DarkBeam
Global Moderator
Fractal Senior
******
Posts: 2512


Fragments of the fractal -like the tip of it


« Reply #3 on: April 27, 2015, 06:39:32 PM »

Haha, I love smiley
Logged

No sweat, guardian of wisdom!
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #4 on: April 28, 2015, 12:17:48 AM »

lol, yeah, a bit much for a fractal prog but the amount of code to make that happen is so small it seems silly not to have this functionality available even if it is only used in rare cases or to study the conversion from GLSL to machine code.
The assembler code is contained in the binary object as text and would be very specific to the gfx card that generated it, not practical for redistribution unless it's for exactly matching hardware and drivers, more of a debugging tool bonus for the more hardcore hackers cheesy
If I can find the time or get inspired I might parse the variable names and insert them where relevant so that it makes easier reading, as for compiling this asm txt back into binary, I'm not sure that would be beneficial unless you just needed a particular routine or function for another application, cut, paste, hack, hack, hack  evil

edit: I would be interested to hear what other hardware and versions this works with, mine is...
 - OpenGL Vendor: NVIDIA Corporation
 - OpenGL Version: 4.5.0 NVIDIA 346.46
 - OpenGL Renderer: GeForce GTX 760/PCIe/SSE2
 - OpenGL Shading Language Version: 4.50 NVIDIA
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #5 on: April 28, 2015, 12:25:22 AM »

this just reminds me of the early shader days when i had the radeon 8500 and no high level languages existed, the first mandelbrot rendering i coded in tha gpu assembler, and i did even exploit the limitations by feeding iteration results back into the gpu wink and it reminds me of one of my entries to the ShaderX book series


http://www.google.de/search?q=shaderx3

 afro angel
Logged

---

divide and conquer - iterate and rule - chaos is No random!
cKleinhuis
Administrator
Fractal Senior
*******
Posts: 7044


formerly known as 'Trifox'


WWW
« Reply #6 on: April 28, 2015, 12:27:43 AM »

ah no, looking in the book, i was using hlsl shading language v1.0 at that time wink but first steps where in asm only ... i embraced the high level shading languages so much and they are now at such a beautiful useable state, i love it
Logged

---

divide and conquer - iterate and rule - chaos is No random!
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #7 on: April 28, 2015, 12:35:57 AM »

honestly, I haven't got a clue how to recompile the asm but I'm sure it would need some careful hand crafting or a more intelligent extraction before feeding it to the ptx assembler, proper declarations etc. etc. etc. I know nvcc compiler can handle it but  huh?
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
Syntopia
Fractal Molossus
**
Posts: 681



syntopiadk
WWW
« Reply #8 on: April 28, 2015, 10:59:08 PM »

To recompile it, I think you can just send it instead of GLSL. If the first line begins with "!!NVfp5.0" I think it should be recognized as assembly.
At least that is how I read this document: http://developer.download.nvidia.com/opengl/specs/GL_NV_gpu_program5.txt

Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #9 on: April 29, 2015, 02:33:22 AM »

I interpret that the same way, so assembler frags should be basically the same process  as GLSL frags, set vertex/fragment program text and send it to the GPU, that means technically Fragmentarium can already do this and just needs a little gui-ness to make it comfortable. A separate editing mode or language option switch? Hacking this into the existing code will be tricky, maybe a new branch for Qt5 + GLSL + GASM options? as QGLWidget and friends are to be replaced by functions prefixed with "QOpenGL" that don't work in quite the same way or have different prerequisites.

that is an extremely interesting document full of all kinds of goodies
Quote
    This extension also provides optional support for 64-bit-per-component variables and 64-bit floating-point arithmetic.

 A Beer Cup  @Syntopia, I think that one will keep me up late tonight wink maybe I'll learn enough to make something useable, or learn enough to know that I can't, either way it's still extremely interesting.
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #10 on: April 29, 2015, 04:36:12 AM »

well, the asm compiles using Qt stuff but no image, probably because Fragmentarium uses more than one shader and buffers and this program, QShaderEditor, is not designed with this in mind but a successful compile is promising cheesy


* frag-compiler.jpg (53.66 KB, 727x452 - viewed 293 times.)
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
knighty
Fractal Iambus
***
Posts: 819


« Reply #11 on: April 29, 2015, 04:53:22 PM »

Nice feature!
With Polydraw one can use either assembly or glsl. The source code is also provided.
Logged
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #12 on: May 03, 2015, 10:23:50 AM »

for anyone that applied the diff attached in the first post you also need to add
Code:
#define GL_PROGRAM_BINARY_LENGTH 0x8741
in the Fragmentarium-Source/ThirdPartyCode/glextensions.h file @ line 148  bubble gum
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
3dickulus
Global Moderator
Fractal Senior
******
Posts: 1558



WWW
« Reply #13 on: May 10, 2015, 10:42:17 PM »

NOTE: the move to Qt5 negates the requirement for ThirdPartyCode/glextensions.h file as all GL functions are available through QOpenGLVersionFunctions and QOpenGLFunctions_4_1_Compatibility includes cheesy

edit: wow 500th post w00tw00t.
Logged

Resistance is fertile...
You will be illuminated!

                            #B^] https://en.wikibooks.org/wiki/Fractals/fragmentarium
_revers_
Conqueror
*******
Posts: 138



« Reply #14 on: June 10, 2015, 10:34:35 PM »

edit: I would be interested to hear what other hardware and versions this works with, mine is...

On my NVidia GeForce GTX 750 everything works as expected but on my AMD Radeon HD 5850 Fragmentarium crashes.
Graphics card details:
Code:
GL Vendor     : ATI Technologies Inc.
GL Renderer   : AMD Radeon HD 5800 Series
GL Version    : 4.4.13292 Compatibility Profile/Debug Context 14.502.1014.1001
GL Version    : 4.4
GLSL Version  : 4.40

I've implemented your method on my own and this is what I get on Radeon HD 5850 (only printable characters):

BufferShader.frag:
Code:
ELFc 4 B 4 ( 
 <D <D 13292 #version 440
#ifdef SYNTHCLIPSE
// #include <synthclipse>
#endif
layout(location = 0) in vec4 VertexPosition;

out vec2 coord;

void main(void)
{
gl_Position = VertexPosition;
coord = (VertexPosition).xy;
}


 #version 440
layout(location = 0) out vec4 glFragColor;
#ifdef SYNTHCLIPSE
// #include <synthclipse>
#endif
// This is a simple shader for rendering images
// from an accumulated buffer.

//! <vs shader="BufferShader.vert" />

//! <group name="Post"/>
uniform float Gamma; //! slider[0.0,2.0,5.0];
uniform float Exposure; //! slider[0.0,1.0,3.0];
uniform float Brightness; //! slider[0.0,1.0,5.0];
uniform float Contrast; //! slider[0.0,1.0,5.0];
uniform float Saturation; //! slider[0.0,1.0,5.0];
uniform int ToneMapping; //! slider[1,4,5];

/*
** Based on: http://mouaif.wordpress.com/2009/01/22/photoshop-gamma-correction-shader/
**
** Contrast, saturation, brightness
** Code of this function is from TGM's shader pack
** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
*/
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
vec3 ContrastSaturationBrightness(vec3 color, float brt, float sat, float con)
{
const vec3 LumCoeff = vec3(0.2125, 0.7154, 0.0721);
vec3 AvgLumin = vec3(0.5);
vec3 brtColor = color * brt;
float intensityf = dot(brtColor, LumCoeff);
vec3 intensity = vec3(intensityf, intensityf, intensityf);
vec3 satColor = mix(intensity, brtColor, sat);
vec3 conColor = mix(AvgLumin, satColor, con);
return conColor;
}

float sigmoid(float t) {
float K = 1.0-1./(1.0+exp(-0.5*Contrast*5.));
t -= 0.5;
float x = 1./(1.0+exp(-t*Contrast*5.))-K;
return x/((1.0-2.0*K));
}

vec3 sigmoid3(vec3 t) {
return vec3(sigmoid(t.x),sigmoid(t.y),sigmoid(t.z));
}

in vec2 coord;
uniform sampler2D frontbuffer;

void main() {
vec2 pos = (coord+1.0) * 0.5;
vec4 tex = texture(frontbuffer, pos);
vec3 c = tex.xyz/tex.a;

if (ToneMapping==1) {
// Linear
c = c*Exposure;
c = ContrastSaturationBrightness(c, Brightness, Saturation, Contrast);

} else if (ToneMapping==2) {
// ExponentialExposure
c = vec3(1.0)-exp(-c*Exposure);
c = ContrastSaturationBrightness(c, Brightness, Saturation, Contrast);

} else if (ToneMapping==3) {
// Filmic: http://filmicgames.com/archives/75
c*=Exposure;
vec3 x = max(vec3(0.),c-vec3(0.004));
c = (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06);
c = pow(c, vec3(2.2)); // It already takes the Gamma into acount
c = ContrastSaturationBrightness(c, Brightness, Saturation, Contrast);

} else if (ToneMapping==4) {
// Reinhart
c*=Exposure;
c = c/(1.+c);
c = ContrastSaturationBrightness(c, Brightness, Saturation, Contrast);
} else if (ToneMapping==5) {
c = sigmoid3(c*Exposure+vec3(Brightness-1.0));

}
c = pow(c, vec3(1.0/Gamma));

glFragColor = vec4(c,1.0);
}


 | ELFc 4 X 4 (
 p p
 < @ #
m ^
m H
m vl
m z @
m `
m -
m !
m b
 @ 0 ] coord p Brightness l Contrast l Exposure l Gamma p Saturation p ToneMapping p = frontbuffer t VertexPosition . .text .inputs .outputs .constants .loopconstants .info .usageinfo .symbols .shstrtab T 0 8 % < 4 @ : E | N \ 8 ELFc 4 4 (
 ( ( $ k Q $ B P( @ - @ \ PE @ G @ Pi @ k @ P @ @ P @ @ @ , _ ` G 6 D 7 D p 6 D I 8 k 8 k 8 k@ 8 k` $ @ C @@! H D @ @ ` /O _ _ _ @_ `Y>t$7?*= @ ` ~b ~bO~bo `$ ,@! P X @ T ` o;? @ 0 `@ ` 0 @ @ 0 O _~ _ _ @_ `Y>t$7?*= ~ @ ` }b }bO}bo `$ ,@! D c @ c/ H coo /O c c/ cO co ff@? c/ O coOu=ff@ C o C ` O} C @~ A / A @ A @ O @ @@ @ /@ O _ _ _ @_ `Y>t$7?*= @ ` }b }bO}bo `$ ,@! @ H O Do, ( o C ~ ` C ` ~ @ C O _~ _ _ @_ `Y>t$7?*= ~ @ ` }b }bO}bo `$ ,@! ` H c D c/ @ cO ` @ @ `;? `@ @ ` @ o C ;? 0 /@ o@ @ / @ / C } / C } o~ C `} `~ C ` @ ` CO ? A A O A @ @ ~@ @ @ N ] D 5 D \ D N ] D 5 D \ D N ] D 5 D "" \ D "" ,
m k Q p Brightness l Contrast l Exposure l Gamma p Saturation p ToneMapping p = frontbuffer p F glFragColor . .text .inputs .outputs .constants .loopconstants .info .usageinfo .symbols .shstrtab T @ L , x % | 4 : ( E x N < \ +| < @ #
m ^
m H
m vl
m z @
m `
m -
m !
m b
 @ P( @ - @ \ PE @ G @ Pi @ k @ P @ @ P @ @ @ , _ ` G 6 D 7 D p 6 D I 8 k 8 k 8 k@ 8 k` $ @ C @@! H D @ @ ` /O _ _ _ @_ `Y>t$7?*= @ ` ~b ~bO~bo `$ ,@! P X @ T ` o;? @ 0 `@ ` 0 @ @ 0 O _~ _ _ @_ `Y>t$7?*= ~ @ ` }b }bO}bo `$ ,@! D c @ c/ H coo /O c c/ cO co ff@? c/ O coOu=ff@ C o C ` O} C @~ A / A @ A @ O @ @@ @ /@ O _ _ _ @_ `Y>t$7?*= @ ` }b }bO}bo `$ ,@! @ H O Do, ( o C ~ ` C ` ~ @ C O _~ _ _ @_ `Y>t$7?*= ~ @ ` }b }bO}bo `$ ,@! ` H c D c/ @ cO ` @ @ `;? `@ @ ` @ o C ;? 0 /@ o@ @ / @ / C } / C } o~ C `} `~ C ` @ ` CO ? A A O A @ @ ~@ @ @ N ] D 5 D \ D N ] D 5 D \ D N ] D 5 D "" \ D "" @(#) AMD OpenGL Driver version: 13292asicID: Z __Shader_V_Source_0_ __Shader_F_Source_0_ __Shader_V_AsicID_9_Key_0_ __Shader_V_AsicID_9_BinaryInfo_0_ __Shader_V_AsicID_9_ElfBinary_0_ __Shader_V_Stage_AsicID_9_ __Shader_F_AsicID_9_Key_0_ __Shader_F_AsicID_9_BinaryInfo_0_ __Shader_F_AsicID_9_ElfBinary_0_ __Shader_F_Stage_AsicID_9_ __Shader_V_AsicID_9_Text_ __Shader_F_AsicID_9_Text_ + , F 0 h @ ( , , X h ( ( h 7 ( . .setting .parameter .source .internal .crc .text .comment .strtab .symtab .shstrtab T d (
 l * ) 6 . 6 4 ? 4 = @ T E \A M ,B X

Unfortunately on AMD platforms you won't get shader assembly so easly.

I've also tested your method on some Intel video card at work and it also failed due to fact that glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS) returned "0".
Logged
Pages: [1] 2 3   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Small error in Complex.frag Fragmentarium JosLeys 2 1489 Last post June 08, 2013, 09:01:45 AM
by Roquen
Orbit Trap in GI frag Fragmentarium « 1 2 3 » vinz 38 7476 Last post June 20, 2013, 07:48:01 PM
by vinz
Photomanip + Fractal :: Image Dump Images Showcase (Rate My Fractal) Ryche 6 1102 Last post July 21, 2015, 11:20:59 AM
by Ryche
Frag / GLSL newbie questions Fragmentarium Patryk Kizny 5 1251 Last post July 25, 2015, 05:02:47 AM
by 3dickulus
Abox minR2 tweaking frag Amazing Box, Amazing Surf and variations mclarekin 0 2419 Last post July 26, 2017, 03:18:00 PM
by mclarekin

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.143 seconds with 25 queries. (Pretty URLs adds 0.009s, 2q)