+void
+nine_context_set_vertex_shader_constant_f(struct NineDevice9 *device,
+ UINT StartRegister,
+ const float *pConstantData,
+ UINT Vector4fCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ float *vs_const_f = device->may_swvp ? context->vs_const_f_swvp : context->vs_const_f;
+
+ memcpy(&vs_const_f[StartRegister * 4],
+ pConstantData,
+ Vector4fCount * 4 * sizeof(context->vs_const_f[0]));
+
+ if (device->may_swvp) {
+ Vector4fCount = MIN2(StartRegister + Vector4fCount, NINE_MAX_CONST_F) - StartRegister;
+ if (StartRegister < NINE_MAX_CONST_F)
+ memcpy(&context->vs_const_f[StartRegister * 4],
+ pConstantData,
+ Vector4fCount * 4 * sizeof(context->vs_const_f[0]));
+ }
+
+ context->changed.vs_const_f = TRUE;
+ state->changed.group |= NINE_STATE_VS_CONST;
+}
+
+
+void
+nine_context_set_vertex_shader_constant_i(struct NineDevice9 *device,
+ UINT StartRegister,
+ const int *pConstantData,
+ UINT Vector4iCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ int i;
+
+ if (device->driver_caps.vs_integer) {
+ memcpy(&context->vs_const_i[4 * StartRegister],
+ pConstantData,
+ Vector4iCount * sizeof(int[4]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ context->vs_const_i[4 * (StartRegister + i)] = fui((float)(pConstantData[4 * i]));
+ context->vs_const_i[4 * (StartRegister + i) + 1] = fui((float)(pConstantData[4 * i + 1]));
+ context->vs_const_i[4 * (StartRegister + i) + 2] = fui((float)(pConstantData[4 * i + 2]));
+ context->vs_const_i[4 * (StartRegister + i) + 3] = fui((float)(pConstantData[4 * i + 3]));
+ }
+ }
+
+ context->changed.vs_const_i = TRUE;
+ state->changed.group |= NINE_STATE_VS_CONST;
+}
+
+void
+nine_context_set_vertex_shader_constant_b(struct NineDevice9 *device,
+ UINT StartRegister,
+ const BOOL *pConstantData,
+ UINT BoolCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ int i;
+ uint32_t bool_true = device->driver_caps.vs_integer ? 0xFFFFFFFF : fui(1.0f);
+
+ for (i = 0; i < BoolCount; i++)
+ context->vs_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
+
+ context->changed.vs_const_b = TRUE;
+ state->changed.group |= NINE_STATE_VS_CONST;
+}
+
+void
+nine_context_set_pixel_shader_constant_f(struct NineDevice9 *device,
+ UINT StartRegister,
+ const float *pConstantData,
+ UINT Vector4fCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+
+ memcpy(&context->ps_const_f[StartRegister * 4],
+ pConstantData,
+ Vector4fCount * 4 * sizeof(context->ps_const_f[0]));
+
+ context->changed.ps_const_f = TRUE;
+ state->changed.group |= NINE_STATE_PS_CONST;
+}
+
+void
+nine_context_set_pixel_shader_constant_i(struct NineDevice9 *device,
+ UINT StartRegister,
+ const int *pConstantData,
+ UINT Vector4iCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ int i;
+
+ if (device->driver_caps.ps_integer) {
+ memcpy(&context->ps_const_i[StartRegister][0],
+ pConstantData,
+ Vector4iCount * sizeof(context->ps_const_i[0]));
+ } else {
+ for (i = 0; i < Vector4iCount; i++) {
+ context->ps_const_i[StartRegister+i][0] = fui((float)(pConstantData[4*i]));
+ context->ps_const_i[StartRegister+i][1] = fui((float)(pConstantData[4*i+1]));
+ context->ps_const_i[StartRegister+i][2] = fui((float)(pConstantData[4*i+2]));
+ context->ps_const_i[StartRegister+i][3] = fui((float)(pConstantData[4*i+3]));
+ }
+ }
+ context->changed.ps_const_i = TRUE;
+ state->changed.group |= NINE_STATE_PS_CONST;
+}
+
+void
+nine_context_set_pixel_shader_constant_b(struct NineDevice9 *device,
+ UINT StartRegister,
+ const BOOL *pConstantData,
+ UINT BoolCount)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ int i;
+ uint32_t bool_true = device->driver_caps.ps_integer ? 0xFFFFFFFF : fui(1.0f);
+
+ for (i = 0; i < BoolCount; i++)
+ context->ps_const_b[StartRegister + i] = pConstantData[i] ? bool_true : 0;
+
+ context->changed.ps_const_b = TRUE;
+ state->changed.group |= NINE_STATE_PS_CONST;
+}
+