Bioshock 3D Vision DX11
  8 / 12    
[quote="djb"]ok, might as well show you why... My current build... http://www.overclock.net/t/1132180/official-xspc-raystorm-club/580#post_19418818[/quote]Awesome build! I love that you keep the wife warm while you keep the computer cool.
djb said:ok, might as well show you why...

My current build...

http://www.overclock.net/t/1132180/official-xspc-raystorm-club/580#post_19418818
Awesome build! I love that you keep the wife warm while you keep the computer cool.

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 06/29/2013 04:58 AM   
[quote="helifax"]PS: Chiri if I can be of any help let me know! I am quite familiar with OpenGL and GLSL. I have also ported numerous shaders from HLSL to GLSL so I could also do it the other way around. Currently I am not familiar that much with Direct3D but I imagine there are alot of similarities between OpenGL 4.x and Direct3D 11. If I can be of any help let me know![/quote] Actually yes. I just wanted to make some screenshots of Assassins Creed 3 with minimal shader fixes, but this game uses strange out of order offset values for shader const parameters: [code] // Buffer Definitions: cbuffer $Globals { float2 g_TexelSize; // Offset: 2256 Size: 8 float3 g_Forces; // Offset: 16 Size: 12 float g_SplashStrength; // Offset: 32 Size: 4 float4 g_PrevOffset; // Offset: 48 Size: 16 }[/code] I have no clue at the moment on how to declare an offset in HLSL. If somebody knows this, it would help fixing AC3 a lot. And a big thank you to all donators. We keep a list of all generous souls.[/quote][/quote] I might be wrong..but by the looks of it I think the data is packed there. I haven't used it extensively in GLSL and the syntax might be different in HLSL but I have a feeling you are referring to this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb509581(v=vs.85).aspx I might be wrong... or I don't quite understand the problem. Can you elaborate a little? The general definition of an offset is a "base_address"+offset = "current_address" but I don't know if this applies directly in HLSL...
helifax said:PS: Chiri if I can be of any help let me know! I am quite familiar with OpenGL and GLSL. I have also ported numerous shaders from HLSL to GLSL so I could also do it the other way around. Currently I am not familiar that much with Direct3D but I imagine there are alot of similarities between OpenGL 4.x and Direct3D 11. If I can be of any help let me know!

Actually yes. I just wanted to make some screenshots of Assassins Creed 3 with minimal shader fixes, but this game uses strange out of order offset values for shader const parameters:
// Buffer Definitions: 

cbuffer $Globals
{

float2 g_TexelSize; // Offset: 2256 Size: 8
float3 g_Forces; // Offset: 16 Size: 12
float g_SplashStrength; // Offset: 32 Size: 4
float4 g_PrevOffset; // Offset: 48 Size: 16

}

I have no clue at the moment on how to declare an offset in HLSL. If somebody knows this, it would help fixing AC3 a lot.

And a big thank you to all donators. We keep a list of all generous souls.


I might be wrong..but by the looks of it I think the data is packed there. I haven't used it extensively in GLSL and the syntax might be different in HLSL but I have a feeling you are referring to this:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb509581(v=vs.85).aspx

I might be wrong... or I don't quite understand the problem. Can you elaborate a little?

The general definition of an offset is a "base_address"+offset = "current_address" but I don't know if this applies directly in HLSL...

1x Palit RTX 2080Ti Pro Gaming OC(watercooled and overclocked to hell)
3x 3D Vision Ready Asus VG278HE monitors (5760x1080).
Intel i9 9900K (overclocked to 5.3 and watercooled ofc).
Asus Maximus XI Hero Mobo.
16 GB Team Group T-Force Dark Pro DDR4 @ 3600.
Lots of Disks:
- Raid 0 - 256GB Sandisk Extreme SSD.
- Raid 0 - WD Black - 2TB.
- SanDisk SSD PLUS 480 GB.
- Intel 760p 256GB M.2 PCIe NVMe SSD.
Creative Sound Blaster Z.
Windows 10 x64 Pro.
etc


My website with my fixes and OpenGL to 3D Vision wrapper:
http://3dsurroundgaming.com

