3Dmigoto now open-source...
  40 / 141    
Hmmm, that's a tricky one. I guess what you really want to know is either the distance to the nearest shoreline, or the vertical depth of the lake. [code] Camera --- \ \ \ \ --__ \ Lake _-- \ Value \----+---------------------/ ---- \ from ^\ |\ _-^ | Vertical \ depth \ | \ / | Depth \ buffer ^-_ \ _-^ ---- \ ^-\___--___-^ \ |----| --- Distance from nearest shore [/code] Unless the game is already providing either of those values for an effect it is already using it could be tricky to determine them. Games generally just use the value from the depth buffer to blend the water surface with the ground underwater, so my guess is that it would be fairly unlikely it will have handed it to you. One approach that might be worth trying is a screen space search on the depth buffer to try to find the approximate vertical depth. Like most screen space effects this would not be accurate, but there's a chance it might be close enough. The idea is that you iterate over the depth buffer downwards starting from the current pixel, and at each point you calculate the world space position from screen X+Y and the sampled depth (in the same way deferred lighting shaders often do). You then compare that to the world-space coordinate of the lake surface to find the closest point in X and Z, at which point the difference in Y will be the approximate vertical depth. Of course, you are unlikely to find an exact match on X and Z (which could be significantly worse if something is obscuring the view), so it's probably worth linearly interpolating between the last point that was too far and first point that is too close to somewhat counter that. This will also be problematic for pixels near the bottom of the screen where the information you are after is cut off the bottom of the depth buffer, and you would have to compromise here to find something that looks acceptable, but would never be perfect. Another approach could be to try to copy the geometry for the lake bed into the foam shader and use it to accurately find the vertical depth on each pixel, but there's probably no good way to do this since the lake bed would have been drawn during the opaque geometry stage a long time before the water surface is drawn in the transparent geometry stage. And if you were to try to do this by copying the vertex buffer it would be further complicated by the fact that the shader is unlikely to be used for just the lake bed, and is likely to be called multiple times (though with enough custom resources and some tricky logic that last part might be solvable). And even if you do manage to get the geometry into the pixel shader, searching it would likely be slow. Another approach (which is probably not possible yet) would be to render the lake bed from a second perspective whenever it is drawn. The idea would be to use an Orthographic projection from directly above the lake (ideally positioned so that it encompasses every part of the lake that the camera can see) using a custom shader that just renders it's height onto a custom render target, that can then be sampled from the foam shader to find the vertical depth. This would be tricky, but once I finish support for running custom shaders from a ShaderOverride it might just be doable.
Hmmm, that's a tricky one.

I guess what you really want to know is either the distance to the nearest shoreline, or the vertical depth of the lake.

Camera                                          ---
\ \
\ \
--__ \ Lake _-- \ Value
\----+---------------------/ ---- \ from
^\ |\ _-^ | Vertical \ depth
\ | \ / | Depth \ buffer
^-_ \ _-^ ---- \
^-\___--___-^ \
|----| ---
Distance from
nearest shore


Unless the game is already providing either of those values for an effect it is already using it could be tricky to determine them. Games generally just use the value from the depth buffer to blend the water surface with the ground underwater, so my guess is that it would be fairly unlikely it will have handed it to you.

One approach that might be worth trying is a screen space search on the depth buffer to try to find the approximate vertical depth. Like most screen space effects this would not be accurate, but there's a chance it might be close enough. The idea is that you iterate over the depth buffer downwards starting from the current pixel, and at each point you calculate the world space position from screen X+Y and the sampled depth (in the same way deferred lighting shaders often do). You then compare that to the world-space coordinate of the lake surface to find the closest point in X and Z, at which point the difference in Y will be the approximate vertical depth.

Of course, you are unlikely to find an exact match on X and Z (which could be significantly worse if something is obscuring the view), so it's probably worth linearly interpolating between the last point that was too far and first point that is too close to somewhat counter that. This will also be problematic for pixels near the bottom of the screen where the information you are after is cut off the bottom of the depth buffer, and you would have to compromise here to find something that looks acceptable, but would never be perfect.


Another approach could be to try to copy the geometry for the lake bed into the foam shader and use it to accurately find the vertical depth on each pixel, but there's probably no good way to do this since the lake bed would have been drawn during the opaque geometry stage a long time before the water surface is drawn in the transparent geometry stage. And if you were to try to do this by copying the vertex buffer it would be further complicated by the fact that the shader is unlikely to be used for just the lake bed, and is likely to be called multiple times (though with enough custom resources and some tricky logic that last part might be solvable). And even if you do manage to get the geometry into the pixel shader, searching it would likely be slow.


Another approach (which is probably not possible yet) would be to render the lake bed from a second perspective whenever it is drawn. The idea would be to use an Orthographic projection from directly above the lake (ideally positioned so that it encompasses every part of the lake that the camera can see) using a custom shader that just renders it's height onto a custom render target, that can then be sampled from the foam shader to find the vertical depth. This would be tricky, but once I finish support for running custom shaders from a ShaderOverride it might just be doable.

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

Posted 12/07/2015 04:03 AM   
[quote="daspwan"]how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable[/quote]That's all you need to do (that and restart the game). The version on the blog won't have an overlay as it's using an old stable version of 3DMigoto, but the hunting keys should still work. What are you hunting? We finally fixed all the crashing issues in that game on the latest 3DMigoto (well, not quite - there's still a crash on launch issue that only affects Windows 8.0), and I've got a lot of fairly major updates to the fix (most of which depend on new features in 3DMigoto): - auto crosshair - auto HUD - hairworks W==1 glitch - No-AA shadow sync issue - Weapon shop background fix independent of resolution - HBAO+ artefacts - Reflected sun/moon glow - Soft shadow box artefact - Specular highlights accuracy improvement - Window/door shadow clipping - Environment reflections on texture quality >= high - Several other general fixes including some (only some) community maps Once the Win 8.0 issue is fixed and I've had a chance to look at a few other things I'll be releasing the update on the blog (probably in the next week or two). If you want a preview, use the version in the 3DMigoto git repository with the latest 3DMigoto DLL.
daspwan said:how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable
That's all you need to do (that and restart the game). The version on the blog won't have an overlay as it's using an old stable version of 3DMigoto, but the hunting keys should still work.

What are you hunting? We finally fixed all the crashing issues in that game on the latest 3DMigoto (well, not quite - there's still a crash on launch issue that only affects Windows 8.0), and I've got a lot of fairly major updates to the fix (most of which depend on new features in 3DMigoto):
- auto crosshair
- auto HUD
- hairworks W==1 glitch
- No-AA shadow sync issue
- Weapon shop background fix independent of resolution
- HBAO+ artefacts
- Reflected sun/moon glow
- Soft shadow box artefact
- Specular highlights accuracy improvement
- Window/door shadow clipping
- Environment reflections on texture quality >= high
- Several other general fixes including some (only some) community maps

Once the Win 8.0 issue is fixed and I've had a chance to look at a few other things I'll be releasing the update on the blog (probably in the next week or two). If you want a preview, use the version in the 3DMigoto git repository with the latest 3DMigoto DLL.

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

Posted 12/07/2015 04:53 AM   
[quote="Oomek"]If you have even the craziest ideas I'm all ears.[/quote] Here's another crazy idea - I'm not sure how practical this is, but since the water won't change in each level you could potentially create a texture with the outline of the lake and load that into the game, where you can sample it from the foam shader by mapping world coordinates into texture coordinates. There's a few tricky parts here: Firstly - creating the textures... If you can dump out the geometry from the game (possibly using 3DMigoto's frame analysis to dump vertex and index buffers and massaging the result with a script, possibly using other tools that are designed to extract geometry from games, or possibly extracting the geometry from the game files using whatever modding tools are available for that engine) you could probably use that to create it, but there's probably nothing that will just give you what you need easily. Otherwise you could just paint on the texture and reload in game to see what it looks like, but that would be error-prone and time consuming. Secondly - the texture resolution... You would want it detailed enough so the shoreline can be filled in and look good in game (interpolation would help reduce this need), but you probably don't want a single macro texture that stretches over the entire level, but I'm not sure that breaking it up into smaller textures would help since they all would be bound to the pipeline anyway. I don't really have a good answer here. Thirdly - determining which textures to use for the current level... You could use a key to switch textures, but people would forget to use it. You might be able to match the texture showing the level in the level select screen to determine it (if they are unique - not sure) and set an ini param or change the custom resources from the [TextureOverride] (remembering that those features will only work from a TextureOverride if the texture slot is referenced in the ShaderOverride with a checktextureoverride=ps-t0 or similar).
Oomek said:If you have even the craziest ideas I'm all ears.

Here's another crazy idea - I'm not sure how practical this is, but since the water won't change in each level you could potentially create a texture with the outline of the lake and load that into the game, where you can sample it from the foam shader by mapping world coordinates into texture coordinates.

There's a few tricky parts here:

