[quote="masterotaku"]Can you discard a vertex shader? I thought it wasn't possible, but it's something that I didn't actually try since 2015 when I was starting learning HLSL.[/quote]
I clearly haven't followed the discussion close enough and thought he was trying the disable code in a pixel shader.
I should really get around to implementing the conditional logic in the command list so you could do something like this to avoid the decompiler altogether if you don't need to otherwise modify the shader (example only - the syntax is not final):
[code]
[ShaderOverrideFoo]
hash = ...
if x == 0 then
handling = skip
endif
[/code]
[quote]Unrelated to all if this, one of the strange things I learned while fixing Hitman 1 and 2 was that in Shader Model 4, in ASM, comparisons are done differently (compared to DX9 fixes) if they aren't just checking if something is zero or non zero. Storing comparisons in a register and then checking if they were zero or non zero (true/false) wasn't intuitive at first, but then it allowed a lot of quick and effortless changes in the code. Fun stuff.[/quote]
It's done that way because it's easier to implement in hardware. However, beware that if you ever get a NaN value (e.g. infinity) in some calculation those tests can behave really strangely and don't make sense (variations in compiler output that should produce a logically equivalent result don't, because the compiler made an assumption that NaN wouldn't appear there), whereas the DX9 versions still make some logical sense in that case.
masterotaku said:Can you discard a vertex shader? I thought it wasn't possible, but it's something that I didn't actually try since 2015 when I was starting learning HLSL.
I clearly haven't followed the discussion close enough and thought he was trying the disable code in a pixel shader.
I should really get around to implementing the conditional logic in the command list so you could do something like this to avoid the decompiler altogether if you don't need to otherwise modify the shader (example only - the syntax is not final):
[ShaderOverrideFoo]
hash = ...
if x == 0 then
handling = skip
endif
Unrelated to all if this, one of the strange things I learned while fixing Hitman 1 and 2 was that in Shader Model 4, in ASM, comparisons are done differently (compared to DX9 fixes) if they aren't just checking if something is zero or non zero. Storing comparisons in a register and then checking if they were zero or non zero (true/false) wasn't intuitive at first, but then it allowed a lot of quick and effortless changes in the code. Fun stuff.
It's done that way because it's easier to implement in hardware. However, beware that if you ever get a NaN value (e.g. infinity) in some calculation those tests can behave really strangely and don't make sense (variations in compiler output that should produce a logically equivalent result don't, because the compiler made an assumption that NaN wouldn't appear there), whereas the DX9 versions still make some logical sense in that case.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
[quote="DarkStarSword"]I should really get around to implementing the conditional logic in the command list so you could do something like this to avoid the decompiler altogether if you don't need to otherwise modify the shader (example only - the syntax is not final):
[code] [ShaderOverrideFoo]
hash = ...
if x == 0 then
handling = skip
endif[/quote][/code]
Ah, so you could set up a toggle in the d3dx.ini instead? That would be awesome.
DarkStarSword said:I should really get around to implementing the conditional logic in the command list so you could do something like this to avoid the decompiler altogether if you don't need to otherwise modify the shader (example only - the syntax is not final):
[ShaderOverrideFoo]
hash = ...
if x == 0 then
handling = skip
endif
Ah, so you could set up a toggle in the d3dx.ini instead? That would be awesome.
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
[quote="DetectiveJohnKimble"][quote="bo3b"]@DetectiveJohnKimble: I'm not sure I understand exactly what you are wanting to do, but for this code, I would recommend not changing the other parameters. To disable, set the o0 to 0, not all of them.[/quote]
I'm trying to make the shader toggle on/off. It's the HUD in AC Origins so basically this is meant to be a hotkey for turning the HUD on and off.
[quote="bo3b"]The key part is that [i]out float4 o0 : SV_Position0,[/i]
which is o0. If you set position to zero, then the pixel shader has nothing to work with. This is explained in fair depth in my ShaderHacker class, so if you haven't looked at that, you need to. Even though the class talks about DX9, the principles are the same.
Just:
[code] float4 params = IniParams.Load(0);
if (params.x == 0)
{
o0 = 0;
return;
} else {
[/code][/quote]
Hmm, this gives me the same result as before.
[/quote]
If you are getting glitches, look to see if it is an HLSL Decompiler problem. Use F9 to show_original when it's up, and see if it changes. For properly Decompiled shaders, there should be no visual difference for an unmodified HLSL shader.
For getting the starting value, the iniParams.x starts at zero by default. If that's not what you want, you need to set it in the earlier part of the d3dx.ini where they are defined, or use the opposite boolean check.
Probably for an on/off toggle, you'd want to use the PS instead. It's later in the pipeline, and less likely to damage other visual items when disabled.
bo3b said:@DetectiveJohnKimble: I'm not sure I understand exactly what you are wanting to do, but for this code, I would recommend not changing the other parameters. To disable, set the o0 to 0, not all of them.
I'm trying to make the shader toggle on/off. It's the HUD in AC Origins so basically this is meant to be a hotkey for turning the HUD on and off.
bo3b said:The key part is that out float4 o0 : SV_Position0,
which is o0. If you set position to zero, then the pixel shader has nothing to work with. This is explained in fair depth in my ShaderHacker class, so if you haven't looked at that, you need to. Even though the class talks about DX9, the principles are the same.
If you are getting glitches, look to see if it is an HLSL Decompiler problem. Use F9 to show_original when it's up, and see if it changes. For properly Decompiled shaders, there should be no visual difference for an unmodified HLSL shader.
For getting the starting value, the iniParams.x starts at zero by default. If that's not what you want, you need to set it in the earlier part of the d3dx.ini where they are defined, or use the opposite boolean check.
Probably for an on/off toggle, you'd want to use the PS instead. It's later in the pipeline, and less likely to damage other visual items when disabled.
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607 Latest 3Dmigoto Release Bo3b's School for ShaderHackers
bo3b said:
If you are getting glitches, look to see if it is an HLSL Decompiler problem. Use F9 to show_original when it's up, and see if it changes. For properly Decompiled shaders, there should be no visual difference for an unmodified HLSL shader.
I'm supposed to hold F9 in hunting mode right? If I do that then the shader changes back to it's original form.
bo3b said:
Probably for an on/off toggle, you'd want to use the PS instead. It's later in the pipeline, and less likely to damage other visual items when disabled.
Well you mentioned it being harder to fix, so I understand if it's too much work. Just gonna post it incase you or anyone wants to have a whack at it:
[quote="masterotaku"]File name: 000ea4ff144f3d6d-ps.txt
I did it the way you had it. If x==0, it disables the HUD.[/quote]
Thanks. But there's another error:
[color="orange"]000ea4ff144f3d6d-ps_replace.txt(304,5-19): error X3000: unrecognized identifier 'dcl_globalFlags'[/color]
This shader is nuts, haha. But "dcl_globalFlags refactoringAllowed" isn't used at all later in the shader, so try commenting it, using "//dcl_globalFlags refactoringAllowed".
This shader is nuts, haha. But "dcl_globalFlags refactoringAllowed" isn't used at all later in the shader, so try commenting it, using "//dcl_globalFlags refactoringAllowed".
[quote="DetectiveJohnKimble"][quote="masterotaku"]File name: 000ea4ff144f3d6d-ps.txt
I did it the way you had it. If x==0, it disables the HUD.[/quote]
Thanks. But there's another error:
[color="orange"]000ea4ff144f3d6d-ps_replace.txt(304,5-19): error X3000: unrecognized identifier 'dcl_globalFlags'[/color]
[/quote]
Use the filename 000ea4ff144f3d6d-ps.txt not 000ea4ff144f3d6d-ps_replace.txt
[quote="DarkStarSword"]
Use the filename 000ea4ff144f3d6d-ps.txt not 000ea4ff144f3d6d-ps_replace.txt
[/quote]
This doesn't give me any error messages, but toggle is still not working. I have it set up like this in the d3dx.ini which I assume is correct?
[code][Constants]
x = 1
[Key1]
Key = caps
x = 0
type = toggle[/code]
You may also need to add this before the if_z/nz line, since the if instructions don't behave like the documentation or common sense would lead you to believe, so it is always best to pair them with a comparison instruction, even if all you are doing is comparing against zero/non-zero:
[code]
eq r28.x, r28.x, l(0.0)
[/code]
You may also need to add this before the if_z/nz line, since the if instructions don't behave like the documentation or common sense would lead you to believe, so it is always best to pair them with a comparison instruction, even if all you are doing is comparing against zero/non-zero:
eq r28.x, r28.x, l(0.0)
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
[quote="masterotaku"]Where I put "if_z r28.x", try changing it to "if_nz r28.x", just to see of it does the opposite effect and to see if it's a shader or hotkey problem.[/quote]
No change when doing this.
[quote="DarkStarSword"]You may also need to add this before the if_z/nz line, since the if instructions don't behave like the documentation or common sense would lead you to believe, so it is always best to pair them with a comparison instruction, even if all you are doing is comparing against zero/non-zero:
[code]
eq r28.x, r28.x, l(0.0)
[/code][/quote]
This crashes the game at the main menu.
masterotaku said:Where I put "if_z r28.x", try changing it to "if_nz r28.x", just to see of it does the opposite effect and to see if it's a shader or hotkey problem.
No change when doing this.
DarkStarSword said:You may also need to add this before the if_z/nz line, since the if instructions don't behave like the documentation or common sense would lead you to believe, so it is always best to pair them with a comparison instruction, even if all you are doing is comparing against zero/non-zero:
eq r28.x, r28.x, l(0.0)
This crashes the game at the main menu.
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
[quote] This crashes the game at the main menu. [/quote]o_O
Something copied incorrectly I'd guess (perhaps forgetting the open and/or close bracket in the float literal, or maybe including the line number that the forum added?) - the assembler was not written to cope with human input and doesn't handle errors (silently dropping instructions, corrupting the shader or just outright crashing), so you have to be very careful if you use it and be as precise as a machine.
I've improved the assembler considerably since the original implementation to cope with some human quirks (e.g. coping with tabs for indentation and adding comments mid line), but it is still extremely fragile - if you can work out exactly what you did that crashed it, please add that to this bug report:
https://github.com/bo3b/3Dmigoto/issues/36
Of course, it is possible to crash the GPU with a badly written assembly shader (e.g. via an infinite loop) that has nothing to do with our assembler, but I can't see how that would have happened in this case.
If you can't work it out, please post the complete shader here for us to check.
Something copied incorrectly I'd guess (perhaps forgetting the open and/or close bracket in the float literal, or maybe including the line number that the forum added?) - the assembler was not written to cope with human input and doesn't handle errors (silently dropping instructions, corrupting the shader or just outright crashing), so you have to be very careful if you use it and be as precise as a machine.
I've improved the assembler considerably since the original implementation to cope with some human quirks (e.g. coping with tabs for indentation and adding comments mid line), but it is still extremely fragile - if you can work out exactly what you did that crashed it, please add that to this bug report:
https://github.com/bo3b/3Dmigoto/issues/36
Of course, it is possible to crash the GPU with a badly written assembly shader (e.g. via an infinite loop) that has nothing to do with our assembler, but I can't see how that would have happened in this case.
If you can't work it out, please post the complete shader here for us to check.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Oh, hang on:
[quote][code]
dcl_temps 5[/code][/quote]
That might be a problem. Change that to:
[code]
dcl_temps 29[/code]
@masterotaku Always remember to bump dcl_temps to one higher than the largest temporary register number you have used, otherwise you will be corrupting some random GPU memory.
@masterotaku Always remember to bump dcl_temps to one higher than the largest temporary register number you have used, otherwise you will be corrupting some random GPU memory.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
"cannot map expression to vs_5_0 instruction set" it says.
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
I clearly haven't followed the discussion close enough and thought he was trying the disable code in a pixel shader.
I should really get around to implementing the conditional logic in the command list so you could do something like this to avoid the decompiler altogether if you don't need to otherwise modify the shader (example only - the syntax is not final):
It's done that way because it's easier to implement in hardware. However, beware that if you ever get a NaN value (e.g. infinity) in some calculation those tests can behave really strangely and don't make sense (variations in compiler output that should produce a logically equivalent result don't, because the compiler made an assumption that NaN wouldn't appear there), whereas the DX9 versions still make some logical sense in that case.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
Ah, so you could set up a toggle in the d3dx.ini instead? That would be awesome.
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
If you are getting glitches, look to see if it is an HLSL Decompiler problem. Use F9 to show_original when it's up, and see if it changes. For properly Decompiled shaders, there should be no visual difference for an unmodified HLSL shader.
For getting the starting value, the iniParams.x starts at zero by default. If that's not what you want, you need to set it in the earlier part of the d3dx.ini where they are defined, or use the opposite boolean check.
Probably for an on/off toggle, you'd want to use the PS instead. It's later in the pipeline, and less likely to damage other visual items when disabled.
Acer H5360 (1280x720@120Hz) - ASUS VG248QE with GSync mod - 3D Vision 1&2 - Driver 372.54
GTX 970 - i5-4670K@4.2GHz - 12GB RAM - Win7x64+evilKB2670838 - 4 Disk X25 RAID
SAGER NP9870-S - GTX 980 - i7-6700K - Win10 Pro 1607
Latest 3Dmigoto Release
Bo3b's School for ShaderHackers
I'm supposed to hold F9 in hunting mode right? If I do that then the shader changes back to it's original form.
Well you mentioned it being harder to fix, so I understand if it's too much work. Just gonna post it incase you or anyone wants to have a whack at it:
000ea4ff144f3d6d-ps_replace.txt(244,37): error X3000: syntax error: unexpected token '.'
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
I did it the way you had it. If x==0, it disables the HUD.
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
Thanks. But there's another error:
000ea4ff144f3d6d-ps_replace.txt(304,5-19): error X3000: unrecognized identifier 'dcl_globalFlags'
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
Use the filename 000ea4ff144f3d6d-ps.txt not 000ea4ff144f3d6d-ps_replace.txt
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
This doesn't give me any error messages, but toggle is still not working. I have it set up like this in the d3dx.ini which I assume is correct?
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
CPU: Intel Core i7 7700K @ 4.9GHz
Motherboard: Gigabyte Aorus GA-Z270X-Gaming 5
RAM: GSKILL Ripjaws Z 16GB 3866MHz CL18
GPU: MSI GeForce RTX 2080Ti Gaming X Trio
Monitor: Asus PG278QR
Speakers: Logitech Z506
Donations account: masterotakusuko@gmail.com
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
No change when doing this.
This crashes the game at the main menu.
1080 Ti - i7 5820k - 16Gb RAM - Win 10 version 1607 - ASUS VG236H (1920x1080@120Hz)
Something copied incorrectly I'd guess (perhaps forgetting the open and/or close bracket in the float literal, or maybe including the line number that the forum added?) - the assembler was not written to cope with human input and doesn't handle errors (silently dropping instructions, corrupting the shader or just outright crashing), so you have to be very careful if you use it and be as precise as a machine.
I've improved the assembler considerably since the original implementation to cope with some human quirks (e.g. coping with tabs for indentation and adding comments mid line), but it is still extremely fragile - if you can work out exactly what you did that crashed it, please add that to this bug report:
https://github.com/bo3b/3Dmigoto/issues/36
Of course, it is possible to crash the GPU with a badly written assembly shader (e.g. via an infinite loop) that has nothing to do with our assembler, but I can't see how that would have happened in this case.
If you can't work it out, please post the complete shader here for us to check.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword
That might be a problem. Change that to:
@masterotaku Always remember to bump dcl_temps to one higher than the largest temporary register number you have used, otherwise you will be corrupting some random GPU memory.
2x Geforce GTX 980 in SLI provided by NVIDIA, i7 6700K 4GHz CPU, Asus 27" VG278HE 144Hz 3D Monitor, BenQ W1070 3D Projector, 120" Elite Screens YardMaster 2, 32GB Corsair DDR4 3200MHz RAM, Samsung 850 EVO 500G SSD, 4x750GB HDD in RAID5, Gigabyte Z170X-Gaming 7 Motherboard, Corsair Obsidian 750D Airflow Edition Case, Corsair RM850i PSU, HTC Vive, Win 10 64bit
Alienware M17x R4 w/ built in 3D, Intel i7 3740QM, GTX 680m 2GB, 16GB DDR3 1600MHz RAM, Win7 64bit, 1TB SSD, 1TB HDD, 750GB HDD
Pre-release 3D fixes, shadertool.py and other goodies: http://github.com/DarkStarSword/3d-fixes
Support me on Patreon: https://www.patreon.com/DarkStarSword or PayPal: https://www.paypal.me/DarkStarSword