D3D shader assembler

Stefan Dösinger stefandoesinger at gmx.at
Mon Jul 20 14:51:27 CDT 2009


Am Monday 20 July 2009 20:33:44 schrieb Henri Verbeet:
> > While in principle this is right, as many functions are indeed very
> > similar, this won't be pretty practically, even excluding that some
> > instructions really need special treatment.
One more thing comes to my mind here: The assembler doesn't actually check if 
the registers for the instruction are valid. You can happily assemble a 
shader that doesn't make sense, but validation fails. The validation is 
implemented in d3d9.dll.Direct3DShaderValidatorCreate9, not in the assembler:

For example:
vs_2_0
rep c0
endrep
mov oPos, c0

$ vsa.exe shader.txt /Fh shader.h (with native d3d9)
Microsoft (R) D3DX9 Shader Assembler 9.25 PRIVATE
Copyright (C) Microsoft Corporation 2002-2003. All rights reserved.

Z:\dev\shm\shader.txt(2,1): error X5936: rep requires first parameter to be 
integer constant register (i#).

assembly failed; no code produced

$ vsa.exe shader.txt /Fh shader.h (with builtin d3d9)
Microsoft (R) D3DX9 Shader Assembler 9.25 PRIVATE
Copyright (C) Microsoft Corporation 2002-2003. All rights reserved.

fixme:d3d9:Direct3DShaderValidatorCreate9 stub
assembly succeeded; see shader.h

So while its certainly nice to print a warning if such a thing happens, the 
assembler doesn't have to catch it, and must not return an error. Its 
certainly worth testing if this holds true in d3dx9 though, since vsa.exe 
seems to have its own copy of the assembler.

As I said to Matteo in an IRC conversion, my main intentions for the 
one-callback-per-instruction setup when I wrote it last year were this sort 
of error handling(which I later found out doesn't happen in the assembler), 
and to map all shader versions to a shared format, and then generate any 
target shader version(ie, convert between two shader versions), which is now 
moot as well since we put the shader into d3dx9 and strictly stick to the MS 
API that way.



More information about the wine-devel mailing list