Firstly - creating the textures... If you can dump out the geometry from the game (possibly using 3DMigoto's frame analysis to dump vertex and index buffers and massaging the result with a script, possibly using other tools that are designed to extract geometry from games, or possibly extracting the geometry from the game files using whatever modding tools are available for that engine) you could probably use that to create it, but there's probably nothing that will just give you what you need easily. Otherwise you could just paint on the texture and reload in game to see what it looks like, but that would be error-prone and time consuming.

Secondly - the texture resolution... You would want it detailed enough so the shoreline can be filled in and look good in game (interpolation would help reduce this need), but you probably don't want a single macro texture that stretches over the entire level, but I'm not sure that breaking it up into smaller textures would help since they all would be bound to the pipeline anyway. I don't really have a good answer here.

Thirdly - determining which textures to use for the current level... You could use a key to switch textures, but people would forget to use it. You might be able to match the texture showing the level in the level select screen to determine it (if they are unique - not sure) and set an ini param or change the custom resources from the [TextureOverride] (remembering that those features will only work from a TextureOverride if the texture slot is referenced in the ShaderOverride with a checktextureoverride=ps-t0 or similar).

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

Posted 12/07/2015 05:14 AM   
[quote="DarkStarSword"][quote="daspwan"]how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable[/quote]That's all you need to do (that and restart the game). The version on the blog won't have an overlay as it's using an old stable version of 3DMigoto, but the hunting keys should still work. What are you hunting?[/quote]I saw that you were posting in the Dying Light thread about the weapon depth adjustment. If you're thinking about trying the same thing here know that I briefly experimented with this, and quickly decided it was a bad idea because it is guaranteed to break something - the hands are connected to the steering wheel, the steering wheel is connected to the vehicle, the vehicle is connected to the road, the road is connected to the... well, you get the idea - if you try to adjust the hand depth you will have to misalign something because Far Cry 4 has a lot of hands on animations with physical contact. If you're willing to accept breaking the world in this way you're welcome to try it, but I wouldn't recommend it.
DarkStarSword said:
daspwan said:how can i enable shader hunting in farcry4 fix ? change hunting=1 in d3d9.ini,and it's still disable
That's all you need to do (that and restart the game). The version on the blog won't have an overlay as it's using an old stable version of 3DMigoto, but the hunting keys should still work.

What are you hunting?
I saw that you were posting in the Dying Light thread about the weapon depth adjustment. If you're thinking about trying the same thing here know that I briefly experimented with this, and quickly decided it was a bad idea because it is guaranteed to break something - the hands are connected to the steering wheel, the steering wheel is connected to the vehicle, the vehicle is connected to the road, the road is connected to the... well, you get the idea - if you try to adjust the hand depth you will have to misalign something because Far Cry 4 has a lot of hands on animations with physical contact. If you're willing to accept breaking the world in this way you're welcome to try it, but I wouldn't recommend it.

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

Posted 12/07/2015 06:11 AM   
Hey guys. I'm back at it again with another game (MKX). This time I'll be happy just to disable some broken effects, maybe, but essentially it looks like 3DM is having decompiler errors with the shaders in this game. When I dump a broken shader I'm getting a high/low beep (sometimes after a really lengthy pause), the shader code keeps referencing known errors and such, and attempting to modify the output in the shader has no result. I'm using one of the latest versions 1.2.9. Is there any settings that I could change in the d3dx.ini file that could help, or would this require some sort of fix in the wrapper decompiler? Or would it be required to manually fix each dumped shader (and if so, is that something that I could be taught/advised how to do that on my own)? Here's the shader code: [code] cbuffer _Globals : register(b0) { float SpecularMipFactor : packoffset(c0); bool bUseBlurSkinning : packoffset(c0.y); bool bFogEnabled : packoffset(c0.z); float4 RefiningSampleOffsets[12] : packoffset(c1); float4 EdgeSampleOffsets[2] : packoffset(c13); float4 UniformSampleOffsets[8] : packoffset(c15); float4 InvRandomAngleTextureSize : packoffset(c23); float4 ShadowBufferResolution : packoffset(c24); float4 AOBufferSize : packoffset(c25); uint4 PointListIndices[8] : packoffset(c26); uint4 SpotListIndices[8] : packoffset(c34); uint4 SpotShadowListIndices[8] : packoffset(c42); uint4 BoxListIndices[8] : packoffset(c50); uint4 TubeListIndices[8] : packoffset(c58); uint4 PerPixelListCountA : packoffset(c66); uint4 PerPixelListCountB : packoffset(c67); float3 AmbientColor : packoffset(c68); float4 MaterialMultiplier : packoffset(c69); float DirectLightingScale : packoffset(c70); float4 AODebugFlags : packoffset(c71); float LightIntensityClampValue : packoffset(c72); float SpecularLightIntensityClampValue : packoffset(c72.y); float4 PerObjectFog : packoffset(c73); float ReflectionRoughnessAdjustment : packoffset(c74); float4x4 ScreenToWorld : packoffset(c75); uint4 PerVertexLightIndices[8] : packoffset(c79); uint4 PerVertexLightCounts : packoffset(c87); uint PerVertexLightListOffset : packoffset(c88); float3 EnvironmentMapCenter[4] : packoffset(c89); float3 EnvironmentMapBoxMin[4] : packoffset(c93); float3 EnvironmentMapBoxMax[4] : packoffset(c97); uint4 EnvironmentMapIndex : packoffset(c101); float3 EnvironmentBoxWeights[4] : packoffset(c102); float EnvironmentIBLContributionIntensity : packoffset(c105.w); float DiffuseIndirectMipLevel : packoffset(c106); float2 FloorDistortionOffsetScale : packoffset(c106.y); float3 FloorReflectionFadeParameters : packoffset(c107); float TuneCurvature : packoffset(c107.w) = float(1); float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5); uint SphereCount : packoffset(c108.w); float2 LevelDesatAndFadeControls : packoffset(c109); bool bUseVoxelLighting : packoffset(c109.z); float4x4 WorldToVoxelTransform : packoffset(c110); float3 VoxelSize : packoffset(c114); float2 VoxelLightingControl : packoffset(c115); float3 OcclusionVoxelSize : packoffset(c116); float4x4 WorldToOccVoxelTransform : packoffset(c117); float3 AOScaleAndBias : packoffset(c121); float4 ObjectWorldPositionAndRadius : packoffset(c122); float3 ObjectOrientation : packoffset(c123); float3 ObjectPostProjectionPosition : packoffset(c124); float3 ObjectNDCPosition : packoffset(c125); float4 ObjectMacroUVScales : packoffset(c126); float4 UserWorldSpaceClipPlanes[2] : packoffset(c127); float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129); float4 DecalShaderUVs : packoffset(c130); float4 TessellationFactors : packoffset(c131); float4x4 LocalToWorld : packoffset(c132); float4x4 PreviousLocalToWorld : packoffset(c136); float LocalToWorldRotDeterminantFlip : packoffset(c140); float3x3 WorldToLocal : packoffset(c141); float4 ShadowCoordinateScaleBias : packoffset(c144); uint HasVertexColorData : packoffset(c145); uint NumTexCoordsPerVertex : packoffset(c145.y); float CoreRadius : packoffset(c145.z); float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0); StructuredBuffer<PositionBuffer> PositionBuffer : register(t0); StructuredBuffer<ColorBuffer> ColorBuffer : register(t2); StructuredBuffer<TexCoords> TexCoords : register(t3); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( uint v0 : SV_VertexID0, out float2 o0 : SV_ClipDistance0, out float4 o1 : COLOR0, out float4 o2 : TEXCOORD0, out float4 o3 : TEXCOORD7, out float4 o4 : SV_Position0) { float4 r0,r1,r2; uint4 bitmask, uiDest; float4 fDest; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx r0.x = PositionBuffer[]..swiz; r0.y = PositionBuffer[]..swiz; r0.z = PositionBuffer[]..swiz; r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy; r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw; r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw; r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw; o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw); o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw); r1.xy = (int2)v0.xx * HasVertexColorData; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx r1.x = PositionBuffer[]..swiz; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx r1.y = PositionBuffer[]..swiz; r1.z = (int)r1.x & 255; r2.x = (uint)r1.z; if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8; if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16; r1.x = (uint)r1.x >> 24; r2.yzw = (uint3)r1.zwx; o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw; r1.x = (int)r1.y & 0x0000ffff; r1.y = (uint)r1.y >> 16; o2.xy = f16tof32(r1.xy); r1.x = 1 < NumTexCoordsPerVertex; r1.x = r1.x ? 1 : 0; r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x); // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx r1.x = PositionBuffer[]..swiz; r1.y = (int)r1.x & 0x0000ffff; r1.x = (uint)r1.x >> 16; o2.zw = f16tof32(r1.xy); r1.xyzw = cb1[1].xyzw * r0.yyyy; r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw; r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw; r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw; o3.xyzw = r0.xyzw; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 // // using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float SpecularMipFactor; // Offset: 0 Size: 4 [unused] // bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused] // bool bFogEnabled; // Offset: 8 Size: 4 [unused] // float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused] // float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused] // float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused] // float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused] // float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused] // float4 AOBufferSize; // Offset: 400 Size: 16 [unused] // uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused] // uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused] // uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused] // uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused] // uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused] // uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused] // uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused] // float3 AmbientColor; // Offset: 1088 Size: 12 [unused] // float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused] // float DirectLightingScale; // Offset: 1120 Size: 4 [unused] // float4 AODebugFlags; // Offset: 1136 Size: 16 [unused] // float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused] // float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused] // float4 PerObjectFog; // Offset: 1168 Size: 16 [unused] // float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused] // float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused] // uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused] // uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused] // uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused] // float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused] // float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused] // float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused] // uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused] // float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused] // float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused] // float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused] // float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused] // float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused] // float TuneCurvature; // Offset: 1724 Size: 4 [unused] // = 0x3f800000 // float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused] // = 0x3f19999a 0x3f000000 0x3f000000 // uint SphereCount; // Offset: 1740 Size: 4 [unused] // float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused] // bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused] // float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused] // float3 VoxelSize; // Offset: 1824 Size: 12 [unused] // float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused] // float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused] // float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused] // float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused] // float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused] // float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused] // float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused] // float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused] // float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused] // float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32 // float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused] // float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused] // float4 TessellationFactors; // Offset: 2096 Size: 16 [unused] // float4x4 LocalToWorld; // Offset: 2112 Size: 64 // float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused] // float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused] // float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused] // float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused] // uint HasVertexColorData; // Offset: 2320 Size: 4 // uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4 // float CoreRadius; // Offset: 2328 Size: 4 [unused] // float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused] // = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000 // 0xbf5753b5 0x3f056b12 0x00000000 0x00000000 // 0xbf37ab75 0xbf00d307 0x00000000 0x00000000 // 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000 // 0xbf29c758 0x3e1e8922 0x00000000 0x00000000 // 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000 // 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000 // 0xbeb11559 0xbf107b24 0x00000000 0x00000000 // 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000 // 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000 // 0xbe120924 0xbcba417a 0x00000000 0x00000000 // 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000 // 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000 // 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000 // 0x3e29f948 0x3dbeb181 0x00000000 0x00000000 // 0x3e81dcf9 0x3f383372 0x00000000 0x00000000 // 0x3ebd3587 0xbf27af53 0x00000000 0x00000000 // 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000 // 0x3f07df09 0xbebadd7b 0x00000000 0x00000000 // 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000 // 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000 // 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000 // 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000 // 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000 // 0x3f7debfb 0xbf28474e // // } // // cbuffer VSOffsetConstants // { // // float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64 // float4 ViewOrigin; // Offset: 64 Size: 16 [unused] // // struct FFogBand // { // // float4 Color; // Offset: 80 // float4 DistanceDensity; // Offset: 96 // // } FogBandData[8]; // Offset: 80 Size: 256 [unused] // // } // // Resource bind info for PositionBuffer // { // // struct VSInputPosition // { // // float3 Position; // Offset: 0 // // } $Element; // Offset: 0 Size: 12 // // } // // Resource bind info for ColorBuffer // { // // struct VSInputColor // { // // uint Color; // Offset: 0 // // } $Element; // Offset: 0 Size: 4 // // } // // Resource bind info for TexCoords // { // // uint $Element; // Offset: 0 Size: 4 // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // PositionBuffer texture struct r/o 0 1 // ColorBuffer texture struct r/o 2 1 // TexCoords texture struct r/o 3 1 // $Globals cbuffer NA NA 0 1 // VSOffsetConstants cbuffer NA NA 1 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_VertexID 0 x 0 VERTID uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_ClipDistance 0 xy 0 CLIPDST float xy // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xyzw 2 NONE float xyzw // TEXCOORD 7 xyzw 3 NONE float xyzw // SV_Position 0 xyzw 4 POS float xyzw // vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[146], immediateIndexed dcl_constantbuffer cb1[4], immediateIndexed dcl_resource_structured t0, 12 dcl_resource_structured t2, 4 dcl_resource_structured t3, 4 dcl_input_sgv v0.x, vertex_id dcl_output_siv o0.xy, clip_distance dcl_output o1.xyzw dcl_output o2.xyzw dcl_output o3.xyzw dcl_output_siv o4.xyzw, position dcl_temps 3 ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx mul r1.xyzw, r0.yyyy, cb0[133].xyzw mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw add r0.xyzw, r0.xyzw, cb0[135].xyzw dp4 o0.x, cb0[127].xyzw, r0.xyzw dp4 o0.y, cb0[128].xyzw, r0.xyzw imul null, r1.xy, v0.xxxx, cb0[145].xyxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx and r1.z, r1.x, l(255) utof r2.x, r1.z ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx ushr r1.x, r1.x, l(24) utof r2.yzw, r1.zzwx mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886) and r1.x, r1.y, l(0x0000ffff) ushr r1.y, r1.y, l(16) f16tof32 o2.xy, r1.xyxx ult r1.x, l(1), cb0[145].y and r1.x, r1.x, l(1) imad r1.x, v0.x, cb0[145].y, r1.x ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx and r1.y, r1.x, l(0x0000ffff) ushr r1.x, r1.x, l(16) f16tof32 o2.zw, r1.xxxy mul r1.xyzw, r0.yyyy, cb1[1].xyzw mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw mov o3.xyzw, r0.xyzw mov o4.xyzw, r0.xyzw ret // Approximately 33 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ [/code]
Hey guys. I'm back at it again with another game (MKX). This time I'll be happy just to disable some broken effects, maybe, but essentially it looks like 3DM is having decompiler errors with the shaders in this game. When I dump a broken shader I'm getting a high/low beep (sometimes after a really lengthy pause), the shader code keeps referencing known errors and such, and attempting to modify the output in the shader has no result.

I'm using one of the latest versions 1.2.9. Is there any settings that I could change in the d3dx.ini file that could help, or would this require some sort of fix in the wrapper decompiler? Or would it be required to manually fix each dumped shader (and if so, is that something that I could be taught/advised how to do that on my own)?

Here's the shader code:

cbuffer _Globals : register(b0)
{
float SpecularMipFactor : packoffset(c0);
bool bUseBlurSkinning : packoffset(c0.y);
bool bFogEnabled : packoffset(c0.z);
float4 RefiningSampleOffsets[12] : packoffset(c1);
float4 EdgeSampleOffsets[2] : packoffset(c13);
float4 UniformSampleOffsets[8] : packoffset(c15);
float4 InvRandomAngleTextureSize : packoffset(c23);
float4 ShadowBufferResolution : packoffset(c24);
float4 AOBufferSize : packoffset(c25);
uint4 PointListIndices[8] : packoffset(c26);
uint4 SpotListIndices[8] : packoffset(c34);
uint4 SpotShadowListIndices[8] : packoffset(c42);
uint4 BoxListIndices[8] : packoffset(c50);
uint4 TubeListIndices[8] : packoffset(c58);
uint4 PerPixelListCountA : packoffset(c66);
uint4 PerPixelListCountB : packoffset(c67);
float3 AmbientColor : packoffset(c68);
float4 MaterialMultiplier : packoffset(c69);
float DirectLightingScale : packoffset(c70);
float4 AODebugFlags : packoffset(c71);
float LightIntensityClampValue : packoffset(c72);
float SpecularLightIntensityClampValue : packoffset(c72.y);
float4 PerObjectFog : packoffset(c73);
float ReflectionRoughnessAdjustment : packoffset(c74);
float4x4 ScreenToWorld : packoffset(c75);
uint4 PerVertexLightIndices[8] : packoffset(c79);
uint4 PerVertexLightCounts : packoffset(c87);
uint PerVertexLightListOffset : packoffset(c88);
float3 EnvironmentMapCenter[4] : packoffset(c89);
float3 EnvironmentMapBoxMin[4] : packoffset(c93);
float3 EnvironmentMapBoxMax[4] : packoffset(c97);
uint4 EnvironmentMapIndex : packoffset(c101);
float3 EnvironmentBoxWeights[4] : packoffset(c102);
float EnvironmentIBLContributionIntensity : packoffset(c105.w);
float DiffuseIndirectMipLevel : packoffset(c106);
float2 FloorDistortionOffsetScale : packoffset(c106.y);
float3 FloorReflectionFadeParameters : packoffset(c107);
float TuneCurvature : packoffset(c107.w) = float(1);
float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5);
uint SphereCount : packoffset(c108.w);
float2 LevelDesatAndFadeControls : packoffset(c109);
bool bUseVoxelLighting : packoffset(c109.z);
float4x4 WorldToVoxelTransform : packoffset(c110);
float3 VoxelSize : packoffset(c114);
float2 VoxelLightingControl : packoffset(c115);
float3 OcclusionVoxelSize : packoffset(c116);
float4x4 WorldToOccVoxelTransform : packoffset(c117);
float3 AOScaleAndBias : packoffset(c121);
float4 ObjectWorldPositionAndRadius : packoffset(c122);
float3 ObjectOrientation : packoffset(c123);
float3 ObjectPostProjectionPosition : packoffset(c124);
float3 ObjectNDCPosition : packoffset(c125);
float4 ObjectMacroUVScales : packoffset(c126);
float4 UserWorldSpaceClipPlanes[2] : packoffset(c127);
float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129);
float4 DecalShaderUVs : packoffset(c130);
float4 TessellationFactors : packoffset(c131);
float4x4 LocalToWorld : packoffset(c132);
float4x4 PreviousLocalToWorld : packoffset(c136);
float LocalToWorldRotDeterminantFlip : packoffset(c140);
float3x3 WorldToLocal : packoffset(c141);
float4 ShadowCoordinateScaleBias : packoffset(c144);
uint HasVertexColorData : packoffset(c145);
uint NumTexCoordsPerVertex : packoffset(c145.y);
float CoreRadius : packoffset(c145.z);
float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0);
StructuredBuffer<PositionBuffer> PositionBuffer : register(t0);
StructuredBuffer<ColorBuffer> ColorBuffer : register(t2);
StructuredBuffer<TexCoords> TexCoords : register(t3);

Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
uint v0 : SV_VertexID0,
out float2 o0 : SV_ClipDistance0,
out float4 o1 : COLOR0,
out float4 o2 : TEXCOORD0,
out float4 o3 : TEXCOORD7,
out float4 o4 : SV_Position0)
{
float4 r0,r1,r2;
uint4 bitmask, uiDest;
float4 fDest;

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
r0.x = PositionBuffer[]..swiz;
r0.y = PositionBuffer[]..swiz;
r0.z = PositionBuffer[]..swiz;
r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy;
r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw;
o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw);
o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw);
r1.xy = (int2)v0.xx * HasVertexColorData;
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
r1.x = PositionBuffer[]..swiz;
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
r1.y = PositionBuffer[]..swiz;
r1.z = (int)r1.x & 255;
r2.x = (uint)r1.z;
if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8;
if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16;
r1.x = (uint)r1.x >> 24;
r2.yzw = (uint3)r1.zwx;
o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw;
r1.x = (int)r1.y & 0x0000ffff;
r1.y = (uint)r1.y >> 16;
o2.xy = f16tof32(r1.xy);
r1.x = 1 < NumTexCoordsPerVertex;
r1.x = r1.x ? 1 : 0;
r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x);
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
r1.x = PositionBuffer[]..swiz;
r1.y = (int)r1.x & 0x0000ffff;
r1.x = (uint)r1.x >> 16;
o2.zw = f16tof32(r1.xy);
r1.xyzw = cb1[1].xyzw * r0.yyyy;
r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw;
r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw;
r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw;
o3.xyzw = r0.xyzw;
return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
// using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float SpecularMipFactor; // Offset: 0 Size: 4 [unused]
// bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused]
// bool bFogEnabled; // Offset: 8 Size: 4 [unused]
// float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused]
// float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused]
// float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused]
// float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused]
// float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused]
// float4 AOBufferSize; // Offset: 400 Size: 16 [unused]
// uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused]
// uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused]
// uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused]
// uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused]
// uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused]
// uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused]
// uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused]
// float3 AmbientColor; // Offset: 1088 Size: 12 [unused]
// float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused]
// float DirectLightingScale; // Offset: 1120 Size: 4 [unused]
// float4 AODebugFlags; // Offset: 1136 Size: 16 [unused]
// float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused]
// float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused]
// float4 PerObjectFog; // Offset: 1168 Size: 16 [unused]
// float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused]
// float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused]
// uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused]
// uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused]
// uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused]
// float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused]
// float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused]
// float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused]
// uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused]
// float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused]
// float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused]
// float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused]
// float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused]
// float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused]
// float TuneCurvature; // Offset: 1724 Size: 4 [unused]
// = 0x3f800000
// float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused]
// = 0x3f19999a 0x3f000000 0x3f000000
// uint SphereCount; // Offset: 1740 Size: 4 [unused]
// float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused]
// bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused]
// float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused]
// float3 VoxelSize; // Offset: 1824 Size: 12 [unused]
// float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused]
// float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused]
// float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused]
// float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused]
// float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused]
// float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused]
// float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused]
// float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused]
// float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused]
// float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32
// float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused]
// float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused]
// float4 TessellationFactors; // Offset: 2096 Size: 16 [unused]
// float4x4 LocalToWorld; // Offset: 2112 Size: 64
// float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused]
// float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused]
// float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused]
// float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused]
// uint HasVertexColorData; // Offset: 2320 Size: 4
// uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4
// float CoreRadius; // Offset: 2328 Size: 4 [unused]
// float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused]
// = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000
// 0xbf5753b5 0x3f056b12 0x00000000 0x00000000
// 0xbf37ab75 0xbf00d307 0x00000000 0x00000000
// 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000
// 0xbf29c758 0x3e1e8922 0x00000000 0x00000000
// 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000
// 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000
// 0xbeb11559 0xbf107b24 0x00000000 0x00000000
// 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000
// 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000
// 0xbe120924 0xbcba417a 0x00000000 0x00000000
// 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000
// 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000
// 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000
// 0x3e29f948 0x3dbeb181 0x00000000 0x00000000
// 0x3e81dcf9 0x3f383372 0x00000000 0x00000000
// 0x3ebd3587 0xbf27af53 0x00000000 0x00000000
// 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000
// 0x3f07df09 0xbebadd7b 0x00000000 0x00000000
// 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000
// 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000
// 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000
// 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000
// 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000
// 0x3f7debfb 0xbf28474e
//
// }
//
// cbuffer VSOffsetConstants
// {
//
// float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64
// float4 ViewOrigin; // Offset: 64 Size: 16 [unused]
//
// struct FFogBand
// {
//
// float4 Color; // Offset: 80
// float4 DistanceDensity; // Offset: 96
//
// } FogBandData[8]; // Offset: 80 Size: 256 [unused]
//
// }
//
// Resource bind info for PositionBuffer
// {
//
// struct VSInputPosition
// {
//
// float3 Position; // Offset: 0
//
// } $Element; // Offset: 0 Size: 12
//
// }
//
// Resource bind info for ColorBuffer
// {
//
// struct VSInputColor
// {
//
// uint Color; // Offset: 0
//
// } $Element; // Offset: 0 Size: 4
//
// }
//
// Resource bind info for TexCoords
// {
//
// uint $Element; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PositionBuffer texture struct r/o 0 1
// ColorBuffer texture struct r/o 2 1
// TexCoords texture struct r/o 3 1
// $Globals cbuffer NA NA 0 1
// VSOffsetConstants cbuffer NA NA 1 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID 0 x 0 VERTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_ClipDistance 0 xy 0 CLIPDST float xy
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xyzw 2 NONE float xyzw
// TEXCOORD 7 xyzw 3 NONE float xyzw
// SV_Position 0 xyzw 4 POS float xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[146], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_resource_structured t0, 12
dcl_resource_structured t2, 4
dcl_resource_structured t3, 4
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xy, clip_distance
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output_siv o4.xyzw, position
dcl_temps 3
ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
mul r1.xyzw, r0.yyyy, cb0[133].xyzw
mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb0[135].xyzw
dp4 o0.x, cb0[127].xyzw, r0.xyzw
dp4 o0.y, cb0[128].xyzw, r0.xyzw
imul null, r1.xy, v0.xxxx, cb0[145].xyxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
and r1.z, r1.x, l(255)
utof r2.x, r1.z
ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx
ushr r1.x, r1.x, l(24)
utof r2.yzw, r1.zzwx
mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886)
and r1.x, r1.y, l(0x0000ffff)
ushr r1.y, r1.y, l(16)
f16tof32 o2.xy, r1.xyxx
ult r1.x, l(1), cb0[145].y
and r1.x, r1.x, l(1)
imad r1.x, v0.x, cb0[145].y, r1.x
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
and r1.y, r1.x, l(0x0000ffff)
ushr r1.x, r1.x, l(16)
f16tof32 o2.zw, r1.xxxy
mul r1.xyzw, r0.yyyy, cb1[1].xyzw
mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw
mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw
mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw
mov o3.xyzw, r0.xyzw
mov o4.xyzw, r0.xyzw
ret
// Approximately 33 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