(If you like some of the stuff that I've done and want to donate something, you can do it with PayPal at tavyhome@gmail.com)

Posted 06/29/2013 05:13 AM   
[quote="Foulplay99"]I would be interested to know how you came to your estimated figure for active 3D vision users. I know a lot of forum users are classed as the "Vocal Minority" and after reading these forums daily for almost a year (minus the downtime after the forums were hacked) its still the same relatively small group of guys regularly commenting. In the steam forums for most games you might find a single thread asking about 3D Vision support with maybe 2 or 3 replies, the numbers don't suggest to me there are that many active 3D Vision users out there right now. If the project reaches $20k it would make the argument a lot stronger, however with 500k active 3D vision users wouldn't we have more active users on the forums in general? I've pledged towards this project because I badly want to see it work, but my doubts still unfortunately remain.[/quote]Here is some food for thought. When NVidia announced 3D Vision 2, they also said that they had sales of 500K of 3D Vision 1. [url]http://www.anandtech.com/show/4966/nvidia-announces-3d-vision-2-and-3d-lightboost-technology[/url] That was a year and half ago, and 3D Vision 2 has gotten more attention than 1 because of the LightBoost, better and cheaper monitors. I take that as a starting point, and say that we know that there are 500K old kits in the field, and possibly another 500K of new kits in the field. We have no way of knowing how many are still in use, but this is not an impulse buy. A kit costs $150, and a monitor or projector another $400. I make the reasonable assumption that these are likely still in use, because of the compelling nature of the gaming, and the high cost. Even if you stopped using it, you might be inclined to sell the kit to someone else. I use the 500K figure as a rough estimate to assume that maybe half of the kits are no longer in use, or sales of 3D Vision 2 are not as good as expected. This is maybe more conservative than necessary, but I'm really after an order of magnitude number, not a precise number. Order of magnitude sniff test: Could it be 10x smaller at 50K kits? This seems extremely unlikely, that with 3D Vision 2 we'd have a mass exodus of people stopping playing. 10% of original sales. Can't see it. Could it be 10x larger at 5M kits? This is also extremely unlikely. That would require 3D Vision 2 uptake to be 3M/year, and I think no one can accept that as reality. So, it seems to me that 500K kits of active users is roughly right. We can go up or down to maybe 900K, maybe down to 200K, but I think this is clearly the right order of magnitude. With regard to the number of forum posts- you have to remember that people typically only come to the forums when they have a problem, not when things work well. As a related example, here are the rough sales of AddInBoard GPUs: [url]http://www.jonpeddie.com/publications/add-in-board-report/[/url] That's about 15M boards every quarter. Or roughly 60M boards a year. Now every one of those boards is going to require drivers right? If we go to the forum specifically for drivers we see: [url]https://forums.geforce.com/default/board/27/support/[/url] 30K topics, 200K comments. And I would suggest this is for the most problematic of all the technologies, and probably the most visited. Even if we take into account the entire forum, we are at maybe 1M comments over multiple years. Now compare that 1M actual comments to that 60M boards/year. My argument would be that you cannot use forum comments as a proxy for sales, or even active users.
Foulplay99 said:I would be interested to know how you came to your estimated figure for active 3D vision users. I know a lot of forum users are classed as the "Vocal Minority" and after reading these forums daily for almost a year (minus the downtime after the forums were hacked) its still the same relatively small group of guys regularly commenting.

In the steam forums for most games you might find a single thread asking about 3D Vision support with maybe 2 or 3 replies, the numbers don't suggest to me there are that many active 3D Vision users out there right now.

If the project reaches $20k it would make the argument a lot stronger, however with 500k active 3D vision users wouldn't we have more active users on the forums in general? I've pledged towards this project because I badly want to see it work, but my doubts still unfortunately remain.
Here is some food for thought.

When NVidia announced 3D Vision 2, they also said that they had sales of 500K of 3D Vision 1.

http://www.anandtech.com/show/4966/nvidia-announces-3d-vision-2-and-3d-lightboost-technology

That was a year and half ago, and 3D Vision 2 has gotten more attention than 1 because of the LightBoost, better and cheaper monitors.

I take that as a starting point, and say that we know that there are 500K old kits in the field, and possibly another 500K of new kits in the field. We have no way of knowing how many are still in use, but this is not an impulse buy. A kit costs $150, and a monitor or projector another $400.

I make the reasonable assumption that these are likely still in use, because of the compelling nature of the gaming, and the high cost. Even if you stopped using it, you might be inclined to sell the kit to someone else.

I use the 500K figure as a rough estimate to assume that maybe half of the kits are no longer in use, or sales of 3D Vision 2 are not as good as expected. This is maybe more conservative than necessary, but I'm really after an order of magnitude number, not a precise number.

Order of magnitude sniff test:

Could it be 10x smaller at 50K kits? This seems extremely unlikely, that with 3D Vision 2 we'd have a mass exodus of people stopping playing. 10% of original sales. Can't see it.

Could it be 10x larger at 5M kits? This is also extremely unlikely. That would require 3D Vision 2 uptake to be 3M/year, and I think no one can accept that as reality.

So, it seems to me that 500K kits of active users is roughly right. We can go up or down to maybe 900K, maybe down to 200K, but I think this is clearly the right order of magnitude.


With regard to the number of forum posts- you have to remember that people typically only come to the forums when they have a problem, not when things work well. As a related example, here are the rough sales of AddInBoard GPUs:

http://www.jonpeddie.com/publications/add-in-board-report/

That's about 15M boards every quarter. Or roughly 60M boards a year.

Now every one of those boards is going to require drivers right? If we go to the forum specifically for drivers we see:

https://forums.geforce.com/default/board/27/support/

30K topics, 200K comments. And I would suggest this is for the most problematic of all the technologies, and probably the most visited. Even if we take into account the entire forum, we are at maybe 1M comments over multiple years.

Now compare that 1M actual comments to that 60M boards/year.

My argument would be that you cannot use forum comments as a proxy for sales, or even active users.

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 06/29/2013 05:17 AM   
[quote="bo3b"][quote="Foulplay99"]I would be interested to know how you came to your estimated figure for active 3D vision users. I know a lot of forum users are classed as the "Vocal Minority" and after reading these forums daily for almost a year (minus the downtime after the forums were hacked) its still the same relatively small group of guys regularly commenting. In the steam forums for most games you might find a single thread asking about 3D Vision support with maybe 2 or 3 replies, the numbers don't suggest to me there are that many active 3D Vision users out there right now. If the project reaches $20k it would make the argument a lot stronger, however with 500k active 3D vision users wouldn't we have more active users on the forums in general? I've pledged towards this project because I badly want to see it work, but my doubts still unfortunately remain.[/quote]Here is some food for thought. When NVidia announced 3D Vision 2, they also said that they had sales of 500K of 3D Vision 1. [url]http://www.anandtech.com/show/4966/nvidia-announces-3d-vision-2-and-3d-lightboost-technology[/url] That was a year and half ago, and 3D Vision 2 has gotten more attention than 1 because of the LightBoost, better and cheaper monitors. I take that as a starting point, and say that we know that there are 500K old kits in the field, and possibly another 500K of new kits in the field. We have no way of knowing how many are still in use, but this is not an impulse buy. A kit costs $150, and a monitor or projector another $400. I make the reasonable assumption that these are likely still in use, because of the compelling nature of the gaming, and the high cost. Even if you stopped using it, you might be inclined to sell the kit to someone else. I use the 500K figure as a rough estimate to assume that maybe half of the kits are no longer in use, or sales of 3D Vision 2 are not as good as expected. This is maybe more conservative than necessary, but I'm really after an order of magnitude number, not a precise number. Order of magnitude sniff test: Could it be 10x smaller at 50K kits? This seems extremely unlikely, that with 3D Vision 2 we'd have a mass exodus of people stopping playing. 10% of original sales. Can't see it. Could it be 10x larger at 5M kits? This is also extremely unlikely. That would require 3D Vision 2 uptake to be 3M/year, and I think no one can accept that as reality. So, it seems to me that 500K kits of active users is roughly right. We can go up or down to maybe 900K, maybe down to 200K, but I think this is clearly the right order of magnitude. With regard to the number of forum posts- you have to remember that people typically only come to the forums when they have a problem, not when things work well. As a related example, here are the rough sales of AddInBoard GPUs: [url]http://www.jonpeddie.com/publications/add-in-board-report/[/url] That's about 15M boards every quarter. Or roughly 60M boards a year. Now every one of those boards is going to require drivers right? If we go to the forum specifically for drivers we see: [url]https://forums.geforce.com/default/board/27/support/[/url] 30K topics, 200K comments. And I would suggest this is for the most problematic of all the technologies, and probably the most visited. Even if we take into account the entire forum, we are at maybe 1M comments over multiple years. Now compare that 1M actual comments to that 60M boards/year. My argument would be that you cannot use forum comments as a proxy for sales, or even active users.[/quote] +1 Now I will not post at all here...for the next year and I will continue enjoying my 3D Surround setup:)) that way the number will go down by....1 :)))))
bo3b said:
Foulplay99 said:I would be interested to know how you came to your estimated figure for active 3D vision users. I know a lot of forum users are classed as the "Vocal Minority" and after reading these forums daily for almost a year (minus the downtime after the forums were hacked) its still the same relatively small group of guys regularly commenting.

In the steam forums for most games you might find a single thread asking about 3D Vision support with maybe 2 or 3 replies, the numbers don't suggest to me there are that many active 3D Vision users out there right now.

If the project reaches $20k it would make the argument a lot stronger, however with 500k active 3D vision users wouldn't we have more active users on the forums in general? I've pledged towards this project because I badly want to see it work, but my doubts still unfortunately remain.
Here is some food for thought.

When NVidia announced 3D Vision 2, they also said that they had sales of 500K of 3D Vision 1.

http://www.anandtech.com/show/4966/nvidia-announces-3d-vision-2-and-3d-lightboost-technology

That was a year and half ago, and 3D Vision 2 has gotten more attention than 1 because of the LightBoost, better and cheaper monitors.

I take that as a starting point, and say that we know that there are 500K old kits in the field, and possibly another 500K of new kits in the field. We have no way of knowing how many are still in use, but this is not an impulse buy. A kit costs $150, and a monitor or projector another $400.

I make the reasonable assumption that these are likely still in use, because of the compelling nature of the gaming, and the high cost. Even if you stopped using it, you might be inclined to sell the kit to someone else.

I use the 500K figure as a rough estimate to assume that maybe half of the kits are no longer in use, or sales of 3D Vision 2 are not as good as expected. This is maybe more conservative than necessary, but I'm really after an order of magnitude number, not a precise number.

Order of magnitude sniff test:

Could it be 10x smaller at 50K kits? This seems extremely unlikely, that with 3D Vision 2 we'd have a mass exodus of people stopping playing. 10% of original sales. Can't see it.

Could it be 10x larger at 5M kits? This is also extremely unlikely. That would require 3D Vision 2 uptake to be 3M/year, and I think no one can accept that as reality.

So, it seems to me that 500K kits of active users is roughly right. We can go up or down to maybe 900K, maybe down to 200K, but I think this is clearly the right order of magnitude.


With regard to the number of forum posts- you have to remember that people typically only come to the forums when they have a problem, not when things work well. As a related example, here are the rough sales of AddInBoard GPUs:

http://www.jonpeddie.com/publications/add-in-board-report/

That's about 15M boards every quarter. Or roughly 60M boards a year.

Now every one of those boards is going to require drivers right? If we go to the forum specifically for drivers we see:

https://forums.geforce.com/default/board/27/support/

30K topics, 200K comments. And I would suggest this is for the most problematic of all the technologies, and probably the most visited. Even if we take into account the entire forum, we are at maybe 1M comments over multiple years.

Now compare that 1M actual comments to that 60M boards/year.

My argument would be that you cannot use forum comments as a proxy for sales, or even active users.


+1 Now I will not post at all here...for the next year and I will continue enjoying my 3D Surround setup:)) that way the number will go down by....1
:)))))

1x Palit RTX 2080Ti Pro Gaming OC(watercooled and overclocked to hell)
3x 3D Vision Ready Asus VG278HE monitors (5760x1080).
Intel i9 9900K (overclocked to 5.3 and watercooled ofc).
Asus Maximus XI Hero Mobo.
16 GB Team Group T-Force Dark Pro DDR4 @ 3600.
Lots of Disks:
- Raid 0 - 256GB Sandisk Extreme SSD.
- Raid 0 - WD Black - 2TB.
- SanDisk SSD PLUS 480 GB.
- Intel 760p 256GB M.2 PCIe NVMe SSD.
Creative Sound Blaster Z.
Windows 10 x64 Pro.
etc


My website with my fixes and OpenGL to 3D Vision wrapper:
http://3dsurroundgaming.com

(If you like some of the stuff that I've done and want to donate something, you can do it with PayPal at tavyhome@gmail.com)

Posted 06/29/2013 05:24 AM   
These posts have made a strange turn.
These posts have made a strange turn.

Co-founder of helixmod.blog.com

If you like one of my helixmod patches and want to donate. Can send to me through paypal - eqzitara@yahoo.com

Posted 06/29/2013 07:23 AM   
Here we go :-) [img]https://forums.geforce.com/cmd/default/download-comment-attachment/58751/[/img]
Here we go :-)
Image

Posted 06/29/2013 08:06 AM   
In terms of the offset, I found this on Google. It's probably useless, I don't understand a bit of it. But maybe it isn't useless? Have a read. http://www.riemers.net/Forum/index.php?var=1817&var2=0
In terms of the offset, I found this on Google. It's probably useless, I don't understand a bit of it.

But maybe it isn't useless?

Have a read.


http://www.riemers.net/Forum/index.php?var=1817&var2=0

Posted 06/29/2013 08:17 AM   
As an aside, does your fix do anything to AC3 automatically? I'd be curious to see how far it gets on it's own.
As an aside, does your fix do anything to AC3 automatically? I'd be curious to see how far it gets on it's own.

