1

I've been researching a game's engine for the last few months and after extracting the DX9 bytecode, have begun examining the game's shaders. I mainly worked with OpenGL so some of the syntax or way of doing things is new to me.

Anyway, this is a 5x5 gaussian blur pixel shader (3.0). Can anyone explain what is going on with the texture coords declaration? Does this mean 4 coordinates are being sent into the pixel shader? Or is the same texture coordinate being reused?

def c0, 0.120259, 0.162103, 0.089216, 0.000000
dcl_texcoord0 v0.xy
dcl_texcoord1 v1
dcl_texcoord2 v2
dcl_texcoord3 v3
dcl_texcoord4 v4
dcl_2d s0
tex_pp r0, v1.zwzw, s0
mul r0, r0, c0.x
tex_pp r1, v1, s0
mad_pp r0, r1, c0.y, r0
tex_pp r1, v2, s0
mad_pp r0, r1, c0.x, r0
tex_pp r1, v2.zwzw, s0
mad_pp r0, r1, c0.x, r0
tex_pp r1, v3, s0
mad_pp r0, r1, c0.x, r0
tex_pp r1, v3.zwzw, s0
mad_pp r0, r1, c0.z, r0
tex_pp r1, v4, s0
mad_pp r0, r1, c0.z, r0
tex_pp r1, v4.zwzw, s0
mad_pp r0, r1, c0.z, r0
tex_pp r1, v0, s0
mad_pp oC0, r1, c0.z, r0
end
Ioncannon
  • 901
  • 1
  • 7
  • 19

1 Answers1

1

The dcl_texcoord ASM instruction declares a register that contains data. For a pixel shader in D3D9, this data would be written in the vertex stage. So, yes, in this shader there are in fact 5 sets of texture coordinates in use (0..4). The first coordinate only uses the two first components, which is why is declared with those explicitly (this reduces the bandwidth required between the stages). The other four do additional samples with the upper two components as well, so the shader samples in 9 times total.

MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
  • Thank you, that makes more sense. I actually found the vertex shader and found the data that gets moved to the pixel shader. – Ioncannon Jul 06 '15 at 17:12
  • Just to make sure I am looking at the correct shader... so does that mean there would be a corresponding o0, o1, o2, o3, o4 in the vertex shader? – Ioncannon Jul 06 '15 at 17:18
  • Texture coordinate registers output in a vertex shader would appear as 'oT0'. https://msdn.microsoft.com/en-us/library/windows/desktop/bb172959(v=vs.85).aspx – MuertoExcobito Jul 06 '15 at 18:13