3D Gaming Rig: CPU: i7 7700K @ 4.9Ghz | Mobo: Asus Maximus Hero VIII | RAM: Corsair Dominator 16GB | GPU: 2 x GTX 1080 Ti SLI | 3xSSDs for OS and Apps, 2 x HDD's for 11GB storage | PSU: Seasonic X-1250 M2| Case: Corsair C70 | Cooling: Corsair H115i Hydro cooler | Displays: Asus PG278QR, BenQ XL2420TX & BenQ HT1075 | OS: Windows 10 Pro + Windows 7 dual boot

Like my fixes? Dontations can be made to: www.paypal.me/DShanz or rshannonca@gmail.com
Like electronic music? Check out: www.soundcloud.com/dj-ryan-king

Posted 12/07/2015 10:59 AM   
Thank you DarkStarSword for all your precious suggestions. I will try to get most of it. I'm trying now your first method, but it seems like the depth buffer is beeing occluded by the car model (for some stupid reason). Does it mean I can forget about it and move to the next method? [img]http://i.imgur.com/Po0Rkyy.jpg[/img]
Thank you DarkStarSword for all your precious suggestions. I will try to get most of it.
I'm trying now your first method, but it seems like the depth buffer is beeing occluded by the car model (for some stupid reason). Does it mean I can forget about it and move to the next method?

Image

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/07/2015 10:29 PM   
[quote="Oomek"]Thank you DarkStarSword for all your precious suggestions. I will try to get most of it. I'm trying now your first method, but it seems like the depth buffer is beeing occluded by the car model (for some stupid reason). Does it mean I can forget about it and move to another?[/quote]Yeah, I knew that was going to happen (though I was hoping it wouldn't be quite that bad) - screen space reflections run into a similar problem. You might be able to tweak the algorithm to behave better in that situation (maybe detect when a point sampled is above the surface and disregard it?), but no matter what the nature of the algorithm will only ever be an approximation at best.
Oomek said:Thank you DarkStarSword for all your precious suggestions. I will try to get most of it.
I'm trying now your first method, but it seems like the depth buffer is beeing occluded by the car model (for some stupid reason). Does it mean I can forget about it and move to another?
Yeah, I knew that was going to happen (though I was hoping it wouldn't be quite that bad) - screen space reflections run into a similar problem. You might be able to tweak the algorithm to behave better in that situation (maybe detect when a point sampled is above the surface and disregard it?), but no matter what the nature of the algorithm will only ever be an approximation at best.

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

Posted 12/07/2015 11:06 PM   
[quote="DJ-RK"]but essentially it looks like 3DM is having decompiler errors with the shaders in this game. When I dump a broken shader I'm getting a high/low beep (sometimes after a really lengthy pause), the shader code keeps referencing known errors and such, and attempting to modify the output in the shader has no result. I'm using one of the latest versions 1.2.9. Is there any settings that I could change in the d3dx.ini file that could help, or would this require some sort of fix in the wrapper decompiler? Or would it be required to manually fix each dumped shader (and if so, is that something that I could be taught/advised how to do that on my own)?[/quote] This will need a manual fix to the shaders - are there just one or two like this, or does it seem that most of the shaders use these instructions? I gave helifax a hand fixing up one of these the other day - you might like to go over these posts and see if you can work out how to do the same type of fixup here: [url]https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4739720/#4739720[/url] [url]https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4740050/#4740050[/url] @bo3b - was this one of the cases you were looking at trying to improve in the decompiler?
DJ-RK said:but essentially it looks like 3DM is having decompiler errors with the shaders in this game. When I dump a broken shader I'm getting a high/low beep (sometimes after a really lengthy pause), the shader code keeps referencing known errors and such, and attempting to modify the output in the shader has no result.

I'm using one of the latest versions 1.2.9. Is there any settings that I could change in the d3dx.ini file that could help, or would this require some sort of fix in the wrapper decompiler? Or would it be required to manually fix each dumped shader (and if so, is that something that I could be taught/advised how to do that on my own)?

This will need a manual fix to the shaders - are there just one or two like this, or does it seem that most of the shaders use these instructions?

I gave helifax a hand fixing up one of these the other day - you might like to go over these posts and see if you can work out how to do the same type of fixup here:
https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4739720/#4739720
https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4740050/#4740050

@bo3b - was this one of the cases you were looking at trying to improve in the decompiler?

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

Posted 12/07/2015 11:14 PM   
[quote="DarkStarSword"] ... Another approach (which is probably not possible yet) would be to render the lake bed from a second perspective whenever it is drawn. The idea would be to use an Orthographic projection from directly above the lake (ideally positioned so that it encompasses every part of the lake that the camera can see) using a custom shader that just renders it's height onto a custom render target, that can then be sampled from the foam shader to find the vertical depth. This would be tricky, but once I finish support for running custom shaders from a ShaderOverride it might just be doable. [/quote] I think I'll go with this one :) and drop that shader for now. No matter what I do there are always artiffacts. I'm perfectionist and sometimes I fall into an endless loop where there is no escape. I'll focus on polishing the rest as I've spent to much time already on this particular subject. Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time? edit: The Idea with exporting the lakes geometry (which is possible with tools) rendering it to texture, bluring the edges and then sampling it from the file poped into my mind as well, but the size of it would be way to big if I wanted to maintain a decent accuracy, like 10k or so.
DarkStarSword said:
...
Another approach (which is probably not possible yet) would be to render the lake bed from a second perspective whenever it is drawn. The idea would be to use an Orthographic projection from directly above the lake (ideally positioned so that it encompasses every part of the lake that the camera can see) using a custom shader that just renders it's height onto a custom render target, that can then be sampled from the foam shader to find the vertical depth. This would be tricky, but once I finish support for running custom shaders from a ShaderOverride it might just be doable.


I think I'll go with this one :) and drop that shader for now. No matter what I do there are always artiffacts. I'm perfectionist and sometimes I fall into an endless loop where there is no escape. I'll focus on polishing the rest as I've spent to much time already on this particular subject.

Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time?


