How to use a huge array in HLSL (error X4505)

1.9k views Asked by At

When I try to compile I get the error:

X4505: sum of temp register and indexable temp registers exceeds limit of 4096.

However my shader does work in FX Composer.

The reason it crashes is probably because I use a very large array since I'm using marching cubes.

const static int edgeTable[256] = ...
const static int triTable[256][16] = ...

How should I go about using these arrays? (D11)

2

There are 2 answers

0
Achille Depla On BEST ANSWER

So... I actually solved this problem a few days after posting this (a few allnighters) and forgot to upload the solution. By now I have forgotten what it exactly was so I'm putting up my whole solution: https://github.com/Ownie/MarchingCubesShader

1
MuertoExcobito On

https://msdn.microsoft.com/en-us/library/windows/desktop/ff476898(v=vs.85).aspx#Shader_Constant_Buffer

Each shader stage allows up to 15 shader-constant buffers; each buffer can hold up to 4096 constants.