Posted 06/29/2013 09:59 AM   
[quote="Pirateguybrush"]As an aside, does your fix do anything to AC3 automatically?[/quote] It should, but the shaders of AC3 can't be modified by the wrapper at the moment because it uses non regular offsets of attributes in constant buffers. Thanks for all the links, but I've already looked into pretty much all Microsoft documentation and books about HLSL and shader level 5. Tomorrow is my free day and I'll fix some more Bioshock shaders and take a deeper look into the offset problem. [quote="Pirateguybrush"]Can you elaborate a little?[/quote] Here's a very simple shader from AC3 [code] // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // // Buffer Definitions: // // cbuffer $Globals // { // // float4 g_ViewportScaleOffset; // Offset: 1344 Size: 16 // // struct // { // // float4 m_PositionFar; // Offset: 2048 // float4 m_ColorFade; // Offset: 2064 // // } g_DeferredOmniLight; // Offset: 2048 Size: 32 [unused] // // struct // { // // float3 m_Direction; // Offset: 2080 // float3 m_Color; // Offset: 2096 // // } g_DeferredDirectLight; // Offset: 2080 Size: 28 [unused] // // struct // { // // float4 m_PositionFar; // Offset: 2112 // float4 m_ColorFade; // Offset: 2128 // float3 m_Direction; // Offset: 2144 // float4 m_ConeAngles; // Offset: 2160 // // } g_DeferredSpotLight; // Offset: 2112 Size: 64 [unused] // float4 g_DeferredProjWorldToLight[4];// Offset: 2176 Size: 64 [unused] // float4 g_DeferredProjShadowParams; // Offset: 2240 Size: 16 [unused] // float4 g_DeferredBackgroundColor; // Offset: 2256 Size: 16 [unused] // float4 g_VPOSToUVs_Resolve; // Offset: 2336 Size: 16 [unused] // float4 g_ReverseProjectionParams; // Offset: 1600 Size: 16 [unused] // float2 g_ReverseProjectionParams2; // Offset: 1616 Size: 8 [unused] // float4x4 g_ViewToWorld; // Offset: 1632 Size: 64 [unused] // float4x4 g_WorldToView; // Offset: 1696 Size: 64 [unused] // float4 g_EyePosition; // Offset: 192 Size: 16 [unused] // float4 g_DepthParams; // Offset: 1760 Size: 16 [unused] // float4 g_LinearFogColor; // Offset: 256 Size: 16 [unused] // float4 g_LinearFogParams; // Offset: 272 Size: 16 [unused] // float4x4 g_WorldViewProj; // Offset: 0 Size: 64 [unused] // float4 g_EyeXAxis; // Offset: 128 Size: 16 [unused] // float4 g_EyeYAxis; // Offset: 144 Size: 16 [unused] // float4 g_EyeZAxis; // Offset: 160 Size: 16 [unused] // float4 g_EyeWorldPosition_Resolve; // Offset: 176 Size: 16 [unused] // // struct // { // // float4 m_CloudUVScaleOffset; // Offset: 1024 // float4 m_CloudShadowsParams; // Offset: 1040 // float4 m_ShadowMapSize; // Offset: 1056 // float4 m_OffsetsY; // Offset: 1072 // float4 m_OffsetsX; // Offset: 1088 // float4 m_ScalesY; // Offset: 1104 // float4 m_ScalesX; // Offset: 1120 // float4 m_OffsetsZ; // Offset: 1136 // float4 m_ScalesZ; // Offset: 1152 // float4 m_OffsetsW; // Offset: 1168 // float4 m_ScalesW; // Offset: 1184 // float4 m_NoiseScale; // Offset: 1200 // float4 m_NearFar; // Offset: 1216 // float4 m_FadeParams; // Offset: 1232 // float4 m_CascadesRangesMax; // Offset: 1248 // float4 m_ShadowContrast; // Offset: 1264 // float4x4 m_WorldToLightProj; // Offset: 1280 // // } g_Shadows; // Offset: 1024 Size: 320 [unused] // // struct // { // // float4 m_UseHQFiltering; // Offset: 1008 // // } g_ShadowPerfOptions; // Offset: 1008 Size: 16 [unused] // float4 g_WorldLightmapParameters; // Offset: 1392 Size: 16 [unused] // float4 g_WorldLightmapUVParameters;// Offset: 1408 Size: 16 [unused] // float4 g_WorldLightmapColor; // Offset: 1424 Size: 16 [unused] // float4 g_WorldAOParameters; // Offset: 1440 Size: 16 [unused] // float4 g_WorldAORangeParameters; // Offset: 1456 Size: 16 [unused] // float4 g_WeatherExposedParams; // Offset: 1472 Size: 16 [unused] // float4 g_WinterParams; // Offset: 1488 Size: 16 [unused] // float4 g_SnowSparklesParams; // Offset: 1504 Size: 16 [unused] // float4 g_DebugValue; // Offset: 2352 Size: 16 [unused] // = 0x00000000 0x00000000 0x00000000 0x00000000 // // struct // { // // float2 m_VPOS; // Offset: 2368 // float3 m_ShadowResult; // Offset: 2384 // float3 m_WorldPosition; // Offset: 2400 // float3 m_WorldNormal; // Offset: 2416 // float3 m_WorldEyeVector; // Offset: 2432 // float3 m_NormalizedWorldEyeVector;// Offset: 2448 // float m_SpecularPower; // Offset: 2460 // // } c; // Offset: 2368 Size: 96 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1 // g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1 // $Globals cbuffer NA NA 0 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float // TEXCOORD 0 xyzw 1 NONE float xy w // TEXCOORD 1 xyz 2 NONE float // TEXCOORD 2 xyz 3 NONE float // SV_SAMPLEINDEX 0 x 4 SAMPLE uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // // Pixel Shader runs at sample frequency // ps_4_1 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[85], immediateIndexed dcl_resource_texture2dms(4) (float,float,float,float) t0 dcl_resource_texture2dms(4) (float,float,float,float) t3 dcl_input_ps linear v1.xyw dcl_input_ps_sgv v4.x, sampleIndex dcl_output o0.xyzw dcl_temps 2 resinfo r0.xy, l(0), t0.xyzw div r0.zw, v1.xxxy, v1.wwww mad r0.zw, r0.zzzw, cb0[84].xxxy, cb0[84].zzzw mul r0.xy, r0.xyxx, r0.zwzz ftoi r1.xy, r0.xyxx mov r1.zw, l(0,0,0,0) ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x mov o0.xyz, r1.xyzx resinfo r0.xy, l(0), t3.xyzw mul r0.xy, r0.xyxx, r0.zwzz ftoi r0.xy, r0.xyxx mov r0.zw, l(0,0,0,0) ldms r0.x, r0.xyzw, t3.wxyz, v4.x mov o0.w, r0.x ret // Approximately 15 instruction slots used [/code] The wrapper takes this assembly code and decompiles it to HLSL, which results into: [code] // Global buffer declarations float4 g_ViewportScaleOffset; struct { float4 m_PositionFar; float4 m_ColorFade; } g_DeferredOmniLight; struct { float3 m_Direction; float3 m_Color; } g_DeferredDirectLight; struct { float4 m_PositionFar; float4 m_ColorFade; float3 m_Direction; float4 m_ConeAngles; } g_DeferredSpotLight; float4 g_DeferredProjWorldToLight[4]; float4 g_DeferredProjShadowParams; float4 g_DeferredBackgroundColor; float4 g_VPOSToUVs_Resolve; float4 g_ReverseProjectionParams; float2 g_ReverseProjectionParams2; float4x4 g_ViewToWorld; float4x4 g_WorldToView; float4 g_EyePosition; float4 g_DepthParams; float4 g_LinearFogColor; float4 g_LinearFogParams; float4x4 g_WorldViewProj; float4 g_EyeXAxis; float4 g_EyeYAxis; float4 g_EyeZAxis; float4 g_EyeWorldPosition_Resolve; struct { float4 m_CloudUVScaleOffset; float4 m_CloudShadowsParams; float4 m_ShadowMapSize; float4 m_OffsetsY; float4 m_OffsetsX; float4 m_ScalesY; float4 m_ScalesX; float4 m_OffsetsZ; float4 m_ScalesZ; float4 m_OffsetsW; float4 m_ScalesW; float4 m_NoiseScale; float4 m_NearFar; float4 m_FadeParams; float4 m_CascadesRangesMax; float4 m_ShadowContrast; float4x4 m_WorldToLightProj; } g_Shadows; struct { float4 m_UseHQFiltering; } g_ShadowPerfOptions; float4 g_WorldLightmapParameters; float4 g_WorldLightmapUVParameters; float4 g_WorldLightmapColor; float4 g_WorldAOParameters; float4 g_WorldAORangeParameters; float4 g_WeatherExposedParams; float4 g_WinterParams; float4 g_SnowSparklesParams; float4 g_DebugValue = float4(0.000000e+000,0.000000e+000,0.000000e+000,0.000000e+000); struct { float2 m_VPOS; float3 m_ShadowResult; float3 m_WorldPosition; float3 m_WorldNormal; float3 m_WorldEyeVector; float3 m_NormalizedWorldEyeVector; float m_SpecularPower; } c; Texture2DMS<float4,4> g_TextureAlbedoDX11_MSAA : register(t0); Texture2DMS<float4,4> g_TextureLightingAccumulationDX11_MSAA : register(t3); Texture2D<float4> StereoParams : register(t125); SamplerState StereoParamsSampler; void main( float4 v0 : SV_Position0, float4 v1 : TEXCOORD0, float3 v2 : TEXCOORD1, float3 v3 : TEXCOORD2, uint v4 : SV_SAMPLEINDEX0, out float4 o0 : SV_Target0) { float4 r0,r1; float unused; g_TextureAlbedoDX11_MSAA.GetDimensions(r0.x, r0.y, unused); r0.zw = v1.xy / v1.ww; r0.zw = r0.zw * g_ViewportScaleOffset.xy + g_ViewportScaleOffset.zw; r0.xy = r0.zw * r0.xy; r1.xy = (int2)r0.xy; r1.zw = 0; r1.xyz = g_TextureAlbedoDX11_MSAA.Load(r1.xy,v4.x).xyz; o0.xyz = r1.xyz; g_TextureLightingAccumulationDX11_MSAA.GetDimensions(r0.x, r0.y, unused); r0.xy = r0.zw * r0.xy; r0.xy = (int2)r0.xy; r0.zw = 0; r0.x = g_TextureLightingAccumulationDX11_MSAA.Load(r0.xy,v4.x).w; o0.w = r0.x; } [/code] Then the code is patched by a script or by a person and compiled back to assembly code which results in: [code] // // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384 // // /// // Buffer Definitions: // // cbuffer $Globals // { // // float4 g_ViewportScaleOffset; // Offset: 0 Size: 16 // // struct // { // // float4 m_PositionFar; // Offset: 16 // float4 m_ColorFade; // Offset: 32 // // } g_DeferredOmniLight; // Offset: 16 Size: 32 [unused] // // struct // { // // float3 m_Direction; // Offset: 48 // float3 m_Color; // Offset: 64 // // } g_DeferredDirectLight; // Offset: 48 Size: 28 [unused] // // struct // { // // float4 m_PositionFar; // Offset: 80 // float4 m_ColorFade; // Offset: 96 // float3 m_Direction; // Offset: 112 // float4 m_ConeAngles; // Offset: 128 // // } g_DeferredSpotLight; // Offset: 80 Size: 64 [unused] // float4 g_DeferredProjWorldToLight[4];// Offset: 144 Size: 64 [unused] // float4 g_DeferredProjShadowParams; // Offset: 208 Size: 16 [unused] // float4 g_DeferredBackgroundColor; // Offset: 224 Size: 16 [unused] // float4 g_VPOSToUVs_Resolve; // Offset: 240 Size: 16 [unused] // float4 g_ReverseProjectionParams; // Offset: 256 Size: 16 [unused] // float2 g_ReverseProjectionParams2; // Offset: 272 Size: 8 [unused] // float4x4 g_ViewToWorld; // Offset: 288 Size: 64 [unused] // float4x4 g_WorldToView; // Offset: 352 Size: 64 [unused] // float4 g_EyePosition; // Offset: 416 Size: 16 [unused] // float4 g_DepthParams; // Offset: 432 Size: 16 [unused] // float4 g_LinearFogColor; // Offset: 448 Size: 16 [unused] // float4 g_LinearFogParams; // Offset: 464 Size: 16 [unused] // float4x4 g_WorldViewProj; // Offset: 480 Size: 64 [unused] // float4 g_EyeXAxis; // Offset: 544 Size: 16 [unused] // float4 g_EyeYAxis; // Offset: 560 Size: 16 [unused] // float4 g_EyeZAxis; // Offset: 576 Size: 16 [unused] // float4 g_EyeWorldPosition_Resolve; // Offset: 592 Size: 16 [unused] // // struct // { // // float4 m_CloudUVScaleOffset; // Offset: 608 // float4 m_CloudShadowsParams; // Offset: 624 // float4 m_ShadowMapSize; // Offset: 640 // float4 m_OffsetsY; // Offset: 656 // float4 m_OffsetsX; // Offset: 672 // float4 m_ScalesY; // Offset: 688 // float4 m_ScalesX; // Offset: 704 // float4 m_OffsetsZ; // Offset: 720 // float4 m_ScalesZ; // Offset: 736 // float4 m_OffsetsW; // Offset: 752 // float4 m_ScalesW; // Offset: 768 // float4 m_NoiseScale; // Offset: 784 // float4 m_NearFar; // Offset: 800 // float4 m_FadeParams; // Offset: 816 // float4 m_CascadesRangesMax; // Offset: 832 // float4 m_ShadowContrast; // Offset: 848 // float4x4 m_WorldToLightProj; // Offset: 864 // // } g_Shadows; // Offset: 608 Size: 320 [unused] // // struct // { // // float4 m_UseHQFiltering; // Offset: 928 // // } g_ShadowPerfOptions; // Offset: 928 Size: 16 [unused] // float4 g_WorldLightmapParameters; // Offset: 944 Size: 16 [unused] // float4 g_WorldLightmapUVParameters;// Offset: 960 Size: 16 [unused] // float4 g_WorldLightmapColor; // Offset: 976 Size: 16 [unused] // float4 g_WorldAOParameters; // Offset: 992 Size: 16 [unused] // float4 g_WorldAORangeParameters; // Offset: 1008 Size: 16 [unused] // float4 g_WeatherExposedParams; // Offset: 1024 Size: 16 [unused] // float4 g_WinterParams; // Offset: 1040 Size: 16 [unused] // float4 g_SnowSparklesParams; // Offset: 1056 Size: 16 [unused] // float4 g_DebugValue; // Offset: 1072 Size: 16 [unused] // = 0x00000000 0x00000000 0x00000000 0x00000000 // // struct // { // // float2 m_VPOS; // Offset: 1088 // float3 m_ShadowResult; // Offset: 1104 // float3 m_WorldPosition; // Offset: 1120 // float3 m_WorldNormal; // Offset: 1136 // float3 m_WorldEyeVector; // Offset: 1152 // float3 m_NormalizedWorldEyeVector;// Offset: 1168 // float m_SpecularPower; // Offset: 1180 // // } c; // Offset: 1088 Size: 96 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1 // g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1 // $Globals cbuffer NA NA 0 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float // TEXCOORD 0 xyzw 1 NONE float xy w // TEXCOORD 1 xyz 2 NONE float // TEXCOORD 2 xyz 3 NONE float // SV_SAMPLEINDEX 0 x 4 SAMPLE uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // // Pixel Shader runs at sample frequency // ps_4_1 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[1], immediateIndexed dcl_resource_texture2dms(4) (float,float,float,float) t0 dcl_resource_texture2dms(4) (float,float,float,float) t3 dcl_input_ps linear v1.xyw dcl_input_ps_sgv v4.x, sampleIndex dcl_output o0.xyzw dcl_temps 2 resinfo r0.xy, l(0), t0.xyzw div r0.zw, v1.xxxy, v1.wwww mad r0.zw, r0.zzzw, cb0[0].xxxy, cb0[0].zzzw mul r0.xy, r0.xyxx, r0.zwzz ftoi r1.xy, r0.xyxx mov r1.zw, l(0,0,0,0) ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x mov o0.xyz, r1.xyzx resinfo r0.xy, l(0), t3.xyzw mul r0.xy, r0.xyxx, r0.zwzz ftoi r0.xy, r0.xyxx mov r0.zw, l(0,0,0,0) ldms r0.x, r0.xyzw, t3.wxyz, v4.x mov o0.w, r0.x ret // Approximately 15 instruction slots used [/code] As you can see, the offset values are wrong. That's not a problem in Bioshock or other DX11 games I've ancountered because they use the default offset layout. You can try yourself by compiling the above shader HLSL code using the command line compiler: [code]fxc /E main /T ps_4_1 shadercode.txt[/code] The compiler ist part of the Platform SDK for Windows 8. The DirectX SDK doesn't exist anymore ( http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275 ).
Pirateguybrush said:As an aside, does your fix do anything to AC3 automatically?