edit:
The Idea with exporting the lakes geometry (which is possible with tools) rendering it to texture, bluring the edges and then sampling it from the file poped into my mind as well, but the size of it would be way to big if I wanted to maintain a decent accuracy, like 10k or so.

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/08/2015 01:37 AM   
[quote="DarkStarSword"] This will need a manual fix to the shaders - are there just one or two like this, or does it seem that most of the shaders use these instructions? I gave helifax a hand fixing up one of these the other day - you might like to go over these posts and see if you can work out how to do the same type of fixup here: [url]https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4739720/#4739720[/url] [url]https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4740050/#4740050[/url] @bo3b - was this one of the cases you were looking at trying to improve in the decompiler? [/quote] Sadly it looks like most shaders are coming out with errors. I was able to dump a shader for the HUD without error, but I tried dumping the associated pixel shader which also dumped with a low beep (although I can't really see any error within the code), and I tried a completely different VS for another object that's not even broken, and that did the same thing. I followed your instruction from the other thread and modified the code, but whenever I try reloading the shader I keep getting the low beep error still. I tried a few variations, but I'll put in the most recent one I tried and if you could advise it would be appreciated. [code] cbuffer _Globals : register(b0) { float SpecularMipFactor : packoffset(c0); bool bUseBlurSkinning : packoffset(c0.y); bool bFogEnabled : packoffset(c0.z); float4 RefiningSampleOffsets[12] : packoffset(c1); float4 EdgeSampleOffsets[2] : packoffset(c13); float4 UniformSampleOffsets[8] : packoffset(c15); float4 InvRandomAngleTextureSize : packoffset(c23); float4 ShadowBufferResolution : packoffset(c24); float4 AOBufferSize : packoffset(c25); uint4 PointListIndices[8] : packoffset(c26); uint4 SpotListIndices[8] : packoffset(c34); uint4 SpotShadowListIndices[8] : packoffset(c42); uint4 BoxListIndices[8] : packoffset(c50); uint4 TubeListIndices[8] : packoffset(c58); uint4 PerPixelListCountA : packoffset(c66); uint4 PerPixelListCountB : packoffset(c67); float3 AmbientColor : packoffset(c68); float4 MaterialMultiplier : packoffset(c69); float DirectLightingScale : packoffset(c70); float4 AODebugFlags : packoffset(c71); float LightIntensityClampValue : packoffset(c72); float SpecularLightIntensityClampValue : packoffset(c72.y); float4 PerObjectFog : packoffset(c73); float ReflectionRoughnessAdjustment : packoffset(c74); float4x4 ScreenToWorld : packoffset(c75); uint4 PerVertexLightIndices[8] : packoffset(c79); uint4 PerVertexLightCounts : packoffset(c87); uint PerVertexLightListOffset : packoffset(c88); float3 EnvironmentMapCenter[4] : packoffset(c89); float3 EnvironmentMapBoxMin[4] : packoffset(c93); float3 EnvironmentMapBoxMax[4] : packoffset(c97); uint4 EnvironmentMapIndex : packoffset(c101); float3 EnvironmentBoxWeights[4] : packoffset(c102); float EnvironmentIBLContributionIntensity : packoffset(c105.w); float DiffuseIndirectMipLevel : packoffset(c106); float2 FloorDistortionOffsetScale : packoffset(c106.y); float3 FloorReflectionFadeParameters : packoffset(c107); float TuneCurvature : packoffset(c107.w) = float(1); float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5); uint SphereCount : packoffset(c108.w); float2 LevelDesatAndFadeControls : packoffset(c109); bool bUseVoxelLighting : packoffset(c109.z); float4x4 WorldToVoxelTransform : packoffset(c110); float3 VoxelSize : packoffset(c114); float2 VoxelLightingControl : packoffset(c115); float3 OcclusionVoxelSize : packoffset(c116); float4x4 WorldToOccVoxelTransform : packoffset(c117); float3 AOScaleAndBias : packoffset(c121); float4 ObjectWorldPositionAndRadius : packoffset(c122); float3 ObjectOrientation : packoffset(c123); float3 ObjectPostProjectionPosition : packoffset(c124); float3 ObjectNDCPosition : packoffset(c125); float4 ObjectMacroUVScales : packoffset(c126); float4 UserWorldSpaceClipPlanes[2] : packoffset(c127); float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129); float4 DecalShaderUVs : packoffset(c130); float4 TessellationFactors : packoffset(c131); float4x4 LocalToWorld : packoffset(c132); float4x4 PreviousLocalToWorld : packoffset(c136); float LocalToWorldRotDeterminantFlip : packoffset(c140); float3x3 WorldToLocal : packoffset(c141); float4 ShadowCoordinateScaleBias : packoffset(c144); uint HasVertexColorData : packoffset(c145); uint NumTexCoordsPerVertex : packoffset(c145.y); float CoreRadius : packoffset(c145.z); float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0); //Define missing structs from bad decompile struct PositionBuffer { struct VSInputPosition { float3 Position; } Element; } struct ColorBuffer { struct VSInputColor { uint Color; } Element; } struct TexCoords { uint Element; } StructuredBuffer<struct PositionBuffer> PositionBuffer : register(t0); StructuredBuffer<struct ColorBuffer> ColorBuffer : register(t2); StructuredBuffer<struct TexCoords> TexCoords : register(t3); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( uint v0 : SV_VertexID0, out float2 o0 : SV_ClipDistance0, out float4 o1 : COLOR0, out float4 o2 : TEXCOORD0, out float4 o3 : TEXCOORD7, out float4 o4 : SV_Position0) { float4 r0,r1,r2; uint4 bitmask, uiDest; float4 fDest; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx r0.x = PositionBuffer[v0.x].Element.x; //Tried with PositionBuffer[r0.x] before as well r0.y = PositionBuffer[v0.x].Element.y; r0.z = PositionBuffer[v0.x].Element.z; r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy; r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw; r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw; r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw; o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw); o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw); r1.xy = (int2)v0.xx * HasVertexColorData; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx r1.x = ColorBuffer[r1.x].Element.x; //The original code used PositionBuffer. Tried that once, didn't work, and since above code references t2 register changed this to ColorBuffer. Same thing with the below TexCoords structs called, they all had PositionBuffer originally in the code // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx r1.y = TexCoords[r1.y].Element.x; //Tried with Element.y before, but since l(0) I interpretted that as starting from x. Tried both and neither worked. r1.z = (int)r1.x & 255; r2.x = (uint)r1.z; if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8; if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16; r1.x = (uint)r1.x >> 24; r2.yzw = (uint3)r1.zwx; o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw; r1.x = (int)r1.y & 0x0000ffff; r1.y = (uint)r1.y >> 16; o2.xy = f16tof32(r1.xy); r1.x = 1 < NumTexCoordsPerVertex; r1.x = r1.x ? 1 : 0; r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x); // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx r1.x = TexCoords[r1.x].Element.x; r1.y = (int)r1.x & 0x0000ffff; r1.x = (uint)r1.x >> 16; o2.zw = f16tof32(r1.xy); r1.xyzw = cb1[1].xyzw * r0.yyyy; r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw; r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw; r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw; o3.xyzw = r0.xyzw; o4.xyzw = r0.xyzw; //o0=0; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 // // using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float SpecularMipFactor; // Offset: 0 Size: 4 [unused] // bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused] // bool bFogEnabled; // Offset: 8 Size: 4 [unused] // float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused] // float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused] // float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused] // float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused] // float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused] // float4 AOBufferSize; // Offset: 400 Size: 16 [unused] // uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused] // uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused] // uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused] // uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused] // uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused] // uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused] // uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused] // float3 AmbientColor; // Offset: 1088 Size: 12 [unused] // float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused] // float DirectLightingScale; // Offset: 1120 Size: 4 [unused] // float4 AODebugFlags; // Offset: 1136 Size: 16 [unused] // float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused] // float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused] // float4 PerObjectFog; // Offset: 1168 Size: 16 [unused] // float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused] // float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused] // uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused] // uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused] // uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused] // float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused] // float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused] // float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused] // uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused] // float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused] // float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused] // float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused] // float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused] // float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused] // float TuneCurvature; // Offset: 1724 Size: 4 [unused] // = 0x3f800000 // float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused] // = 0x3f19999a 0x3f000000 0x3f000000 // uint SphereCount; // Offset: 1740 Size: 4 [unused] // float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused] // bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused] // float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused] // float3 VoxelSize; // Offset: 1824 Size: 12 [unused] // float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused] // float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused] // float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused] // float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused] // float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused] // float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused] // float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused] // float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused] // float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused] // float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32 // float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused] // float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused] // float4 TessellationFactors; // Offset: 2096 Size: 16 [unused] // float4x4 LocalToWorld; // Offset: 2112 Size: 64 // float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused] // float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused] // float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused] // float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused] // uint HasVertexColorData; // Offset: 2320 Size: 4 // uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4 // float CoreRadius; // Offset: 2328 Size: 4 [unused] // float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused] // = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000 // 0xbf5753b5 0x3f056b12 0x00000000 0x00000000 // 0xbf37ab75 0xbf00d307 0x00000000 0x00000000 // 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000 // 0xbf29c758 0x3e1e8922 0x00000000 0x00000000 // 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000 // 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000 // 0xbeb11559 0xbf107b24 0x00000000 0x00000000 // 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000 // 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000 // 0xbe120924 0xbcba417a 0x00000000 0x00000000 // 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000 // 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000 // 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000 // 0x3e29f948 0x3dbeb181 0x00000000 0x00000000 // 0x3e81dcf9 0x3f383372 0x00000000 0x00000000 // 0x3ebd3587 0xbf27af53 0x00000000 0x00000000 // 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000 // 0x3f07df09 0xbebadd7b 0x00000000 0x00000000 // 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000 // 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000 // 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000 // 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000 // 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000 // 0x3f7debfb 0xbf28474e // // } // // cbuffer VSOffsetConstants // { // // float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64 // float4 ViewOrigin; // Offset: 64 Size: 16 [unused] // // struct FFogBand // { // // float4 Color; // Offset: 80 // float4 DistanceDensity; // Offset: 96 // // } FogBandData[8]; // Offset: 80 Size: 256 [unused] // // } // // Resource bind info for PositionBuffer // { // // struct VSInputPosition // { // // float3 Position; // Offset: 0 // // } $Element; // Offset: 0 Size: 12 // // } // // Resource bind info for ColorBuffer // { // // struct VSInputColor // { // // uint Color; // Offset: 0 // // } $Element; // Offset: 0 Size: 4 // // } // // Resource bind info for TexCoords // { // // uint $Element; // Offset: 0 Size: 4 // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // PositionBuffer texture struct r/o 0 1 // ColorBuffer texture struct r/o 2 1 // TexCoords texture struct r/o 3 1 // $Globals cbuffer NA NA 0 1 // VSOffsetConstants cbuffer NA NA 1 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_VertexID 0 x 0 VERTID uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_ClipDistance 0 xy 0 CLIPDST float xy // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xyzw 2 NONE float xyzw // TEXCOORD 7 xyzw 3 NONE float xyzw // SV_Position 0 xyzw 4 POS float xyzw // vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[146], immediateIndexed dcl_constantbuffer cb1[4], immediateIndexed dcl_resource_structured t0, 12 dcl_resource_structured t2, 4 dcl_resource_structured t3, 4 dcl_input_sgv v0.x, vertex_id dcl_output_siv o0.xy, clip_distance dcl_output o1.xyzw dcl_output o2.xyzw dcl_output o3.xyzw dcl_output_siv o4.xyzw, position dcl_temps 3 ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx mul r1.xyzw, r0.yyyy, cb0[133].xyzw mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw add r0.xyzw, r0.xyzw, cb0[135].xyzw dp4 o0.x, cb0[127].xyzw, r0.xyzw dp4 o0.y, cb0[128].xyzw, r0.xyzw imul null, r1.xy, v0.xxxx, cb0[145].xyxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx and r1.z, r1.x, l(255) utof r2.x, r1.z ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx ushr r1.x, r1.x, l(24) utof r2.yzw, r1.zzwx mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886) and r1.x, r1.y, l(0x0000ffff) ushr r1.y, r1.y, l(16) f16tof32 o2.xy, r1.xyxx ult r1.x, l(1), cb0[145].y and r1.x, r1.x, l(1) imad r1.x, v0.x, cb0[145].y, r1.x ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx and r1.y, r1.x, l(0x0000ffff) ushr r1.x, r1.x, l(16) f16tof32 o2.zw, r1.xxxy mul r1.xyzw, r0.yyyy, cb1[1].xyzw mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw mov o3.xyzw, r0.xyzw mov o4.xyzw, r0.xyzw ret // Approximately 33 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ [/code]
DarkStarSword said:
This will need a manual fix to the shaders - are there just one or two like this, or does it seem that most of the shaders use these instructions?

I gave helifax a hand fixing up one of these the other day - you might like to go over these posts and see if you can work out how to do the same type of fixup here:
https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4739720/#4739720
https://forums.geforce.com/default/topic/766890/3d-vision/bo3bs-school-for-shaderhackers/post/4740050/#4740050

@bo3b - was this one of the cases you were looking at trying to improve in the decompiler?


Sadly it looks like most shaders are coming out with errors. I was able to dump a shader for the HUD without error, but I tried dumping the associated pixel shader which also dumped with a low beep (although I can't really see any error within the code), and I tried a completely different VS for another object that's not even broken, and that did the same thing.

I followed your instruction from the other thread and modified the code, but whenever I try reloading the shader I keep getting the low beep error still. I tried a few variations, but I'll put in the most recent one I tried and if you could advise it would be appreciated.

cbuffer _Globals : register(b0)
{
float SpecularMipFactor : packoffset(c0);
bool bUseBlurSkinning : packoffset(c0.y);
bool bFogEnabled : packoffset(c0.z);
float4 RefiningSampleOffsets[12] : packoffset(c1);
float4 EdgeSampleOffsets[2] : packoffset(c13);
float4 UniformSampleOffsets[8] : packoffset(c15);
float4 InvRandomAngleTextureSize : packoffset(c23);
float4 ShadowBufferResolution : packoffset(c24);
float4 AOBufferSize : packoffset(c25);
uint4 PointListIndices[8] : packoffset(c26);
uint4 SpotListIndices[8] : packoffset(c34);
uint4 SpotShadowListIndices[8] : packoffset(c42);
uint4 BoxListIndices[8] : packoffset(c50);
uint4 TubeListIndices[8] : packoffset(c58);
uint4 PerPixelListCountA : packoffset(c66);
uint4 PerPixelListCountB : packoffset(c67);
float3 AmbientColor : packoffset(c68);
float4 MaterialMultiplier : packoffset(c69);
float DirectLightingScale : packoffset(c70);
float4 AODebugFlags : packoffset(c71);
float LightIntensityClampValue : packoffset(c72);
float SpecularLightIntensityClampValue : packoffset(c72.y);
float4 PerObjectFog : packoffset(c73);
float ReflectionRoughnessAdjustment : packoffset(c74);
float4x4 ScreenToWorld : packoffset(c75);
uint4 PerVertexLightIndices[8] : packoffset(c79);
uint4 PerVertexLightCounts : packoffset(c87);
uint PerVertexLightListOffset : packoffset(c88);
float3 EnvironmentMapCenter[4] : packoffset(c89);
float3 EnvironmentMapBoxMin[4] : packoffset(c93);
float3 EnvironmentMapBoxMax[4] : packoffset(c97);
uint4 EnvironmentMapIndex : packoffset(c101);
float3 EnvironmentBoxWeights[4] : packoffset(c102);
float EnvironmentIBLContributionIntensity : packoffset(c105.w);
float DiffuseIndirectMipLevel : packoffset(c106);
float2 FloorDistortionOffsetScale : packoffset(c106.y);
float3 FloorReflectionFadeParameters : packoffset(c107);
float TuneCurvature : packoffset(c107.w) = float(1);
float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5);
uint SphereCount : packoffset(c108.w);
float2 LevelDesatAndFadeControls : packoffset(c109);
bool bUseVoxelLighting : packoffset(c109.z);
float4x4 WorldToVoxelTransform : packoffset(c110);
float3 VoxelSize : packoffset(c114);
float2 VoxelLightingControl : packoffset(c115);
float3 OcclusionVoxelSize : packoffset(c116);
float4x4 WorldToOccVoxelTransform : packoffset(c117);
float3 AOScaleAndBias : packoffset(c121);
float4 ObjectWorldPositionAndRadius : packoffset(c122);
float3 ObjectOrientation : packoffset(c123);
float3 ObjectPostProjectionPosition : packoffset(c124);
float3 ObjectNDCPosition : packoffset(c125);
float4 ObjectMacroUVScales : packoffset(c126);
float4 UserWorldSpaceClipPlanes[2] : packoffset(c127);
float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129);
float4 DecalShaderUVs : packoffset(c130);
float4 TessellationFactors : packoffset(c131);
float4x4 LocalToWorld : packoffset(c132);
float4x4 PreviousLocalToWorld : packoffset(c136);
float LocalToWorldRotDeterminantFlip : packoffset(c140);
float3x3 WorldToLocal : packoffset(c141);
float4 ShadowCoordinateScaleBias : packoffset(c144);
uint HasVertexColorData : packoffset(c145);
uint NumTexCoordsPerVertex : packoffset(c145.y);
float CoreRadius : packoffset(c145.z);
float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0);

//Define missing structs from bad decompile
struct PositionBuffer
{
struct VSInputPosition
{
float3 Position;
} Element;
}

struct ColorBuffer
{
struct VSInputColor
{
uint Color;
} Element;
}

struct TexCoords
{
uint Element;
}

StructuredBuffer<struct PositionBuffer> PositionBuffer : register(t0);
StructuredBuffer<struct ColorBuffer> ColorBuffer : register(t2);
StructuredBuffer<struct TexCoords> TexCoords : register(t3);


Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
uint v0 : SV_VertexID0,
out float2 o0 : SV_ClipDistance0,
out float4 o1 : COLOR0,
out float4 o2 : TEXCOORD0,
out float4 o3 : TEXCOORD7,
out float4 o4 : SV_Position0)
{

float4 r0,r1,r2;
uint4 bitmask, uiDest;
float4 fDest;

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
r0.x = PositionBuffer[v0.x].Element.x; //Tried with PositionBuffer[r0.x] before as well
r0.y = PositionBuffer[v0.x].Element.y;
r0.z = PositionBuffer[v0.x].Element.z;
r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy;
r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw;
o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw);
o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw);
r1.xy = (int2)v0.xx * HasVertexColorData;
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
r1.x = ColorBuffer[r1.x].Element.x; //The original code used PositionBuffer. Tried that once, didn't work, and since above code references t2 register changed this to ColorBuffer. Same thing with the below TexCoords structs called, they all had PositionBuffer originally in the code
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
r1.y = TexCoords[r1.y].Element.x; //Tried with Element.y before, but since l(0) I interpretted that as starting from x. Tried both and neither worked.
r1.z = (int)r1.x & 255;
r2.x = (uint)r1.z;
if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8;
if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16;
r1.x = (uint)r1.x >> 24;
r2.yzw = (uint3)r1.zwx;
o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw;
r1.x = (int)r1.y & 0x0000ffff;
r1.y = (uint)r1.y >> 16;
o2.xy = f16tof32(r1.xy);
r1.x = 1 < NumTexCoordsPerVertex;
r1.x = r1.x ? 1 : 0;
r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x);
// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
r1.x = TexCoords[r1.x].Element.x;
r1.y = (int)r1.x & 0x0000ffff;
r1.x = (uint)r1.x >> 16;
o2.zw = f16tof32(r1.xy);
r1.xyzw = cb1[1].xyzw * r0.yyyy;
r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw;
r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw;
r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw;
o3.xyzw = r0.xyzw;
o4.xyzw = r0.xyzw;

