shed some bytes
hex edit a shader compiled with the HLSL compiler and you’ll see it has added a bunch of extra data. it has an embedded constant table and a big fat string saying the compiler version. if you are making an intro this is wasting bytes! here’s the easiest way to strip that out. compile in two steps instead of one:
fxc /nologo /EPixelShader /Tps_1_1 shaders.fx > shaderPs.psh
psa /FhshaderPs.h /Vns_psData shaderPs.psh
Thanks for the tip! Exactly this issue is what I was worried about at the moment. The version string is probably okay (exe compressor should take care of it); but the constant tables were useless in my case.
glad to help. one other useful bit is that if you don’t already know, you can force HLSL to map a constant to a particular register using for example:
float4x4 world : register(c0);
Yeah, I’m already using that (that’s why I have no use of the constant table). Actually, a macro processing is more convenient: have a header file ‘constants.h’ with something like:
#define SHC_WORLDMAT 0
#define SHC_VIEWPROJMAT 4
// etc.
#define REG(x) register(c##x)
Then use this header file in both HLSL (float4x4 world : REG(0)) and C++ (just use the constants)
[...] Compiling HLSL in two steps (HLSL->asm and asm->bytecode) instead of direct (HLSL->bytecode) gets rid of the constant table, some copyright strings and hence is good. (thanks blackpawn!) [...]