It should, but the shaders of AC3 can't be modified by the wrapper at the moment because it uses non regular offsets of attributes in constant buffers. Thanks for all the links, but I've already looked into pretty much all Microsoft documentation and books about HLSL and shader level 5.

Tomorrow is my free day and I'll fix some more Bioshock shaders and take a deeper look into the offset problem.

Pirateguybrush said:Can you elaborate a little?

Here's a very simple shader from AC3
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float4 g_ViewportScaleOffset; // Offset: 1344 Size: 16
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 2048
// float4 m_ColorFade; // Offset: 2064
//
// } g_DeferredOmniLight; // Offset: 2048 Size: 32 [unused]
//
// struct
// {
//
// float3 m_Direction; // Offset: 2080
// float3 m_Color; // Offset: 2096
//
// } g_DeferredDirectLight; // Offset: 2080 Size: 28 [unused]
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 2112
// float4 m_ColorFade; // Offset: 2128
// float3 m_Direction; // Offset: 2144
// float4 m_ConeAngles; // Offset: 2160
//
// } g_DeferredSpotLight; // Offset: 2112 Size: 64 [unused]
// float4 g_DeferredProjWorldToLight[4];// Offset: 2176 Size: 64 [unused]
// float4 g_DeferredProjShadowParams; // Offset: 2240 Size: 16 [unused]
// float4 g_DeferredBackgroundColor; // Offset: 2256 Size: 16 [unused]
// float4 g_VPOSToUVs_Resolve; // Offset: 2336 Size: 16 [unused]
// float4 g_ReverseProjectionParams; // Offset: 1600 Size: 16 [unused]
// float2 g_ReverseProjectionParams2; // Offset: 1616 Size: 8 [unused]
// float4x4 g_ViewToWorld; // Offset: 1632 Size: 64 [unused]
// float4x4 g_WorldToView; // Offset: 1696 Size: 64 [unused]
// float4 g_EyePosition; // Offset: 192 Size: 16 [unused]
// float4 g_DepthParams; // Offset: 1760 Size: 16 [unused]
// float4 g_LinearFogColor; // Offset: 256 Size: 16 [unused]
// float4 g_LinearFogParams; // Offset: 272 Size: 16 [unused]
// float4x4 g_WorldViewProj; // Offset: 0 Size: 64 [unused]
// float4 g_EyeXAxis; // Offset: 128 Size: 16 [unused]
// float4 g_EyeYAxis; // Offset: 144 Size: 16 [unused]
// float4 g_EyeZAxis; // Offset: 160 Size: 16 [unused]
// float4 g_EyeWorldPosition_Resolve; // Offset: 176 Size: 16 [unused]
//
// struct
// {
//
// float4 m_CloudUVScaleOffset; // Offset: 1024
// float4 m_CloudShadowsParams; // Offset: 1040
// float4 m_ShadowMapSize; // Offset: 1056
// float4 m_OffsetsY; // Offset: 1072
// float4 m_OffsetsX; // Offset: 1088
// float4 m_ScalesY; // Offset: 1104
// float4 m_ScalesX; // Offset: 1120
// float4 m_OffsetsZ; // Offset: 1136
// float4 m_ScalesZ; // Offset: 1152
// float4 m_OffsetsW; // Offset: 1168
// float4 m_ScalesW; // Offset: 1184
// float4 m_NoiseScale; // Offset: 1200
// float4 m_NearFar; // Offset: 1216
// float4 m_FadeParams; // Offset: 1232
// float4 m_CascadesRangesMax; // Offset: 1248
// float4 m_ShadowContrast; // Offset: 1264
// float4x4 m_WorldToLightProj; // Offset: 1280
//
// } g_Shadows; // Offset: 1024 Size: 320 [unused]
//
// struct
// {
//
// float4 m_UseHQFiltering; // Offset: 1008
//
// } g_ShadowPerfOptions; // Offset: 1008 Size: 16 [unused]
// float4 g_WorldLightmapParameters; // Offset: 1392 Size: 16 [unused]
// float4 g_WorldLightmapUVParameters;// Offset: 1408 Size: 16 [unused]
// float4 g_WorldLightmapColor; // Offset: 1424 Size: 16 [unused]
// float4 g_WorldAOParameters; // Offset: 1440 Size: 16 [unused]
// float4 g_WorldAORangeParameters; // Offset: 1456 Size: 16 [unused]
// float4 g_WeatherExposedParams; // Offset: 1472 Size: 16 [unused]
// float4 g_WinterParams; // Offset: 1488 Size: 16 [unused]
// float4 g_SnowSparklesParams; // Offset: 1504 Size: 16 [unused]
// float4 g_DebugValue; // Offset: 2352 Size: 16 [unused]
// = 0x00000000 0x00000000 0x00000000 0x00000000
//
// struct
// {
//
// float2 m_VPOS; // Offset: 2368
// float3 m_ShadowResult; // Offset: 2384
// float3 m_WorldPosition; // Offset: 2400
// float3 m_WorldNormal; // Offset: 2416
// float3 m_WorldEyeVector; // Offset: 2432
// float3 m_NormalizedWorldEyeVector;// Offset: 2448
// float m_SpecularPower; // Offset: 2460
//
// } c; // Offset: 2368 Size: 96 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1
// g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1
// $Globals cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy w
// TEXCOORD 1 xyz 2 NONE float
// TEXCOORD 2 xyz 3 NONE float
// SV_SAMPLEINDEX 0 x 4 SAMPLE uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
// Pixel Shader runs at sample frequency
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[85], immediateIndexed
dcl_resource_texture2dms(4) (float,float,float,float) t0
dcl_resource_texture2dms(4) (float,float,float,float) t3
dcl_input_ps linear v1.xyw
dcl_input_ps_sgv v4.x, sampleIndex
dcl_output o0.xyzw
dcl_temps 2
resinfo r0.xy, l(0), t0.xyzw
div r0.zw, v1.xxxy, v1.wwww
mad r0.zw, r0.zzzw, cb0[84].xxxy, cb0[84].zzzw
mul r0.xy, r0.xyxx, r0.zwzz
ftoi r1.xy, r0.xyxx
mov r1.zw, l(0,0,0,0)
ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x
mov o0.xyz, r1.xyzx
resinfo r0.xy, l(0), t3.xyzw
mul r0.xy, r0.xyxx, r0.zwzz
ftoi r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms r0.x, r0.xyzw, t3.wxyz, v4.x
mov o0.w, r0.x
ret
// Approximately 15 instruction slots used