//o0=0;

return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
// using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float SpecularMipFactor; // Offset: 0 Size: 4 [unused]
// bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused]
// bool bFogEnabled; // Offset: 8 Size: 4 [unused]
// float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused]
// float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused]
// float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused]
// float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused]
// float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused]
// float4 AOBufferSize; // Offset: 400 Size: 16 [unused]
// uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused]
// uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused]
// uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused]
// uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused]
// uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused]
// uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused]
// uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused]
// float3 AmbientColor; // Offset: 1088 Size: 12 [unused]
// float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused]
// float DirectLightingScale; // Offset: 1120 Size: 4 [unused]
// float4 AODebugFlags; // Offset: 1136 Size: 16 [unused]
// float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused]
// float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused]
// float4 PerObjectFog; // Offset: 1168 Size: 16 [unused]
// float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused]
// float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused]
// uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused]
// uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused]
// uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused]
// float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused]
// float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused]
// float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused]
// uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused]
// float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused]
// float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused]
// float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused]
// float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused]
// float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused]
// float TuneCurvature; // Offset: 1724 Size: 4 [unused]
// = 0x3f800000
// float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused]
// = 0x3f19999a 0x3f000000 0x3f000000
// uint SphereCount; // Offset: 1740 Size: 4 [unused]
// float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused]
// bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused]
// float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused]
// float3 VoxelSize; // Offset: 1824 Size: 12 [unused]
// float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused]
// float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused]
// float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused]
// float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused]
// float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused]
// float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused]
// float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused]
// float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused]
// float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused]
// float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32
// float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused]
// float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused]
// float4 TessellationFactors; // Offset: 2096 Size: 16 [unused]
// float4x4 LocalToWorld; // Offset: 2112 Size: 64
// float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused]
// float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused]
// float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused]
// float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused]
// uint HasVertexColorData; // Offset: 2320 Size: 4
// uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4
// float CoreRadius; // Offset: 2328 Size: 4 [unused]
// float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused]
// = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000
// 0xbf5753b5 0x3f056b12 0x00000000 0x00000000
// 0xbf37ab75 0xbf00d307 0x00000000 0x00000000
// 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000
// 0xbf29c758 0x3e1e8922 0x00000000 0x00000000
// 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000
// 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000
// 0xbeb11559 0xbf107b24 0x00000000 0x00000000
// 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000
// 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000
// 0xbe120924 0xbcba417a 0x00000000 0x00000000
// 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000
// 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000
// 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000
// 0x3e29f948 0x3dbeb181 0x00000000 0x00000000
// 0x3e81dcf9 0x3f383372 0x00000000 0x00000000
// 0x3ebd3587 0xbf27af53 0x00000000 0x00000000
// 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000
// 0x3f07df09 0xbebadd7b 0x00000000 0x00000000
// 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000
// 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000
// 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000
// 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000
// 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000
// 0x3f7debfb 0xbf28474e
//
// }
//
// cbuffer VSOffsetConstants
// {
//
// float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64
// float4 ViewOrigin; // Offset: 64 Size: 16 [unused]
//
// struct FFogBand
// {
//
// float4 Color; // Offset: 80
// float4 DistanceDensity; // Offset: 96
//
// } FogBandData[8]; // Offset: 80 Size: 256 [unused]
//
// }
//
// Resource bind info for PositionBuffer
// {
//
// struct VSInputPosition
// {
//
// float3 Position; // Offset: 0
//
// } $Element; // Offset: 0 Size: 12
//
// }
//
// Resource bind info for ColorBuffer
// {
//
// struct VSInputColor
// {
//
// uint Color; // Offset: 0
//
// } $Element; // Offset: 0 Size: 4
//
// }
//
// Resource bind info for TexCoords
// {
//
// uint $Element; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PositionBuffer texture struct r/o 0 1
// ColorBuffer texture struct r/o 2 1
// TexCoords texture struct r/o 3 1
// $Globals cbuffer NA NA 0 1
// VSOffsetConstants cbuffer NA NA 1 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID 0 x 0 VERTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_ClipDistance 0 xy 0 CLIPDST float xy
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xyzw 2 NONE float xyzw
// TEXCOORD 7 xyzw 3 NONE float xyzw
// SV_Position 0 xyzw 4 POS float xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[146], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_resource_structured t0, 12
dcl_resource_structured t2, 4
dcl_resource_structured t3, 4
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xy, clip_distance
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output_siv o4.xyzw, position
dcl_temps 3
ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
mul r1.xyzw, r0.yyyy, cb0[133].xyzw
mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb0[135].xyzw
dp4 o0.x, cb0[127].xyzw, r0.xyzw
dp4 o0.y, cb0[128].xyzw, r0.xyzw
imul null, r1.xy, v0.xxxx, cb0[145].xyxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
and r1.z, r1.x, l(255)
utof r2.x, r1.z
ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx
ushr r1.x, r1.x, l(24)
utof r2.yzw, r1.zzwx
mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886)
and r1.x, r1.y, l(0x0000ffff)
ushr r1.y, r1.y, l(16)
f16tof32 o2.xy, r1.xyxx
ult r1.x, l(1), cb0[145].y
and r1.x, r1.x, l(1)
imad r1.x, v0.x, cb0[145].y, r1.x
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
and r1.y, r1.x, l(0x0000ffff)
ushr r1.x, r1.x, l(16)
f16tof32 o2.zw, r1.xxxy
mul r1.xyzw, r0.yyyy, cb1[1].xyzw
mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw
mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw
mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw
mov o3.xyzw, r0.xyzw
mov o4.xyzw, r0.xyzw
ret
// Approximately 33 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

3D Gaming Rig: CPU: i7 7700K @ 4.9Ghz | Mobo: Asus Maximus Hero VIII | RAM: Corsair Dominator 16GB | GPU: 2 x GTX 1080 Ti SLI | 3xSSDs for OS and Apps, 2 x HDD's for 11GB storage | PSU: Seasonic X-1250 M2| Case: Corsair C70 | Cooling: Corsair H115i Hydro cooler | Displays: Asus PG278QR, BenQ XL2420TX & BenQ HT1075 | OS: Windows 10 Pro + Windows 7 dual boot

Like my fixes? Dontations can be made to: www.paypal.me/DShanz or rshannonca@gmail.com
Like electronic music? Check out: www.soundcloud.com/dj-ryan-king

Posted 12/08/2015 05:40 AM   
[quote="Oomek"]Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time?[/quote]I've been mulling the idea around in my head for a while, so it's certainly on the cards, but I haven't decided on the best way to make it work yet. One idea that I was leaning towards, was rather than implement support directly in 3DMigoto, write some custom shaders to visualise the data buffers of interest in various ways and run them at a point of interest in the frame (probably skipping over remaining draw calls, or maybe just run them just before the present call using a buffer copied from earlier). That would potentially give us quite a bit of flexibility without over-complicating 3DMigoto itself, and we could create a library of the most useful visualisations. If you have any suggestions as to what you would like this to look like I'm all ears. I can't promise when (or if) I'll start working on it - custom shaders are on the way since I want them for other reasons as well, but anything specific to this idea is a lower priority for now.
Oomek said:Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time?
I've been mulling the idea around in my head for a while, so it's certainly on the cards, but I haven't decided on the best way to make it work yet.

One idea that I was leaning towards, was rather than implement support directly in 3DMigoto, write some custom shaders to visualise the data buffers of interest in various ways and run them at a point of interest in the frame (probably skipping over remaining draw calls, or maybe just run them just before the present call using a buffer copied from earlier). That would potentially give us quite a bit of flexibility without over-complicating 3DMigoto itself, and we could create a library of the most useful visualisations.

If you have any suggestions as to what you would like this to look like I'm all ears. I can't promise when (or if) I'll start working on it - custom shaders are on the way since I want them for other reasons as well, but anything specific to this idea is a lower priority for now.

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

