D3D11: Fix constant position code for good

I had forgotten how constants worked when compiled; constants are
uploaded as constant registers.  When constants are used with shaders,
multiple constants are often packed in to a single register when
possible to reduce constant register count.

For example, one 'float' constant and one 'float3' constant will be
packed in to a single register (c0.x for constant 1, c0.yzw for constant
2), but two 'float' constants and one 'float3' constant must inhabit two
registers (c0.xy for constant 1, c1.xyz for constant 2), so it must
start on a new register boundry (every 16 bytes).

I had first instinctively thought it was just a simple case of
alignment like it is on the CPU, but then I realized that it didn't
sound right, so I went back and did some more tests and then ultimately
remembered how constants actually are uploaded.
This commit is contained in:
jp9000
2014-05-02 21:38:05 -07:00
parent 8195786811
commit 2838a95066
2 changed files with 58 additions and 17 deletions

View File

@@ -329,13 +329,15 @@ struct shader_param {
string name;
shader_param_type type;
uint32_t textureID;
uint32_t textureID;
int arrayCount;
int arrayCount;
vector<uint8_t> curValue;
vector<uint8_t> defaultValue;
bool changed;
size_t pos;
vector<uint8_t> curValue;
vector<uint8_t> defaultValue;
bool changed;
shader_param(shader_var &var, uint32_t &texCounter);
};