The wrapper takes this assembly code and decompiles it to HLSL, which results into:
// Global buffer declarations
float4 g_ViewportScaleOffset;

struct
{
float4 m_PositionFar;
float4 m_ColorFade;
} g_DeferredOmniLight;

struct
{
float3 m_Direction;
float3 m_Color;
} g_DeferredDirectLight;

struct
{
float4 m_PositionFar;
float4 m_ColorFade;
float3 m_Direction;
float4 m_ConeAngles;
} g_DeferredSpotLight;

float4 g_DeferredProjWorldToLight[4];
float4 g_DeferredProjShadowParams;
float4 g_DeferredBackgroundColor;
float4 g_VPOSToUVs_Resolve;
float4 g_ReverseProjectionParams;
float2 g_ReverseProjectionParams2;
float4x4 g_ViewToWorld;
float4x4 g_WorldToView;
float4 g_EyePosition;
float4 g_DepthParams;
float4 g_LinearFogColor;
float4 g_LinearFogParams;
float4x4 g_WorldViewProj;
float4 g_EyeXAxis;
float4 g_EyeYAxis;
float4 g_EyeZAxis;
float4 g_EyeWorldPosition_Resolve;

struct
{
float4 m_CloudUVScaleOffset;
float4 m_CloudShadowsParams;
float4 m_ShadowMapSize;
float4 m_OffsetsY;
float4 m_OffsetsX;
float4 m_ScalesY;
float4 m_ScalesX;
float4 m_OffsetsZ;
float4 m_ScalesZ;
float4 m_OffsetsW;
float4 m_ScalesW;
float4 m_NoiseScale;
float4 m_NearFar;
float4 m_FadeParams;
float4 m_CascadesRangesMax;
float4 m_ShadowContrast;
float4x4 m_WorldToLightProj;
} g_Shadows;

struct
{
float4 m_UseHQFiltering;
} g_ShadowPerfOptions;

float4 g_WorldLightmapParameters;
float4 g_WorldLightmapUVParameters;
float4 g_WorldLightmapColor;
float4 g_WorldAOParameters;
float4 g_WorldAORangeParameters;
float4 g_WeatherExposedParams;
float4 g_WinterParams;
float4 g_SnowSparklesParams;
float4 g_DebugValue = float4(0.000000e+000,0.000000e+000,0.000000e+000,0.000000e+000);

struct
{
float2 m_VPOS;
float3 m_ShadowResult;
float3 m_WorldPosition;
float3 m_WorldNormal;
float3 m_WorldEyeVector;
float3 m_NormalizedWorldEyeVector;
float m_SpecularPower;
} c;

Texture2DMS<float4,4> g_TextureAlbedoDX11_MSAA : register(t0);
Texture2DMS<float4,4> g_TextureLightingAccumulationDX11_MSAA : register(t3);

Texture2D<float4> StereoParams : register(t125);
SamplerState StereoParamsSampler;

void main(
float4 v0 : SV_Position0,
float4 v1 : TEXCOORD0,
float3 v2 : TEXCOORD1,
float3 v3 : TEXCOORD2,
uint v4 : SV_SAMPLEINDEX0,
out float4 o0 : SV_Target0)
{
float4 r0,r1;
float unused;
g_TextureAlbedoDX11_MSAA.GetDimensions(r0.x, r0.y, unused);
r0.zw = v1.xy / v1.ww;
r0.zw = r0.zw * g_ViewportScaleOffset.xy + g_ViewportScaleOffset.zw;
r0.xy = r0.zw * r0.xy;
r1.xy = (int2)r0.xy;
r1.zw = 0;
r1.xyz = g_TextureAlbedoDX11_MSAA.Load(r1.xy,v4.x).xyz;
o0.xyz = r1.xyz;
g_TextureLightingAccumulationDX11_MSAA.GetDimensions(r0.x, r0.y, unused);
r0.xy = r0.zw * r0.xy;
r0.xy = (int2)r0.xy;
r0.zw = 0;
r0.x = g_TextureLightingAccumulationDX11_MSAA.Load(r0.xy,v4.x).w;
o0.w = r0.x;
}