Posted 12/08/2015 07:14 AM   
[quote="DJ-RK"]Sadly it looks like most shaders are coming out with errors. I was able to dump a shader for the HUD without error, but I tried dumping the associated pixel shader which also dumped with a low beep (although I can't really see any error within the code), and I tried a completely different VS for another object that's not even broken, and that did the same thing.[/quote] Ok, the options are wait until bo3b or myself have improved the decompiler for this game (bo3b is still the expert in this area - I've been focussing on other things), hand-fix them as you come across them, or try to use the assembly versions of the shaders instead. The assembly versions need export_shaders=1 to dump, and they aren't currently automatically copied to ShaderFixes on mark, but it will still print out the hash in the d3d11_log.txt and you can then copy them from the ShaderCache folder. Editing the assembly shaders is similar to Helix Mod, but there's a few extra gotchas to be aware of - things like always remembering to increase dcl_temps when using a new temporary register (easy to forget and can lead to inconsistent crashes), always remembering to declare the StereoParams and IniParams if using them (again easy to forget and will usually work but occasionally crash if you forget), being aware that the assembler might silently drop instructions it didn't recognise or crash if an instruction didn't have enough parameters (the reasm files are there to compare against to check for these issues). Oh, and of course the MSDN documentation on shader model 4/5 assembly exists, but seems to have an aweful lot of errors from what I've seen. [quote]I followed your instruction from the other thread and modified the code, but whenever I try reloading the shader I keep getting the low beep error still. I tried a few variations, but I'll put in the most recent one I tried and if you could advise it would be appreciated.[/quote] I think the structured buffers are ok now, but I had a closer look and realised it also has a second issue: [code] ... float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0); [/code] Which has been cut short - this array was supposed to be initialised with a lot more entries: [code] // float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused] // = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000 // 0xbf5753b5 0x3f056b12 0x00000000 0x00000000 // 0xbf37ab75 0xbf00d307 0x00000000 0x00000000 // 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000 // 0xbf29c758 0x3e1e8922 0x00000000 0x00000000 // 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000 // 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000 // 0xbeb11559 0xbf107b24 0x00000000 0x00000000 // 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000 // 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000 // 0xbe120924 0xbcba417a 0x00000000 0x00000000 // 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000 // 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000 // 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000 // 0x3e29f948 0x3dbeb181 0x00000000 0x00000000 // 0x3e81dcf9 0x3f383372 0x00000000 0x00000000 // 0x3ebd3587 0xbf27af53 0x00000000 0x00000000 // 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000 // 0x3f07df09 0xbebadd7b 0x00000000 0x00000000 // 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000 // 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000 // 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000 // 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000 // 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000 // 0x3f7debfb 0xbf28474e [/code] It also caused the decompiler to abort too soon before it processed this constant buffer: [code] // cbuffer VSOffsetConstants // { // // float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64 // float4 ViewOrigin; // Offset: 64 Size: 16 [unused] // // struct FFogBand // { // // float4 Color; // Offset: 80 // float4 DistanceDensity; // Offset: 96 // // } FogBandData[8]; // Offset: 80 Size: 256 [unused] // // } [/code] It's funny - games could have easily done this at any time, but we haven't seen this particular problem until a few weeks ago - and now I think we've seen it in three separate games all at once :-O I think bo3b mentioned he was looking at this issue - bo3b?
DJ-RK said:Sadly it looks like most shaders are coming out with errors. I was able to dump a shader for the HUD without error, but I tried dumping the associated pixel shader which also dumped with a low beep (although I can't really see any error within the code), and I tried a completely different VS for another object that's not even broken, and that did the same thing.

Ok, the options are wait until bo3b or myself have improved the decompiler for this game (bo3b is still the expert in this area - I've been focussing on other things), hand-fix them as you come across them, or try to use the assembly versions of the shaders instead.

The assembly versions need export_shaders=1 to dump, and they aren't currently automatically copied to ShaderFixes on mark, but it will still print out the hash in the d3d11_log.txt and you can then copy them from the ShaderCache folder. Editing the assembly shaders is similar to Helix Mod, but there's a few extra gotchas to be aware of - things like always remembering to increase dcl_temps when using a new temporary register (easy to forget and can lead to inconsistent crashes), always remembering to declare the StereoParams and IniParams if using them (again easy to forget and will usually work but occasionally crash if you forget), being aware that the assembler might silently drop instructions it didn't recognise or crash if an instruction didn't have enough parameters (the reasm files are there to compare against to check for these issues). Oh, and of course the MSDN documentation on shader model 4/5 assembly exists, but seems to have an aweful lot of errors from what I've seen.

I followed your instruction from the other thread and modified the code, but whenever I try reloading the shader I keep getting the low beep error still. I tried a few variations, but I'll put in the most recent one I tried and if you could advise it would be appreciated.


I think the structured buffers are ok now, but I had a closer look and realised it also has a second issue:

...
float2 Poisson25[25] : packoffset(c146) = float2(-0.978698015,-0.0884120986,0,0);

Which has been cut short - this array was supposed to be initialised with a lot more entries:
//   float2 Poisson25[25];              // Offset: 2336 Size:   392 [unused]
// = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000
// 0xbf5753b5 0x3f056b12 0x00000000 0x00000000
// 0xbf37ab75 0xbf00d307 0x00000000 0x00000000
// 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000
// 0xbf29c758 0x3e1e8922 0x00000000 0x00000000
// 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000
// 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000
// 0xbeb11559 0xbf107b24 0x00000000 0x00000000
// 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000
// 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000
// 0xbe120924 0xbcba417a 0x00000000 0x00000000
// 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000
// 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000
// 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000
// 0x3e29f948 0x3dbeb181 0x00000000 0x00000000
// 0x3e81dcf9 0x3f383372 0x00000000 0x00000000
// 0x3ebd3587 0xbf27af53 0x00000000 0x00000000
// 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000
// 0x3f07df09 0xbebadd7b 0x00000000 0x00000000
// 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000
// 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000
// 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000
// 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000
// 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000
// 0x3f7debfb 0xbf28474e

It also caused the decompiler to abort too soon before it processed this constant buffer:
// cbuffer VSOffsetConstants
// {
//
// float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64
// float4 ViewOrigin; // Offset: 64 Size: 16 [unused]
//
// struct FFogBand
// {
//
// float4 Color; // Offset: 80
// float4 DistanceDensity; // Offset: 96
//
// } FogBandData[8]; // Offset: 80 Size: 256 [unused]
//
// }


It's funny - games could have easily done this at any time, but we haven't seen this particular problem until a few weeks ago - and now I think we've seen it in three separate games all at once :-O

I think bo3b mentioned he was looking at this issue - bo3b?

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

Posted 12/08/2015 07:36 AM   
OK, that shader is fairly busted up so I can't promise this is right, but here is a hand-fix version of that shader that is worth trying. In any case, this will show you the fixing strategy for the ld_unstructured instructions. I'm about 2/3 through getting that to Decompile properly I think, but it's not quite there. The UBFE instruction is changed here, but that might be OK. The fxc compiler is really aggressive, so getting it generate identical code is pretty hard. And, realistically, we only want it to be mathematically the same, the same output. I tried to leave in the original code commented out for stuff I tweaked. Here is a online diff of the end result. Still some differences, but overall pretty good. I'm not worried about the UBFE, the part I look for is making sure the ld_structured_indexable instructions map to the same. [url]https://www.diffchecker.com/sy7itdkd[/url] [code]cbuffer _Globals : register(b0) { float SpecularMipFactor : packoffset(c0); bool bUseBlurSkinning : packoffset(c0.y); bool bFogEnabled : packoffset(c0.z); float4 RefiningSampleOffsets[12] : packoffset(c1); float4 EdgeSampleOffsets[2] : packoffset(c13); float4 UniformSampleOffsets[8] : packoffset(c15); float4 InvRandomAngleTextureSize : packoffset(c23); float4 ShadowBufferResolution : packoffset(c24); float4 AOBufferSize : packoffset(c25); uint4 PointListIndices[8] : packoffset(c26); uint4 SpotListIndices[8] : packoffset(c34); uint4 SpotShadowListIndices[8] : packoffset(c42); uint4 BoxListIndices[8] : packoffset(c50); uint4 TubeListIndices[8] : packoffset(c58); uint4 PerPixelListCountA : packoffset(c66); uint4 PerPixelListCountB : packoffset(c67); float3 AmbientColor : packoffset(c68); float4 MaterialMultiplier : packoffset(c69); float DirectLightingScale : packoffset(c70); float4 AODebugFlags : packoffset(c71); float LightIntensityClampValue : packoffset(c72); float SpecularLightIntensityClampValue : packoffset(c72.y); float4 PerObjectFog : packoffset(c73); float ReflectionRoughnessAdjustment : packoffset(c74); float4x4 ScreenToWorld : packoffset(c75); uint4 PerVertexLightIndices[8] : packoffset(c79); uint4 PerVertexLightCounts : packoffset(c87); uint PerVertexLightListOffset : packoffset(c88); float3 EnvironmentMapCenter[4] : packoffset(c89); float3 EnvironmentMapBoxMin[4] : packoffset(c93); float3 EnvironmentMapBoxMax[4] : packoffset(c97); uint4 EnvironmentMapIndex : packoffset(c101); float3 EnvironmentBoxWeights[4] : packoffset(c102); float EnvironmentIBLContributionIntensity : packoffset(c105.w); float DiffuseIndirectMipLevel : packoffset(c106); float2 FloorDistortionOffsetScale : packoffset(c106.y); float3 FloorReflectionFadeParameters : packoffset(c107); float TuneCurvature : packoffset(c107.w) = float(1); float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5); uint SphereCount : packoffset(c108.w); float2 LevelDesatAndFadeControls : packoffset(c109); bool bUseVoxelLighting : packoffset(c109.z); float4x4 WorldToVoxelTransform : packoffset(c110); float3 VoxelSize : packoffset(c114); float2 VoxelLightingControl : packoffset(c115); float3 OcclusionVoxelSize : packoffset(c116); float4x4 WorldToOccVoxelTransform : packoffset(c117); float3 AOScaleAndBias : packoffset(c121); float4 ObjectWorldPositionAndRadius : packoffset(c122); float3 ObjectOrientation : packoffset(c123); float3 ObjectPostProjectionPosition : packoffset(c124); float3 ObjectNDCPosition : packoffset(c125); float4 ObjectMacroUVScales : packoffset(c126); float4 UserWorldSpaceClipPlanes[2] : packoffset(c127); float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129); float4 DecalShaderUVs : packoffset(c130); float4 TessellationFactors : packoffset(c131); float4x4 LocalToWorld : packoffset(c132); float4x4 PreviousLocalToWorld : packoffset(c136); float LocalToWorldRotDeterminantFlip : packoffset(c140); float3x3 WorldToLocal : packoffset(c141); float4 ShadowCoordinateScaleBias : packoffset(c144); uint HasVertexColorData : packoffset(c145); uint NumTexCoordsPerVertex : packoffset(c145.y); float CoreRadius : packoffset(c145.z); float2 Poisson25[25] : packoffset(c146); // = float2(-0.978698015,-0.0884120986,0,0); // = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000 // 0xbf5753b5 0x3f056b12 0x00000000 0x00000000 // 0xbf37ab75 0xbf00d307 0x00000000 0x00000000 // 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000 // 0xbf29c758 0x3e1e8922 0x00000000 0x00000000 // 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000 // 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000 // 0xbeb11559 0xbf107b24 0x00000000 0x00000000 // 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000 // 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000 // 0xbe120924 0xbcba417a 0x00000000 0x00000000 // 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000 // 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000 // 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000 // 0x3e29f948 0x3dbeb181 0x00000000 0x00000000 // 0x3e81dcf9 0x3f383372 0x00000000 0x00000000 // 0x3ebd3587 0xbf27af53 0x00000000 0x00000000 // 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000 // 0x3f07df09 0xbebadd7b 0x00000000 0x00000000 // 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000 // 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000 // 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000 // 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000 // 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000 // 0x3f7debfb 0xbf28474e } cbuffer VSOffsetConstants : register(b1) { float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64 float4 ViewOrigin; // Offset: 64 Size: 16 [unused] struct FFogBand { float4 Color; // Offset: 80 float4 DistanceDensity; // Offset: 96 } FogBandData[8]; // Offset: 80 Size: 256 [unused] } //Define missing structs from bad decompile // struct PositionBuffer // { struct VSInputPosition { float3 Position; };// Element; // } // struct ColorBuffer // { struct VSInputColor { uint Color; };// Element; // } struct TexCoords { uint Element; }; // StructuredBuffer<struct PositionBuffer> PositionBuffer : register(t0); // StructuredBuffer<struct ColorBuffer> ColorBuffer : register(t2); // StructuredBuffer<struct TexCoords> TexCoords : register(t3); StructuredBuffer<VSInputPosition> PositionBuffer : register(t0); StructuredBuffer<VSInputColor> ColorBuffer : register(t2); StructuredBuffer<TexCoords> TexCoords_ : register(t3); Texture2D<float4> StereoParams : register(t125); Texture1D<float4> IniParams : register(t120); void main( uint v0 : SV_VertexID0, out float2 o0 : SV_ClipDistance0, out float4 o1 : COLOR0, out float4 o2 : TEXCOORD0, out float4 o3 : TEXCOORD7, out float4 o4 : SV_Position0) { uint4 u1; float4 r0,r1,r2; uint4 bitmask, uiDest; float4 fDest; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx r0.x = PositionBuffer[v0.x].Position.x; //Tried with PositionBuffer[r0.x] before as well r0.y = PositionBuffer[v0.x].Position.y; r0.z = PositionBuffer[v0.x].Position.z; r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy; r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw; r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw; r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw; o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw); o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw); // r1.xy = (int2)v0.xx * HasVertexColorData; r1.x = v0 * HasVertexColorData; r1.y = v0 * NumTexCoordsPerVertex; // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx r1.x = ColorBuffer[r1.x].Color.x; //The original code used PositionBuffer. Tried that once, didn't work, and since above code references t2 register changed this to ColorBuffer. Same thing with the below TexCoords structs called, they all had PositionBuffer originally in the code // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx r1.y = TexCoords_[r1.y].Element.x; //Tried with Element.y before, but since l(0) I interpretted that as starting from x. Tried both and neither worked. // and r1.z, r1.x, l(255) // utof r2.x, r1.z // ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx // ushr r1.x, r1.x, l(24) // utof r2.yzw, r1.zzwx r1.z = (int)r1.x & 255; r2.x = (uint)r1.z; if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8; if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16; r1.x = (uint)r1.x >> 24; r2.yzw = (uint3)r1.zwx; o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw; r1.x = (int)r1.y & 0x0000ffff; r1.y = (uint)r1.y >> 16; o2.xy = f16tof32(r1.xy); r1.x = 1 < NumTexCoordsPerVertex; r1.x = r1.x ? 1 : 0; r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x); // Known bad code for instruction (needs manual fix): // ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx r1.x = TexCoords_[r1.x].Element.x; r1.y = (int)r1.x & 0x0000ffff; r1.x = (uint)r1.x >> 16; o2.zw = f16tof32(r1.xy); // r1.xyzw = cb1[1].xyzw * r0.yyyy; // r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw; // r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw; // r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw; r1.xyzw = ViewProjectionMatrix._m01_m11_m21_m31 * r0.yyyy; r1.xyzw = ViewProjectionMatrix._m00_m10_m20_m30 * r0.xxxx + r1.xyzw; r1.xyzw = ViewProjectionMatrix._m02_m12_m22_m32 * r0.zzzz + r1.xyzw; r0.xyzw = ViewProjectionMatrix._m03_m13_m23_m33 * r0.wwww + r1.xyzw; o3.xyzw = r0.xyzw; o4.xyzw = r0.xyzw; //o0=0; return; } /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546 // // using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015 // // // Buffer Definitions: // // cbuffer $Globals // { // // float SpecularMipFactor; // Offset: 0 Size: 4 [unused] // bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused] // bool bFogEnabled; // Offset: 8 Size: 4 [unused] // float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused] // float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused] // float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused] // float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused] // float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused] // float4 AOBufferSize; // Offset: 400 Size: 16 [unused] // uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused] // uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused] // uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused] // uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused] // uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused] // uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused] // uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused] // float3 AmbientColor; // Offset: 1088 Size: 12 [unused] // float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused] // float DirectLightingScale; // Offset: 1120 Size: 4 [unused] // float4 AODebugFlags; // Offset: 1136 Size: 16 [unused] // float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused] // float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused] // float4 PerObjectFog; // Offset: 1168 Size: 16 [unused] // float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused] // float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused] // uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused] // uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused] // uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused] // float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused] // float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused] // float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused] // uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused] // float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused] // float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused] // float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused] // float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused] // float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused] // float TuneCurvature; // Offset: 1724 Size: 4 [unused] // = 0x3f800000 // float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused] // = 0x3f19999a 0x3f000000 0x3f000000 // uint SphereCount; // Offset: 1740 Size: 4 [unused] // float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused] // bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused] // float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused] // float3 VoxelSize; // Offset: 1824 Size: 12 [unused] // float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused] // float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused] // float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused] // float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused] // float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused] // float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused] // float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused] // float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused] // float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused] // float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32 // float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused] // float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused] // float4 TessellationFactors; // Offset: 2096 Size: 16 [unused] // float4x4 LocalToWorld; // Offset: 2112 Size: 64 // float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused] // float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused] // float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused] // float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused] // uint HasVertexColorData; // Offset: 2320 Size: 4 // uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4 // float CoreRadius; // Offset: 2328 Size: 4 [unused] // float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused] // = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000 // 0xbf5753b5 0x3f056b12 0x00000000 0x00000000 // 0xbf37ab75 0xbf00d307 0x00000000 0x00000000 // 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000 // 0xbf29c758 0x3e1e8922 0x00000000 0x00000000 // 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000 // 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000 // 0xbeb11559 0xbf107b24 0x00000000 0x00000000 // 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000 // 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000 // 0xbe120924 0xbcba417a 0x00000000 0x00000000 // 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000 // 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000 // 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000 // 0x3e29f948 0x3dbeb181 0x00000000 0x00000000 // 0x3e81dcf9 0x3f383372 0x00000000 0x00000000 // 0x3ebd3587 0xbf27af53 0x00000000 0x00000000 // 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000 // 0x3f07df09 0xbebadd7b 0x00000000 0x00000000 // 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000 // 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000 // 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000 // 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000 // 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000 // 0x3f7debfb 0xbf28474e // // } // // cbuffer VSOffsetConstants // { // // float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64 // float4 ViewOrigin; // Offset: 64 Size: 16 [unused] // // struct FFogBand // { // // float4 Color; // Offset: 80 // float4 DistanceDensity; // Offset: 96 // // } FogBandData[8]; // Offset: 80 Size: 256 [unused] // // } // // Resource bind info for PositionBuffer // { // // struct VSInputPosition // { // // float3 Position; // Offset: 0 // // } $Element; // Offset: 0 Size: 12 // // } // // Resource bind info for ColorBuffer // { // // struct VSInputColor // { // // uint Color; // Offset: 0 // // } $Element; // Offset: 0 Size: 4 // // } // // Resource bind info for TexCoords // { // // uint $Element; // Offset: 0 Size: 4 // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // PositionBuffer texture struct r/o 0 1 // ColorBuffer texture struct r/o 2 1 // TexCoords texture struct r/o 3 1 // $Globals cbuffer NA NA 0 1 // VSOffsetConstants cbuffer NA NA 1 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_VertexID 0 x 0 VERTID uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_ClipDistance 0 xy 0 CLIPDST float xy // COLOR 0 xyzw 1 NONE float xyzw // TEXCOORD 0 xyzw 2 NONE float xyzw // TEXCOORD 7 xyzw 3 NONE float xyzw // SV_Position 0 xyzw 4 POS float xyzw // vs_5_0 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[146], immediateIndexed dcl_constantbuffer cb1[4], immediateIndexed dcl_resource_structured t0, 12 dcl_resource_structured t2, 4 dcl_resource_structured t3, 4 dcl_input_sgv v0.x, vertex_id dcl_output_siv o0.xy, clip_distance dcl_output o1.xyzw dcl_output o2.xyzw dcl_output o3.xyzw dcl_output_siv o4.xyzw, position dcl_temps 3 ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx mul r1.xyzw, r0.yyyy, cb0[133].xyzw mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw add r0.xyzw, r0.xyzw, cb0[135].xyzw dp4 o0.x, cb0[127].xyzw, r0.xyzw dp4 o0.y, cb0[128].xyzw, r0.xyzw imul null, r1.xy, v0.xxxx, cb0[145].xyxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx and r1.z, r1.x, l(255) utof r2.x, r1.z ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx ushr r1.x, r1.x, l(24) utof r2.yzw, r1.zzwx mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886) and r1.x, r1.y, l(0x0000ffff) ushr r1.y, r1.y, l(16) f16tof32 o2.xy, r1.xyxx ult r1.x, l(1), cb0[145].y and r1.x, r1.x, l(1) imad r1.x, v0.x, cb0[145].y, r1.x ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx and r1.y, r1.x, l(0x0000ffff) ushr r1.x, r1.x, l(16) f16tof32 o2.zw, r1.xxxy mul r1.xyzw, r0.yyyy, cb1[1].xyzw mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw mov o3.xyzw, r0.xyzw mov o4.xyzw, r0.xyzw ret // Approximately 33 instruction slots used ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/[/code] The broken input from the large assignment statements are pretty interesting. We see none (except for 4 element assignments that work), and suddenly we have 3 examples. Luck of the draw probably. Philosophically, this is what I expect. I specifically took the tack of only fixing stuff I knew we needed, rather than trying to make it work to the language spec itself. There are 1000s and 1000s of variants, and only some 100s are actually used. As things get fixed, it gets a little better each time, until hopefully at some point it's pretty solid. I think we are already there for any SM3 stuff, still have holes in SM5 stuff. This is a particularly good example to help me nail that down, because I didn't realize they'd pack it with zeros for a float2 array. You'd expect them to just be assignments, but no, they skip the last two for each line. Lots of weird stuff. I skipped creating the assignment here because Poisson25 is not used in this shader. If you have only a few of these to do, hand-fixing is probably the fastest way at the moment. If you have more than 10, you'll probably want to look at using the ASM version, as I don't think I can nail this down until next week. BTW, if you are looking for just disabled, you can delete all the code in the shader, and set the output to zero and return. Or better, use the ShaderOverride feature with handling=skip in d3dx.ini. [code]void main( uint v0 : SV_VertexID0, out float2 o0 : SV_ClipDistance0, out float4 o1 : COLOR0, out float4 o2 : TEXCOORD0, out float4 o3 : TEXCOORD7, out float4 o4 : SV_Position0) { o0=0; o1=0; o2=0; o3=0; o4=0; return; } [/code]
OK, that shader is fairly busted up so I can't promise this is right, but here is a hand-fix version of that shader that is worth trying.

In any case, this will show you the fixing strategy for the ld_unstructured instructions. I'm about 2/3 through getting that to Decompile properly I think, but it's not quite there. The UBFE instruction is changed here, but that might be OK. The fxc compiler is really aggressive, so getting it generate identical code is pretty hard. And, realistically, we only want it to be mathematically the same, the same output.

I tried to leave in the original code commented out for stuff I tweaked.

Here is a online diff of the end result. Still some differences, but overall pretty good. I'm not worried about the UBFE, the part I look for is making sure the ld_structured_indexable instructions map to the same.

https://www.diffchecker.com/sy7itdkd

cbuffer _Globals : register(b0)
{
float SpecularMipFactor : packoffset(c0);
bool bUseBlurSkinning : packoffset(c0.y);
bool bFogEnabled : packoffset(c0.z);
float4 RefiningSampleOffsets[12] : packoffset(c1);
float4 EdgeSampleOffsets[2] : packoffset(c13);
float4 UniformSampleOffsets[8] : packoffset(c15);
float4 InvRandomAngleTextureSize : packoffset(c23);
float4 ShadowBufferResolution : packoffset(c24);
float4 AOBufferSize : packoffset(c25);
uint4 PointListIndices[8] : packoffset(c26);
uint4 SpotListIndices[8] : packoffset(c34);
uint4 SpotShadowListIndices[8] : packoffset(c42);
uint4 BoxListIndices[8] : packoffset(c50);
uint4 TubeListIndices[8] : packoffset(c58);
uint4 PerPixelListCountA : packoffset(c66);
uint4 PerPixelListCountB : packoffset(c67);
float3 AmbientColor : packoffset(c68);
float4 MaterialMultiplier : packoffset(c69);
float DirectLightingScale : packoffset(c70);
float4 AODebugFlags : packoffset(c71);
float LightIntensityClampValue : packoffset(c72);
float SpecularLightIntensityClampValue : packoffset(c72.y);
float4 PerObjectFog : packoffset(c73);
float ReflectionRoughnessAdjustment : packoffset(c74);
float4x4 ScreenToWorld : packoffset(c75);
uint4 PerVertexLightIndices[8] : packoffset(c79);
uint4 PerVertexLightCounts : packoffset(c87);
uint PerVertexLightListOffset : packoffset(c88);
float3 EnvironmentMapCenter[4] : packoffset(c89);
float3 EnvironmentMapBoxMin[4] : packoffset(c93);
float3 EnvironmentMapBoxMax[4] : packoffset(c97);
uint4 EnvironmentMapIndex : packoffset(c101);
float3 EnvironmentBoxWeights[4] : packoffset(c102);
float EnvironmentIBLContributionIntensity : packoffset(c105.w);
float DiffuseIndirectMipLevel : packoffset(c106);
float2 FloorDistortionOffsetScale : packoffset(c106.y);
float3 FloorReflectionFadeParameters : packoffset(c107);
float TuneCurvature : packoffset(c107.w) = float(1);
float3 NormalBlurFactor : packoffset(c108) = float3(0.600000024,0.5,0.5);
uint SphereCount : packoffset(c108.w);
float2 LevelDesatAndFadeControls : packoffset(c109);
bool bUseVoxelLighting : packoffset(c109.z);
float4x4 WorldToVoxelTransform : packoffset(c110);
float3 VoxelSize : packoffset(c114);
float2 VoxelLightingControl : packoffset(c115);
float3 OcclusionVoxelSize : packoffset(c116);
float4x4 WorldToOccVoxelTransform : packoffset(c117);
float3 AOScaleAndBias : packoffset(c121);
float4 ObjectWorldPositionAndRadius : packoffset(c122);
float3 ObjectOrientation : packoffset(c123);
float3 ObjectPostProjectionPosition : packoffset(c124);
float3 ObjectNDCPosition : packoffset(c125);
float4 ObjectMacroUVScales : packoffset(c126);
float4 UserWorldSpaceClipPlanes[2] : packoffset(c127);
float2 DecalWorldSpaceLowerLeftExtent : packoffset(c129);
float4 DecalShaderUVs : packoffset(c130);
float4 TessellationFactors : packoffset(c131);
float4x4 LocalToWorld : packoffset(c132);
float4x4 PreviousLocalToWorld : packoffset(c136);
float LocalToWorldRotDeterminantFlip : packoffset(c140);
float3x3 WorldToLocal : packoffset(c141);
float4 ShadowCoordinateScaleBias : packoffset(c144);
uint HasVertexColorData : packoffset(c145);
uint NumTexCoordsPerVertex : packoffset(c145.y);
float CoreRadius : packoffset(c145.z);
float2 Poisson25[25] : packoffset(c146);
// = float2(-0.978698015,-0.0884120986,0,0);
// = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000
// 0xbf5753b5 0x3f056b12 0x00000000 0x00000000
// 0xbf37ab75 0xbf00d307 0x00000000 0x00000000
// 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000
// 0xbf29c758 0x3e1e8922 0x00000000 0x00000000
// 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000
// 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000
// 0xbeb11559 0xbf107b24 0x00000000 0x00000000
// 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000
// 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000
// 0xbe120924 0xbcba417a 0x00000000 0x00000000
// 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000
// 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000
// 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000
// 0x3e29f948 0x3dbeb181 0x00000000 0x00000000
// 0x3e81dcf9 0x3f383372 0x00000000 0x00000000
// 0x3ebd3587 0xbf27af53 0x00000000 0x00000000
// 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000
// 0x3f07df09 0xbebadd7b 0x00000000 0x00000000
// 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000
// 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000
// 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000
// 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000
// 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000
// 0x3f7debfb 0xbf28474e
}

cbuffer VSOffsetConstants : register(b1)
{

float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64
float4 ViewOrigin; // Offset: 64 Size: 16 [unused]

struct FFogBand
{

float4 Color; // Offset: 80
float4 DistanceDensity; // Offset: 96

} FogBandData[8]; // Offset: 80 Size: 256 [unused]

}

//Define missing structs from bad decompile
// struct PositionBuffer
// {
struct VSInputPosition
{
float3 Position;
};// Element;
// }

// struct ColorBuffer
// {
struct VSInputColor
{
uint Color;
};// Element;
// }

struct TexCoords
{
uint Element;
};

// StructuredBuffer<struct PositionBuffer> PositionBuffer : register(t0);
// StructuredBuffer<struct ColorBuffer> ColorBuffer : register(t2);
// StructuredBuffer<struct TexCoords> TexCoords : register(t3);
StructuredBuffer<VSInputPosition> PositionBuffer : register(t0);
StructuredBuffer<VSInputColor> ColorBuffer : register(t2);
StructuredBuffer<TexCoords> TexCoords_ : register(t3);


Texture2D<float4> StereoParams : register(t125);
Texture1D<float4> IniParams : register(t120);

void main(
uint v0 : SV_VertexID0,
out float2 o0 : SV_ClipDistance0,
out float4 o1 : COLOR0,
out float4 o2 : TEXCOORD0,
out float4 o3 : TEXCOORD7,
out float4 o4 : SV_Position0)
{
uint4 u1;
float4 r0,r1,r2;
uint4 bitmask, uiDest;
float4 fDest;

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
r0.x = PositionBuffer[v0.x].Position.x; //Tried with PositionBuffer[r0.x] before as well
r0.y = PositionBuffer[v0.x].Position.y;
r0.z = PositionBuffer[v0.x].Position.z;

r1.xyzw = LocalToWorld._m01_m11_m21_m31 * r0.yyyy;
r1.xyzw = LocalToWorld._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
r0.xyzw = LocalToWorld._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
r0.xyzw = LocalToWorld._m03_m13_m23_m33 + r0.xyzw;
o0.x = dot(UserWorldSpaceClipPlanes[0].xyzw, r0.xyzw);
o0.y = dot(UserWorldSpaceClipPlanes[1].xyzw, r0.xyzw);
// r1.xy = (int2)v0.xx * HasVertexColorData;
r1.x = v0 * HasVertexColorData;
r1.y = v0 * NumTexCoordsPerVertex;

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
r1.x = ColorBuffer[r1.x].Color.x; //The original code used PositionBuffer. Tried that once, didn't work, and since above code references t2 register changed this to ColorBuffer. Same thing with the below TexCoords structs called, they all had PositionBuffer originally in the code

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
r1.y = TexCoords_[r1.y].Element.x; //Tried with Element.y before, but since l(0) I interpretted that as starting from x. Tried both and neither worked.

// and r1.z, r1.x, l(255)
// utof r2.x, r1.z
// ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx
// ushr r1.x, r1.x, l(24)
// utof r2.yzw, r1.zzwx

r1.z = (int)r1.x & 255;
r2.x = (uint)r1.z;
if (8 == 0) r1.z = 0; else if (8+8 < 32) { r1.z = (int)r1.x << (32-(8 + 8)); r1.z = (uint)r1.z >> (32-8); } else r1.z = (uint)r1.x >> 8;
if (8 == 0) r1.w = 0; else if (8+16 < 32) { r1.w = (int)r1.x << (32-(8 + 16)); r1.w = (uint)r1.w >> (32-8); } else r1.w = (uint)r1.x >> 16;
r1.x = (uint)r1.x >> 24;
r2.yzw = (uint3)r1.zwx;

o1.xyzw = float4(0.00392156886,0.00392156886,0.00392156886,0.00392156886) * r2.xyzw;
r1.x = (int)r1.y & 0x0000ffff;
r1.y = (uint)r1.y >> 16;
o2.xy = f16tof32(r1.xy);
r1.x = 1 < NumTexCoordsPerVertex;
r1.x = r1.x ? 1 : 0;
r1.x = mad((int)v0.x, NumTexCoordsPerVertex, (int)r1.x);

// Known bad code for instruction (needs manual fix):
// ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
r1.x = TexCoords_[r1.x].Element.x;

r1.y = (int)r1.x & 0x0000ffff;
r1.x = (uint)r1.x >> 16;
o2.zw = f16tof32(r1.xy);

// r1.xyzw = cb1[1].xyzw * r0.yyyy;
// r1.xyzw = cb1[0].xyzw * r0.xxxx + r1.xyzw;
// r1.xyzw = cb1[2].xyzw * r0.zzzz + r1.xyzw;
// r0.xyzw = cb1[3].xyzw * r0.wwww + r1.xyzw;

r1.xyzw = ViewProjectionMatrix._m01_m11_m21_m31 * r0.yyyy;
r1.xyzw = ViewProjectionMatrix._m00_m10_m20_m30 * r0.xxxx + r1.xyzw;
r1.xyzw = ViewProjectionMatrix._m02_m12_m22_m32 * r0.zzzz + r1.xyzw;
r0.xyzw = ViewProjectionMatrix._m03_m13_m23_m33 * r0.wwww + r1.xyzw;

o3.xyzw = r0.xyzw;
o4.xyzw = r0.xyzw;

//o0=0;

return;
}

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20546
//
// using 3Dmigoto v1.2.9 on Mon Dec 07 04:02:19 2015
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float SpecularMipFactor; // Offset: 0 Size: 4 [unused]
// bool bUseBlurSkinning; // Offset: 4 Size: 4 [unused]
// bool bFogEnabled; // Offset: 8 Size: 4 [unused]
// float4 RefiningSampleOffsets[12]; // Offset: 16 Size: 192 [unused]
// float4 EdgeSampleOffsets[2]; // Offset: 208 Size: 32 [unused]
// float4 UniformSampleOffsets[8]; // Offset: 240 Size: 128 [unused]
// float4 InvRandomAngleTextureSize; // Offset: 368 Size: 16 [unused]
// float4 ShadowBufferResolution; // Offset: 384 Size: 16 [unused]
// float4 AOBufferSize; // Offset: 400 Size: 16 [unused]
// uint4 PointListIndices[8]; // Offset: 416 Size: 128 [unused]
// uint4 SpotListIndices[8]; // Offset: 544 Size: 128 [unused]
// uint4 SpotShadowListIndices[8]; // Offset: 672 Size: 128 [unused]
// uint4 BoxListIndices[8]; // Offset: 800 Size: 128 [unused]
// uint4 TubeListIndices[8]; // Offset: 928 Size: 128 [unused]
// uint4 PerPixelListCountA; // Offset: 1056 Size: 16 [unused]
// uint4 PerPixelListCountB; // Offset: 1072 Size: 16 [unused]
// float3 AmbientColor; // Offset: 1088 Size: 12 [unused]
// float4 MaterialMultiplier; // Offset: 1104 Size: 16 [unused]
// float DirectLightingScale; // Offset: 1120 Size: 4 [unused]
// float4 AODebugFlags; // Offset: 1136 Size: 16 [unused]
// float LightIntensityClampValue; // Offset: 1152 Size: 4 [unused]
// float SpecularLightIntensityClampValue;// Offset: 1156 Size: 4 [unused]
// float4 PerObjectFog; // Offset: 1168 Size: 16 [unused]
// float ReflectionRoughnessAdjustment;// Offset: 1184 Size: 4 [unused]
// float4x4 ScreenToWorld; // Offset: 1200 Size: 64 [unused]
// uint4 PerVertexLightIndices[8]; // Offset: 1264 Size: 128 [unused]
// uint4 PerVertexLightCounts; // Offset: 1392 Size: 16 [unused]
// uint PerVertexLightListOffset; // Offset: 1408 Size: 4 [unused]
// float3 EnvironmentMapCenter[4]; // Offset: 1424 Size: 60 [unused]
// float3 EnvironmentMapBoxMin[4]; // Offset: 1488 Size: 60 [unused]
// float3 EnvironmentMapBoxMax[4]; // Offset: 1552 Size: 60 [unused]
// uint4 EnvironmentMapIndex; // Offset: 1616 Size: 16 [unused]
// float3 EnvironmentBoxWeights[4]; // Offset: 1632 Size: 60 [unused]
// float EnvironmentIBLContributionIntensity;// Offset: 1692 Size: 4 [unused]
// float DiffuseIndirectMipLevel; // Offset: 1696 Size: 4 [unused]
// float2 FloorDistortionOffsetScale; // Offset: 1700 Size: 8 [unused]
// float3 FloorReflectionFadeParameters;// Offset: 1712 Size: 12 [unused]
// float TuneCurvature; // Offset: 1724 Size: 4 [unused]
// = 0x3f800000
// float3 NormalBlurFactor; // Offset: 1728 Size: 12 [unused]
// = 0x3f19999a 0x3f000000 0x3f000000
// uint SphereCount; // Offset: 1740 Size: 4 [unused]
// float2 LevelDesatAndFadeControls; // Offset: 1744 Size: 8 [unused]
// bool bUseVoxelLighting; // Offset: 1752 Size: 4 [unused]
// float4x4 WorldToVoxelTransform; // Offset: 1760 Size: 64 [unused]
// float3 VoxelSize; // Offset: 1824 Size: 12 [unused]
// float2 VoxelLightingControl; // Offset: 1840 Size: 8 [unused]
// float3 OcclusionVoxelSize; // Offset: 1856 Size: 12 [unused]
// float4x4 WorldToOccVoxelTransform; // Offset: 1872 Size: 64 [unused]
// float3 AOScaleAndBias; // Offset: 1936 Size: 12 [unused]
// float4 ObjectWorldPositionAndRadius;// Offset: 1952 Size: 16 [unused]
// float3 ObjectOrientation; // Offset: 1968 Size: 12 [unused]
// float3 ObjectPostProjectionPosition;// Offset: 1984 Size: 12 [unused]
// float3 ObjectNDCPosition; // Offset: 2000 Size: 12 [unused]
// float4 ObjectMacroUVScales; // Offset: 2016 Size: 16 [unused]
// float4 UserWorldSpaceClipPlanes[2];// Offset: 2032 Size: 32
// float2 DecalWorldSpaceLowerLeftExtent;// Offset: 2064 Size: 8 [unused]
// float4 DecalShaderUVs; // Offset: 2080 Size: 16 [unused]
// float4 TessellationFactors; // Offset: 2096 Size: 16 [unused]
// float4x4 LocalToWorld; // Offset: 2112 Size: 64
// float4x4 PreviousLocalToWorld; // Offset: 2176 Size: 64 [unused]
// float LocalToWorldRotDeterminantFlip;// Offset: 2240 Size: 4 [unused]
// float3x3 WorldToLocal; // Offset: 2256 Size: 44 [unused]
// float4 ShadowCoordinateScaleBias; // Offset: 2304 Size: 16 [unused]
// uint HasVertexColorData; // Offset: 2320 Size: 4
// uint NumTexCoordsPerVertex; // Offset: 2324 Size: 4
// float CoreRadius; // Offset: 2328 Size: 4 [unused]
// float2 Poisson25[25]; // Offset: 2336 Size: 392 [unused]
// = 0xbf7a8bf4 0xbdb51167 0x00000000 0x00000000
// 0xbf5753b5 0x3f056b12 0x00000000 0x00000000
// 0xbf37ab75 0xbf00d307 0x00000000 0x00000000
// 0xbf33f36b 0x3f6733ca 0x00000000 0x00000000
// 0xbf29c758 0x3e1e8922 0x00000000 0x00000000
// 0xbefd7e02 0xbe6e79ee 0x00000000 0x00000000
// 0xbeba7d67 0xbf7637ef 0x00000000 0x00000000
// 0xbeb11559 0xbf107b24 0x00000000 0x00000000
// 0xbea6bd4d 0x3f23ef4a 0x00000000 0x00000000
// 0xbe3b1961 0x3ea4853c 0x00000000 0x00000000
// 0xbe120924 0xbcba417a 0x00000000 0x00000000
// 0xbd6721c8 0xbebc0d6f 0x00000000 0x00000000
// 0xbc98413f 0x3f6b3bda 0x00000000 0x00000000
// 0x3d1c6145 0xbf3a9f7b 0x00000000 0x00000000
// 0x3e29f948 0x3dbeb181 0x00000000 0x00000000
// 0x3e81dcf9 0x3f383372 0x00000000 0x00000000
// 0x3ebd3587 0xbf27af53 0x00000000 0x00000000
// 0x3ed8e5a3 0x3edc25af 0x00000000 0x00000000
// 0x3f07df09 0xbebadd7b 0x00000000 0x00000000
// 0x3f10e725 0xbf70c3e3 0x00000000 0x00000000
// 0x3f23ab43 0x3ce8c1c0 0x00000000 0x00000000
// 0x3f26ef4e 0x3f2b6f5d 0x00000000 0x00000000
// 0x3f46178f 0x3eb0a56a 0x00000000 0x00000000
// 0x3f7807ee 0x3f5727aa 0x00000000 0x00000000
// 0x3f7debfb 0xbf28474e
//
// }
//
// cbuffer VSOffsetConstants
// {
//
// float4x4 ViewProjectionMatrix; // Offset: 0 Size: 64
// float4 ViewOrigin; // Offset: 64 Size: 16 [unused]
//
// struct FFogBand
// {
//
// float4 Color; // Offset: 80
// float4 DistanceDensity; // Offset: 96
//
// } FogBandData[8]; // Offset: 80 Size: 256 [unused]
//
// }
//
// Resource bind info for PositionBuffer
// {
//
// struct VSInputPosition
// {
//
// float3 Position; // Offset: 0
//
// } $Element; // Offset: 0 Size: 12
//
// }
//
// Resource bind info for ColorBuffer
// {
//
// struct VSInputColor
// {
//
// uint Color; // Offset: 0
//
// } $Element; // Offset: 0 Size: 4
//
// }
//
// Resource bind info for TexCoords
// {
//
// uint $Element; // Offset: 0 Size: 4
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// PositionBuffer texture struct r/o 0 1
// ColorBuffer texture struct r/o 2 1
// TexCoords texture struct r/o 3 1
// $Globals cbuffer NA NA 0 1
// VSOffsetConstants cbuffer NA NA 1 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VertexID 0 x 0 VERTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_ClipDistance 0 xy 0 CLIPDST float xy
// COLOR 0 xyzw 1 NONE float xyzw
// TEXCOORD 0 xyzw 2 NONE float xyzw
// TEXCOORD 7 xyzw 3 NONE float xyzw
// SV_Position 0 xyzw 4 POS float xyzw
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[146], immediateIndexed
dcl_constantbuffer cb1[4], immediateIndexed
dcl_resource_structured t0, 12
dcl_resource_structured t2, 4
dcl_resource_structured t3, 4
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xy, clip_distance
dcl_output o1.xyzw
dcl_output o2.xyzw
dcl_output o3.xyzw
dcl_output_siv o4.xyzw, position
dcl_temps 3
ld_structured_indexable(structured_buffer, stride=12)(mixed,mixed,mixed,mixed) r0.xyz, v0.x, l(0), t0.xyzx
mul r1.xyzw, r0.yyyy, cb0[133].xyzw
mad r1.xyzw, cb0[132].xyzw, r0.xxxx, r1.xyzw
mad r0.xyzw, cb0[134].xyzw, r0.zzzz, r1.xyzw
add r0.xyzw, r0.xyzw, cb0[135].xyzw
dp4 o0.x, cb0[127].xyzw, r0.xyzw
dp4 o0.y, cb0[128].xyzw, r0.xyzw
imul null, r1.xy, v0.xxxx, cb0[145].xyxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t2.xxxx
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.y, r1.y, l(0), t3.xxxx
and r1.z, r1.x, l(255)
utof r2.x, r1.z
ubfe r1.zw, l(0, 0, 8, 8), l(0, 0, 8, 16), r1.xxxx
ushr r1.x, r1.x, l(24)
utof r2.yzw, r1.zzwx
mul o1.xyzw, r2.xyzw, l(0.00392156886, 0.00392156886, 0.00392156886, 0.00392156886)
and r1.x, r1.y, l(0x0000ffff)
ushr r1.y, r1.y, l(16)
f16tof32 o2.xy, r1.xyxx
ult r1.x, l(1), cb0[145].y
and r1.x, r1.x, l(1)
imad r1.x, v0.x, cb0[145].y, r1.x
ld_structured_indexable(structured_buffer, stride=4)(mixed,mixed,mixed,mixed) r1.x, r1.x, l(0), t3.xxxx
and r1.y, r1.x, l(0x0000ffff)
ushr r1.x, r1.x, l(16)
f16tof32 o2.zw, r1.xxxy
mul r1.xyzw, r0.yyyy, cb1[1].xyzw
mad r1.xyzw, cb1[0].xyzw, r0.xxxx, r1.xyzw
mad r1.xyzw, cb1[2].xyzw, r0.zzzz, r1.xyzw
mad r0.xyzw, cb1[3].xyzw, r0.wwww, r1.xyzw
mov o3.xyzw, r0.xyzw
mov o4.xyzw, r0.xyzw
ret
// Approximately 33 instruction slots used

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/



The broken input from the large assignment statements are pretty interesting. We see none (except for 4 element assignments that work), and suddenly we have 3 examples. Luck of the draw probably. Philosophically, this is what I expect. I specifically took the tack of only fixing stuff I knew we needed, rather than trying to make it work to the language spec itself. There are 1000s and 1000s of variants, and only some 100s are actually used. As things get fixed, it gets a little better each time, until hopefully at some point it's pretty solid. I think we are already there for any SM3 stuff, still have holes in SM5 stuff.


This is a particularly good example to help me nail that down, because I didn't realize they'd pack it with zeros for a float2 array. You'd expect them to just be assignments, but no, they skip the last two for each line. Lots of weird stuff.

I skipped creating the assignment here because Poisson25 is not used in this shader.


If you have only a few of these to do, hand-fixing is probably the fastest way at the moment. If you have more than 10, you'll probably want to look at using the ASM version, as I don't think I can nail this down until next week.

BTW, if you are looking for just disabled, you can delete all the code in the shader, and set the output to zero and return. Or better, use the ShaderOverride feature with handling=skip in d3dx.ini.

void main( 
uint v0 : SV_VertexID0,
out float2 o0 : SV_ClipDistance0,
out float4 o1 : COLOR0,
out float4 o2 : TEXCOORD0,
out float4 o3 : TEXCOORD7,
out float4 o4 : SV_Position0)
{

o0=0;
o1=0;
o2=0;
o3=0;
o4=0;

return;
}

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

Posted 12/08/2015 09:58 AM   
[quote="DarkStarSword"]Yep, I think you are looking at the right general area - booleans and integers are problem areas for the decompiler due to fundamental differences between typeless GPU registers and fully typed HLSL variables. I think you actually need to change it from this: [code] r1.w = 0 < r1.y; r1.y = r1.y < 0; r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0); [/code] To this: [code] r1.w = (0 < r1.y ? -1 : 0); r1.y = (r1.y < 0 ? -1 : 0); r1.y = (int)r1.w - (int)r1.y; [/code] The problem here is that in HLSL the result of a boolean test is 0 or 1, but in shader assembly it's 0 or 0xffffffff (-1 as a signed integer). 3DMigoto is taking a different approach and trying to keep track of which components of which variables are booleans (which is why the iadd looked funny), but I don't think it gets it right in every situation. [/quote] I put up a fix for this problem yesterday, that should solve this in a general way. Not posted yet, it will come along on the next release, unless someone needs this ASAP. DarkStarSword, when you get a chance, please review that [url=https://github.com/bo3b/3Dmigoto/commit/f1c911bd4019c4fa9382511c8e1595c7753ec7c4]change[/url] to see if you agree with the strategy, or can think of obvious holes? I tested it against your famous FC4 shader and it fixed that problem.
DarkStarSword said:Yep, I think you are looking at the right general area - booleans and integers are problem areas for the decompiler due to fundamental differences between typeless GPU registers and fully typed HLSL variables.

I think you actually need to change it from this:

r1.w = 0 < r1.y;
r1.y = r1.y < 0;
r1.y = ((int)r1.y ? -1 : 0) + ((int)r1.w ? 1 : 0);


To this:

r1.w = (0 < r1.y ? -1 : 0);
r1.y = (r1.y < 0 ? -1 : 0);
r1.y = (int)r1.w - (int)r1.y;


The problem here is that in HLSL the result of a boolean test is 0 or 1, but in shader assembly it's 0 or 0xffffffff (-1 as a signed integer). 3DMigoto is taking a different approach and trying to keep track of which components of which variables are booleans (which is why the iadd looked funny), but I don't think it gets it right in every situation.

I put up a fix for this problem yesterday, that should solve this in a general way. Not posted yet, it will come along on the next release, unless someone needs this ASAP.

DarkStarSword, when you get a chance, please review that change to see if you agree with the strategy, or can think of obvious holes? I tested it against your famous FC4 shader and it fixed that problem.

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

Posted 12/08/2015 10:41 AM   
[quote="DarkStarSword"][quote="Oomek"]Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time?[/quote]I've been mulling the idea around in my head for a while, so it's certainly on the cards, but I haven't decided on the best way to make it work yet. One idea that I was leaning towards, was rather than implement support directly in 3DMigoto, write some custom shaders to visualise the data buffers of interest in various ways and run them at a point of interest in the frame (probably skipping over remaining draw calls, or maybe just run them just before the present call using a buffer copied from earlier). That would potentially give us quite a bit of flexibility without over-complicating 3DMigoto itself, and we could create a library of the most useful visualisations. If you have any suggestions as to what you would like this to look like I'm all ears. I can't promise when (or if) I'll start working on it - custom shaders are on the way since I want them for other reasons as well, but anything specific to this idea is a lower priority for now. [/quote] Yeah, I'm also after creating a custom shader(s) to do the whole visualization. It would give the ability to extend the functoinality virtually by anyone. The only thing that I'm still thinking about is how to deal wih the variables with per pixel data. 3DM could just spit out the min and max values fo example.
DarkStarSword said:
Oomek said:Btw, Do you have in plans maybe (in some undefined future) to extend the OSD in the way that it would allow to peek on the variables in real time?
I've been mulling the idea around in my head for a while, so it's certainly on the cards, but I haven't decided on the best way to make it work yet.

One idea that I was leaning towards, was rather than implement support directly in 3DMigoto, write some custom shaders to visualise the data buffers of interest in various ways and run them at a point of interest in the frame (probably skipping over remaining draw calls, or maybe just run them just before the present call using a buffer copied from earlier). That would potentially give us quite a bit of flexibility without over-complicating 3DMigoto itself, and we could create a library of the most useful visualisations.

If you have any suggestions as to what you would like this to look like I'm all ears. I can't promise when (or if) I'll start working on it - custom shaders are on the way since I want them for other reasons as well, but anything specific to this idea is a lower priority for now.


Yeah, I'm also after creating a custom shader(s) to do the whole visualization. It would give the ability to extend the functoinality virtually by anyone. The only thing that I'm still thinking about is how to deal wih the variables with per pixel data. 3DM could just spit out the min and max values fo example.

EVGA GeForce GTX 980 SC
Core i5 2500K
MSI Z77A-G45
8GB DDR3
Windows 10 x64

Posted 12/08/2015 04:44 PM   
  40 / 141    
Scroll To Top