};
static struct qreg
-get_temp_for_uniform(struct tgsi_to_qir *trans, uint32_t uniform)
+add_uniform(struct tgsi_to_qir *trans,
+ enum quniform_contents contents,
+ uint32_t data)
{
- struct qcompile *c = trans->c;
+ uint32_t uniform = trans->num_uniforms++;
struct qreg u = { QFILE_UNIF, uniform };
- struct qreg t = qir_MOV(c, u);
- trans->uniforms[uniform] = t;
- return t;
+ trans->uniform_contents[uniform] = contents;
+ trans->uniform_data[uniform] = data;
+
+ return u;
}
static struct qreg
-qir_uniform_ui(struct tgsi_to_qir *trans, uint32_t ui)
+get_temp_for_uniform(struct tgsi_to_qir *trans, enum quniform_contents contents,
+ uint32_t data)
{
+ struct qcompile *c = trans->c;
+
for (int i = 0; i < trans->num_uniforms; i++) {
- if (trans->uniform_contents[i] == QUNIFORM_CONSTANT &&
- trans->uniform_data[i] == ui)
+ if (trans->uniform_contents[i] == contents &&
+ trans->uniform_data[i] == data)
return trans->uniforms[i];
}
- trans->uniform_contents[trans->num_uniforms] = QUNIFORM_CONSTANT;
- trans->uniform_data[trans->num_uniforms] = ui;
- return get_temp_for_uniform(trans, trans->num_uniforms++);
+ struct qreg u = add_uniform(trans, contents, data);
+ struct qreg t = qir_MOV(c, u);
+
+ trans->uniforms[u.index] = t;
+ return t;
}
static struct qreg
-qir_uniform_f(struct tgsi_to_qir *trans, float f)
+qir_uniform_ui(struct tgsi_to_qir *trans, uint32_t ui)
{
- return qir_uniform_ui(trans, fui(f));
+ return get_temp_for_uniform(trans, QUNIFORM_CONSTANT, ui);
}
static struct qreg
-qir_uniform(struct tgsi_to_qir *trans, uint32_t index)
+qir_uniform_f(struct tgsi_to_qir *trans, float f)
{
- for (int i = 0; i < trans->num_uniforms; i++) {
- if (trans->uniform_contents[i] == QUNIFORM_UNIFORM &&
- trans->uniform_data[i] == index)
- return trans->uniforms[i];
- }
-
- trans->uniform_contents[trans->num_uniforms] = QUNIFORM_UNIFORM;
- trans->uniform_data[trans->num_uniforms] = index;
- return get_temp_for_uniform(trans, trans->num_uniforms++);
+ return qir_uniform_ui(trans, fui(f));
}
static struct qreg
r = trans->consts[src->Index * 4 + s];
break;
case TGSI_FILE_CONSTANT:
- r = qir_uniform(trans, src->Index * 4 + s);
+ r = get_temp_for_uniform(trans, QUNIFORM_UNIFORM,
+ src->Index * 4 + s);
break;
case TGSI_FILE_INPUT:
r = trans->inputs[src->Index * 4 + s];
struct qreg xyi[2];
for (int i = 0; i < 2; i++) {
- trans->uniform_contents[trans->num_uniforms] =
- QUNIFORM_VIEWPORT_X_SCALE + i;
- struct qreg scale = { QFILE_UNIF, trans->num_uniforms++ };
+ struct qreg scale =
+ add_uniform(trans, QUNIFORM_VIEWPORT_X_SCALE + i, 0);
xyi[i] = qir_FTOI(c, qir_FMUL(c, trans->outputs[i], scale));
}