Then the code is patched by a script or by a person and compiled back to assembly code which results in:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384
//
//
///
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float4 g_ViewportScaleOffset; // Offset: 0 Size: 16
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 16
// float4 m_ColorFade; // Offset: 32
//
// } g_DeferredOmniLight; // Offset: 16 Size: 32 [unused]
//
// struct
// {
//
// float3 m_Direction; // Offset: 48
// float3 m_Color; // Offset: 64
//
// } g_DeferredDirectLight; // Offset: 48 Size: 28 [unused]
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 80
// float4 m_ColorFade; // Offset: 96
// float3 m_Direction; // Offset: 112
// float4 m_ConeAngles; // Offset: 128
//
// } g_DeferredSpotLight; // Offset: 80 Size: 64 [unused]
// float4 g_DeferredProjWorldToLight[4];// Offset: 144 Size: 64 [unused]
// float4 g_DeferredProjShadowParams; // Offset: 208 Size: 16 [unused]
// float4 g_DeferredBackgroundColor; // Offset: 224 Size: 16 [unused]
// float4 g_VPOSToUVs_Resolve; // Offset: 240 Size: 16 [unused]
// float4 g_ReverseProjectionParams; // Offset: 256 Size: 16 [unused]
// float2 g_ReverseProjectionParams2; // Offset: 272 Size: 8 [unused]
// float4x4 g_ViewToWorld; // Offset: 288 Size: 64 [unused]
// float4x4 g_WorldToView; // Offset: 352 Size: 64 [unused]
// float4 g_EyePosition; // Offset: 416 Size: 16 [unused]
// float4 g_DepthParams; // Offset: 432 Size: 16 [unused]
// float4 g_LinearFogColor; // Offset: 448 Size: 16 [unused]
// float4 g_LinearFogParams; // Offset: 464 Size: 16 [unused]
// float4x4 g_WorldViewProj; // Offset: 480 Size: 64 [unused]
// float4 g_EyeXAxis; // Offset: 544 Size: 16 [unused]
// float4 g_EyeYAxis; // Offset: 560 Size: 16 [unused]
// float4 g_EyeZAxis; // Offset: 576 Size: 16 [unused]
// float4 g_EyeWorldPosition_Resolve; // Offset: 592 Size: 16 [unused]
//
// struct
// {
//
// float4 m_CloudUVScaleOffset; // Offset: 608
// float4 m_CloudShadowsParams; // Offset: 624
// float4 m_ShadowMapSize; // Offset: 640
// float4 m_OffsetsY; // Offset: 656
// float4 m_OffsetsX; // Offset: 672
// float4 m_ScalesY; // Offset: 688
// float4 m_ScalesX; // Offset: 704
// float4 m_OffsetsZ; // Offset: 720
// float4 m_ScalesZ; // Offset: 736
// float4 m_OffsetsW; // Offset: 752
// float4 m_ScalesW; // Offset: 768
// float4 m_NoiseScale; // Offset: 784
// float4 m_NearFar; // Offset: 800
// float4 m_FadeParams; // Offset: 816
// float4 m_CascadesRangesMax; // Offset: 832
// float4 m_ShadowContrast; // Offset: 848
// float4x4 m_WorldToLightProj; // Offset: 864
//
// } g_Shadows; // Offset: 608 Size: 320 [unused]
//
// struct
// {
//
// float4 m_UseHQFiltering; // Offset: 928
//
// } g_ShadowPerfOptions; // Offset: 928 Size: 16 [unused]
// float4 g_WorldLightmapParameters; // Offset: 944 Size: 16 [unused]
// float4 g_WorldLightmapUVParameters;// Offset: 960 Size: 16 [unused]
// float4 g_WorldLightmapColor; // Offset: 976 Size: 16 [unused]
// float4 g_WorldAOParameters; // Offset: 992 Size: 16 [unused]
// float4 g_WorldAORangeParameters; // Offset: 1008 Size: 16 [unused]
// float4 g_WeatherExposedParams; // Offset: 1024 Size: 16 [unused]
// float4 g_WinterParams; // Offset: 1040 Size: 16 [unused]
// float4 g_SnowSparklesParams; // Offset: 1056 Size: 16 [unused]
// float4 g_DebugValue; // Offset: 1072 Size: 16 [unused]
// = 0x00000000 0x00000000 0x00000000 0x00000000
//
// struct
// {
//
// float2 m_VPOS; // Offset: 1088
// float3 m_ShadowResult; // Offset: 1104
// float3 m_WorldPosition; // Offset: 1120
// float3 m_WorldNormal; // Offset: 1136
// float3 m_WorldEyeVector; // Offset: 1152
// float3 m_NormalizedWorldEyeVector;// Offset: 1168
// float m_SpecularPower; // Offset: 1180
//
// } c; // Offset: 1088 Size: 96 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1
// g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1
// $Globals cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Position 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy w
// TEXCOORD 1 xyz 2 NONE float
// TEXCOORD 2 xyz 3 NONE float
// SV_SAMPLEINDEX 0 x 4 SAMPLE uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
// Pixel Shader runs at sample frequency
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[1], immediateIndexed
dcl_resource_texture2dms(4) (float,float,float,float) t0
dcl_resource_texture2dms(4) (float,float,float,float) t3
dcl_input_ps linear v1.xyw
dcl_input_ps_sgv v4.x, sampleIndex
dcl_output o0.xyzw
dcl_temps 2
resinfo r0.xy, l(0), t0.xyzw
div r0.zw, v1.xxxy, v1.wwww
mad r0.zw, r0.zzzw, cb0[0].xxxy, cb0[0].zzzw
mul r0.xy, r0.xyxx, r0.zwzz
ftoi r1.xy, r0.xyxx
mov r1.zw, l(0,0,0,0)
ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x
mov o0.xyz, r1.xyzx
resinfo r0.xy, l(0), t3.xyzw
mul r0.xy, r0.xyxx, r0.zwzz
ftoi r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms r0.x, r0.xyzw, t3.wxyz, v4.x
mov o0.w, r0.x
ret
// Approximately 15 instruction slots used


As you can see, the offset values are wrong. That's not a problem in Bioshock or other DX11 games I've ancountered because they use the default offset layout.
You can try yourself by compiling the above shader HLSL code using the command line compiler:
fxc /E main /T ps_4_1 shadercode.txt

The compiler ist part of the Platform SDK for Windows 8. The DirectX SDK doesn't exist anymore ( http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275 ).

Posted 06/29/2013 01:03 PM   
[quote="Chiri"]The compiler ist part of the Platform SDK for Windows 8. The DirectX SDK doesn't exist anymore[/quote] I wish I understood more about all of this, but does that present a problem?
Chiri said:The compiler ist part of the Platform SDK for Windows 8. The DirectX SDK doesn't exist anymore


I wish I understood more about all of this, but does that present a problem?

Posted 06/29/2013 01:34 PM   
Not a problem unless you are making your own fixes. You need the fxc tool to compile the shaders. If you wanted to try Chiri's experiment, you'd need fxc, but otherwise not.
Not a problem unless you are making your own fixes. You need the fxc tool to compile the shaders. If you wanted to try Chiri's experiment, you'd need fxc, but otherwise not.

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 06/29/2013 01:50 PM   
@Chiri First off, your idea of decompiling the ASM is genius. Awesome. For the offsets, it seems to me that you will need to sort the definitions to match the Offset text in the comment fields. For example, the g_WorldViewProj is Offset 0, but in the middle of the documentation area. When it's compiled to assembly, the compiler is unlikely to be required to maintain order, and that might be where the randomized offsets come from. If you were to rearrange them before decompiling, you should get structs that match the original definitions. Before doing that code though, it would be worth an experiment of manually reordering them to see if that fixes it.
@Chiri
First off, your idea of decompiling the ASM is genius. Awesome.

For the offsets, it seems to me that you will need to sort the definitions to match the Offset text in the comment fields. For example, the g_WorldViewProj is Offset 0, but in the middle of the documentation area.

When it's compiled to assembly, the compiler is unlikely to be required to maintain order, and that might be where the randomized offsets come from.

If you were to rearrange them before decompiling, you should get structs that match the original definitions.

Before doing that code though, it would be worth an experiment of manually reordering them to see if that fixes it.

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 06/29/2013 01:57 PM   
Manually reordered the ASM to make Offsets in ascending order, then manually reordered your decompiled file to match that. As: [code] // Global buffer declarations - reordered float4x4 g_WorldViewProj; float4 g_EyeXAxis; float4 g_EyeYAxis; float4 g_EyeZAxis; float4 g_EyeWorldPosition_Resolve; float4 g_EyePosition; float4 g_LinearFogColor; float4 g_LinearFogParams; struct { float4 m_UseHQFiltering; } g_ShadowPerfOptions; struct { float4 m_CloudUVScaleOffset; float4 m_CloudShadowsParams; float4 m_ShadowMapSize; float4 m_OffsetsY; float4 m_OffsetsX; float4 m_ScalesY; float4 m_ScalesX; float4 m_OffsetsZ; float4 m_ScalesZ; float4 m_OffsetsW; float4 m_ScalesW; float4 m_NoiseScale; float4 m_NearFar; float4 m_FadeParams; float4 m_CascadesRangesMax; float4 m_ShadowContrast; float4x4 m_WorldToLightProj; } g_Shadows; float4 g_ViewportScaleOffset; float4 g_WorldLightmapParameters; float4 g_WorldLightmapUVParameters; float4 g_WorldLightmapColor; float4 g_WorldAOParameters; float4 g_WorldAORangeParameters; float4 g_WeatherExposedParams; float4 g_WinterParams; float4 g_SnowSparklesParams; float4 g_ReverseProjectionParams; float2 g_ReverseProjectionParams2; float4x4 g_ViewToWorld; float4x4 g_WorldToView; float4 g_DepthParams; struct { float4 m_PositionFar; float4 m_ColorFade; } g_DeferredOmniLight; struct { float3 m_Direction; float3 m_Color; } g_DeferredDirectLight; struct { float4 m_PositionFar; float4 m_ColorFade; float3 m_Direction; float4 m_ConeAngles; } g_DeferredSpotLight; float4 g_DeferredProjWorldToLight[4]; float4 g_DeferredProjShadowParams; float4 g_DeferredBackgroundColor; float4 g_VPOSToUVs_Resolve; float4 g_DebugValue = float4(0.000000e+000,0.000000e+000,0.000000e+000,0.000000e+000); struct { float2 m_VPOS; float3 m_ShadowResult; float3 m_WorldPosition; float3 m_WorldNormal; float3 m_WorldEyeVector; float3 m_NormalizedWorldEyeVector; float m_SpecularPower; } c; Texture2DMS<float4,4> g_TextureAlbedoDX11_MSAA : register(t0); Texture2DMS<float4,4> g_TextureLightingAccumulationDX11_MSAA : register(t3); Texture2D<float4> StereoParams : register(t125); SamplerState StereoParamsSampler; void main( float4 v0 : SV_Position0, float4 v1 : TEXCOORD0, float3 v2 : TEXCOORD1, float3 v3 : TEXCOORD2, uint v4 : SV_SAMPLEINDEX0, out float4 o0 : SV_Target0) { float4 r0,r1; float unused; g_TextureAlbedoDX11_MSAA.GetDimensions(r0.x, r0.y, unused); r0.zw = v1.xy / v1.ww; r0.zw = r0.zw * g_ViewportScaleOffset.xy + g_ViewportScaleOffset.zw; r0.xy = r0.zw * r0.xy; r1.xy = (int2)r0.xy; r1.zw = 0; r1.xyz = g_TextureAlbedoDX11_MSAA.Load(r1.xy,v4.x).xyz; o0.xyz = r1.xyz; g_TextureLightingAccumulationDX11_MSAA.GetDimensions(r0.x, r0.y, unused); r0.xy = r0.zw * r0.xy; r0.xy = (int2)r0.xy; r0.zw = 0; r0.x = g_TextureLightingAccumulationDX11_MSAA.Load(r0.xy,v4.x).w; o0.w = r0.x; } [/code]
Manually reordered the ASM to make Offsets in ascending order, then manually reordered your decompiled file to match that. As:

// Global buffer declarations - reordered
float4x4 g_WorldViewProj;
float4 g_EyeXAxis;
float4 g_EyeYAxis;
float4 g_EyeZAxis;
float4 g_EyeWorldPosition_Resolve;
float4 g_EyePosition;
float4 g_LinearFogColor;
float4 g_LinearFogParams;

struct
{
float4 m_UseHQFiltering;
} g_ShadowPerfOptions;

struct
{
float4 m_CloudUVScaleOffset;
float4 m_CloudShadowsParams;
float4 m_ShadowMapSize;
float4 m_OffsetsY;
float4 m_OffsetsX;
float4 m_ScalesY;
float4 m_ScalesX;
float4 m_OffsetsZ;
float4 m_ScalesZ;
float4 m_OffsetsW;
float4 m_ScalesW;
float4 m_NoiseScale;
float4 m_NearFar;
float4 m_FadeParams;
float4 m_CascadesRangesMax;
float4 m_ShadowContrast;
float4x4 m_WorldToLightProj;
} g_Shadows;

float4 g_ViewportScaleOffset;
float4 g_WorldLightmapParameters;
float4 g_WorldLightmapUVParameters;
float4 g_WorldLightmapColor;
float4 g_WorldAOParameters;
float4 g_WorldAORangeParameters;
float4 g_WeatherExposedParams;
float4 g_WinterParams;
float4 g_SnowSparklesParams;
float4 g_ReverseProjectionParams;
float2 g_ReverseProjectionParams2;
float4x4 g_ViewToWorld;
float4x4 g_WorldToView;
float4 g_DepthParams;

struct
{
float4 m_PositionFar;
float4 m_ColorFade;
} g_DeferredOmniLight;

struct
{
float3 m_Direction;
float3 m_Color;
} g_DeferredDirectLight;

struct
{
float4 m_PositionFar;
float4 m_ColorFade;
float3 m_Direction;
float4 m_ConeAngles;
} g_DeferredSpotLight;

float4 g_DeferredProjWorldToLight[4];
float4 g_DeferredProjShadowParams;
float4 g_DeferredBackgroundColor;
float4 g_VPOSToUVs_Resolve;

float4 g_DebugValue = float4(0.000000e+000,0.000000e+000,0.000000e+000,0.000000e+000);

struct
{
float2 m_VPOS;
float3 m_ShadowResult;
float3 m_WorldPosition;
float3 m_WorldNormal;
float3 m_WorldEyeVector;
float3 m_NormalizedWorldEyeVector;
float m_SpecularPower;
} c;

Texture2DMS<float4,4> g_TextureAlbedoDX11_MSAA : register(t0);
Texture2DMS<float4,4> g_TextureLightingAccumulationDX11_MSAA : register(t3);

Texture2D<float4> StereoParams : register(t125);
SamplerState StereoParamsSampler;

void main(
float4 v0 : SV_Position0,
float4 v1 : TEXCOORD0,
float3 v2 : TEXCOORD1,
float3 v3 : TEXCOORD2,
uint v4 : SV_SAMPLEINDEX0,
out float4 o0 : SV_Target0)
{
float4 r0,r1;
float unused;
g_TextureAlbedoDX11_MSAA.GetDimensions(r0.x, r0.y, unused);
r0.zw = v1.xy / v1.ww;
r0.zw = r0.zw * g_ViewportScaleOffset.xy + g_ViewportScaleOffset.zw;
r0.xy = r0.zw * r0.xy;
r1.xy = (int2)r0.xy;
r1.zw = 0;
r1.xyz = g_TextureAlbedoDX11_MSAA.Load(r1.xy,v4.x).xyz;
o0.xyz = r1.xyz;
g_TextureLightingAccumulationDX11_MSAA.GetDimensions(r0.x, r0.y, unused);
r0.xy = r0.zw * r0.xy;
r0.xy = (int2)r0.xy;
r0.zw = 0;
r0.x = g_TextureLightingAccumulationDX11_MSAA.Load(r0.xy,v4.x).w;
o0.w = r0.x;
}

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 06/29/2013 02:32 PM   
Compiling that with fxc starts out OK, but doesn't match the original because of missing declarations in the middle. This technique would thus require padding as well to normalize the offsets. [code]Microsoft (R) Direct3D Shader Compiler 9.29.952.3111 Copyright (C) Microsoft Corporation 2002-2009. All rights reserved. // // Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111 // // // fxc /E main /T ps_4_1 c:\hlsl test.txt // // // Buffer Definitions: // // cbuffer $Globals // { // // float4x4 g_WorldViewProj; // Offset: 0 Size: 64 [unused] // float4 g_EyeXAxis; // Offset: 64 Size: 16 [unused] // float4 g_EyeYAxis; // Offset: 80 Size: 16 [unused] // float4 g_EyeZAxis; // Offset: 96 Size: 16 [unused] // float4 g_EyeWorldPosition_Resolve; // Offset: 112 Size: 16 [unused] // float4 g_EyePosition; // Offset: 128 Size: 16 [unused] // float4 g_LinearFogColor; // Offset: 144 Size: 16 [unused] // float4 g_LinearFogParams; // Offset: 160 Size: 16 [unused] // // struct // { // // float4 m_UseHQFiltering; // Offset: 176 // // } g_ShadowPerfOptions; // Offset: 176 Size: 16 [unused] // // struct // { // // float4 m_CloudUVScaleOffset; // Offset: 192 // float4 m_CloudShadowsParams; // Offset: 208 // float4 m_ShadowMapSize; // Offset: 224 // float4 m_OffsetsY; // Offset: 240 // float4 m_OffsetsX; // Offset: 256 // float4 m_ScalesY; // Offset: 272 // float4 m_ScalesX; // Offset: 288 // float4 m_OffsetsZ; // Offset: 304 // float4 m_ScalesZ; // Offset: 320 // float4 m_OffsetsW; // Offset: 336 // float4 m_ScalesW; // Offset: 352 // float4 m_NoiseScale; // Offset: 368 // float4 m_NearFar; // Offset: 384 // float4 m_FadeParams; // Offset: 400 // float4 m_CascadesRangesMax; // Offset: 416 // float4 m_ShadowContrast; // Offset: 432 // float4x4 m_WorldToLightProj; // Offset: 448 // // } g_Shadows; // Offset: 192 Size: 320 [unused] // float4 g_ViewportScaleOffset; // Offset: 512 Size: 16 // float4 g_WorldLightmapParameters; // Offset: 528 Size: 16 [unused] // float4 g_WorldLightmapUVParameters;// Offset: 544 Size: 16 [unused] // float4 g_WorldLightmapColor; // Offset: 560 Size: 16 [unused] // float4 g_WorldAOParameters; // Offset: 576 Size: 16 [unused] // float4 g_WorldAORangeParameters; // Offset: 592 Size: 16 [unused] // float4 g_WeatherExposedParams; // Offset: 608 Size: 16 [unused] // float4 g_WinterParams; // Offset: 624 Size: 16 [unused] // float4 g_SnowSparklesParams; // Offset: 640 Size: 16 [unused] // float4 g_ReverseProjectionParams; // Offset: 656 Size: 16 [unused] // float2 g_ReverseProjectionParams2; // Offset: 672 Size: 8 [unused] // float4x4 g_ViewToWorld; // Offset: 688 Size: 64 [unused] // float4x4 g_WorldToView; // Offset: 752 Size: 64 [unused] // float4 g_DepthParams; // Offset: 816 Size: 16 [unused] // // struct // { // // float4 m_PositionFar; // Offset: 832 // float4 m_ColorFade; // Offset: 848 // // } g_DeferredOmniLight; // Offset: 832 Size: 32 [unused] // // struct // { // // float3 m_Direction; // Offset: 864 // float3 m_Color; // Offset: 880 // // } g_DeferredDirectLight; // Offset: 864 Size: 28 [unused] // // struct // { // // float4 m_PositionFar; // Offset: 896 // float4 m_ColorFade; // Offset: 912 // float3 m_Direction; // Offset: 928 // float4 m_ConeAngles; // Offset: 944 // // } g_DeferredSpotLight; // Offset: 896 Size: 64 [unused] // float4 g_DeferredProjWorldToLight[4];// Offset: 960 Size: 64 [unused] // float4 g_DeferredProjShadowParams; // Offset: 1024 Size: 16 [unused] // float4 g_DeferredBackgroundColor; // Offset: 1040 Size: 16 [unused] // float4 g_VPOSToUVs_Resolve; // Offset: 1056 Size: 16 [unused] // float4 g_DebugValue; // Offset: 1072 Size: 16 [unused] // = 0x00000000 0x00000000 0x00000000 0x00000000 // // struct // { // // float2 m_VPOS; // Offset: 1088 // float3 m_ShadowResult; // Offset: 1104 // float3 m_WorldPosition; // Offset: 1120 // float3 m_WorldNormal; // Offset: 1136 // float3 m_WorldEyeVector; // Offset: 1152 // float3 m_NormalizedWorldEyeVector;// Offset: 1168 // float m_SpecularPower; // Offset: 1180 // // } c; // Offset: 1088 Size: 96 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1 // g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1 // $Globals cbuffer NA NA 0 1 // // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------ ------ // SV_Position 0 xyzw 0 POS float // TEXCOORD 0 xyzw 1 NONE float xy w // TEXCOORD 1 xyz 2 NONE float // TEXCOORD 2 xyz 3 NONE float // SV_SAMPLEINDEX 0 x 4 SAMPLE uint x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------ ------ // SV_Target 0 xyzw 0 TARGET float xyzw // // Pixel Shader runs at sample frequency // ps_4_1 dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[33], immediateIndexed dcl_resource_texture2dms(4) (float,float,float,float) t0 dcl_resource_texture2dms(4) (float,float,float,float) t3 dcl_input_ps linear v1.xyw dcl_input_ps_sgv v4.x, sampleIndex dcl_output o0.xyzw dcl_temps 2 resinfo r0.xy, l(0), t0.xyzw div r0.zw, v1.xxxy, v1.wwww mad r0.zw, r0.zzzw, cb0[32].xxxy, cb0[32].zzzw mul r0.xy, r0.xyxx, r0.zwzz round_z r0.xy, r0.xyxx ftoi r1.xy, r0.xyxx mov r1.zw, l(0,0,0,0) ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x mov o0.xyz, r1.xyzx resinfo r0.xy, l(0), t3.xyzw mul r0.xy, r0.xyxx, r0.zwzz round_z r0.xy, r0.xyxx ftoi r0.xy, r0.xyxx mov r0.zw, l(0,0,0,0) ldms r0.x, r0.xyzw, t3.wxyz, v4.x mov o0.w, r0.x ret // Approximately 17 instruction slots used [/code]
Compiling that with fxc starts out OK, but doesn't match the original because of missing declarations in the middle. This technique would thus require padding as well to normalize the offsets.

Microsoft (R) Direct3D Shader Compiler 9.29.952.3111
Copyright (C) Microsoft Corporation 2002-2009. All rights reserved.

//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
//
// fxc /E main /T ps_4_1 c:\hlsl test.txt
//
//
// Buffer Definitions:
//
// cbuffer $Globals
// {
//
// float4x4 g_WorldViewProj; // Offset: 0 Size: 64 [unused]
// float4 g_EyeXAxis; // Offset: 64 Size: 16 [unused]
// float4 g_EyeYAxis; // Offset: 80 Size: 16 [unused]
// float4 g_EyeZAxis; // Offset: 96 Size: 16 [unused]
// float4 g_EyeWorldPosition_Resolve; // Offset: 112 Size: 16 [unused]
// float4 g_EyePosition; // Offset: 128 Size: 16 [unused]
// float4 g_LinearFogColor; // Offset: 144 Size: 16 [unused]
// float4 g_LinearFogParams; // Offset: 160 Size: 16 [unused]
//
// struct
// {
//
// float4 m_UseHQFiltering; // Offset: 176
//
// } g_ShadowPerfOptions; // Offset: 176 Size: 16 [unused]
//
// struct
// {
//
// float4 m_CloudUVScaleOffset; // Offset: 192
// float4 m_CloudShadowsParams; // Offset: 208
// float4 m_ShadowMapSize; // Offset: 224
// float4 m_OffsetsY; // Offset: 240
// float4 m_OffsetsX; // Offset: 256
// float4 m_ScalesY; // Offset: 272
// float4 m_ScalesX; // Offset: 288
// float4 m_OffsetsZ; // Offset: 304
// float4 m_ScalesZ; // Offset: 320
// float4 m_OffsetsW; // Offset: 336
// float4 m_ScalesW; // Offset: 352
// float4 m_NoiseScale; // Offset: 368
// float4 m_NearFar; // Offset: 384
// float4 m_FadeParams; // Offset: 400
// float4 m_CascadesRangesMax; // Offset: 416
// float4 m_ShadowContrast; // Offset: 432
// float4x4 m_WorldToLightProj; // Offset: 448
//
// } g_Shadows; // Offset: 192 Size: 320 [unused]
// float4 g_ViewportScaleOffset; // Offset: 512 Size: 16
// float4 g_WorldLightmapParameters; // Offset: 528 Size: 16 [unused]
// float4 g_WorldLightmapUVParameters;// Offset: 544 Size: 16 [unused]
// float4 g_WorldLightmapColor; // Offset: 560 Size: 16 [unused]
// float4 g_WorldAOParameters; // Offset: 576 Size: 16 [unused]
// float4 g_WorldAORangeParameters; // Offset: 592 Size: 16 [unused]
// float4 g_WeatherExposedParams; // Offset: 608 Size: 16 [unused]
// float4 g_WinterParams; // Offset: 624 Size: 16 [unused]
// float4 g_SnowSparklesParams; // Offset: 640 Size: 16 [unused]
// float4 g_ReverseProjectionParams; // Offset: 656 Size: 16 [unused]
// float2 g_ReverseProjectionParams2; // Offset: 672 Size: 8 [unused]
// float4x4 g_ViewToWorld; // Offset: 688 Size: 64 [unused]
// float4x4 g_WorldToView; // Offset: 752 Size: 64 [unused]
// float4 g_DepthParams; // Offset: 816 Size: 16 [unused]
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 832
// float4 m_ColorFade; // Offset: 848
//
// } g_DeferredOmniLight; // Offset: 832 Size: 32 [unused]
//
// struct
// {
//
// float3 m_Direction; // Offset: 864
// float3 m_Color; // Offset: 880
//
// } g_DeferredDirectLight; // Offset: 864 Size: 28 [unused]
//
// struct
// {
//
// float4 m_PositionFar; // Offset: 896
// float4 m_ColorFade; // Offset: 912
// float3 m_Direction; // Offset: 928
// float4 m_ConeAngles; // Offset: 944
//
// } g_DeferredSpotLight; // Offset: 896 Size: 64 [unused]
// float4 g_DeferredProjWorldToLight[4];// Offset: 960 Size: 64 [unused]
// float4 g_DeferredProjShadowParams; // Offset: 1024 Size: 16 [unused]
// float4 g_DeferredBackgroundColor; // Offset: 1040 Size: 16 [unused]
// float4 g_VPOSToUVs_Resolve; // Offset: 1056 Size: 16 [unused]
// float4 g_DebugValue; // Offset: 1072 Size: 16 [unused]
// = 0x00000000 0x00000000 0x00000000 0x00000000
//
// struct
// {
//
// float2 m_VPOS; // Offset: 1088
// float3 m_ShadowResult; // Offset: 1104
// float3 m_WorldPosition; // Offset: 1120
// float3 m_WorldNormal; // Offset: 1136
// float3 m_WorldEyeVector; // Offset: 1152
// float3 m_NormalizedWorldEyeVector;// Offset: 1168
// float m_SpecularPower; // Offset: 1180
//
// } c; // Offset: 1088 Size: 96 [unused]
//
// }
//
//
// Resource Bindings:
//
// Name Type Format Dim Slot Elements
// ------------------------------ ---------- ------- ----------- ---- --------
// g_TextureAlbedoDX11_MSAA texture float4 2dMS4 0 1
// g_TextureLightingAccumulationDX11_MSAA texture float4 2dMS4 3 1
// $Globals cbuffer NA NA 0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Position 0 xyzw 0 POS float
// TEXCOORD 0 xyzw 1 NONE float xy w
// TEXCOORD 1 xyz 2 NONE float
// TEXCOORD 2 xyz 3 NONE float
// SV_SAMPLEINDEX 0 x 4 SAMPLE uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
// Pixel Shader runs at sample frequency
//
ps_4_1
dcl_globalFlags refactoringAllowed
dcl_constantbuffer cb0[33], immediateIndexed
dcl_resource_texture2dms(4) (float,float,float,float) t0
dcl_resource_texture2dms(4) (float,float,float,float) t3
dcl_input_ps linear v1.xyw
dcl_input_ps_sgv v4.x, sampleIndex
dcl_output o0.xyzw
dcl_temps 2
resinfo r0.xy, l(0), t0.xyzw
div r0.zw, v1.xxxy, v1.wwww
mad r0.zw, r0.zzzw, cb0[32].xxxy, cb0[32].zzzw
mul r0.xy, r0.xyxx, r0.zwzz
round_z r0.xy, r0.xyxx
ftoi r1.xy, r0.xyxx
mov r1.zw, l(0,0,0,0)
ldms r1.xyz, r1.xyzw, t0.xyzw, v4.x
mov o0.xyz, r1.xyzx
resinfo r0.xy, l(0), t3.xyzw
mul r0.xy, r0.xyxx, r0.zwzz
round_z r0.xy, r0.xyxx
ftoi r0.xy, r0.xyxx
mov r0.zw, l(0,0,0,0)
ldms r0.x, r0.xyzw, t3.wxyz, v4.x
mov o0.w, r0.x
ret
// Approximately 17 instruction slots used

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 06/29/2013 02:56 PM   
[quote="bo3b"]Manually reordered the ASM to make Offsets in ascending order, then manually reordered your decompiled file to match that.[/quote] Thanks, but I finally figured out how to use the packoffset directive on globals. I'll update the wrapper tomorrow and test it with AC3 (as a side effect, the $Globals identifier is gone, but all games do buffer updates by using register numbers and not identifiers anyways).
bo3b said:Manually reordered the ASM to make Offsets in ascending order, then manually reordered your decompiled file to match that.

Thanks, but I finally figured out how to use the packoffset directive on globals. I'll update the wrapper tomorrow and test it with AC3 (as a side effect, the $Globals identifier is gone, but all games do buffer updates by using register numbers and not identifiers anyways).

Posted 06/29/2013 03:00 PM   
  8 / 12    
Scroll To Top