#include "main/mtypes.h"
#include "brw_structs.h"
#include "intel_aub.h"
+#include "program/prog_parameter.h"
#ifdef __cplusplus
extern "C" {
* These must be the last fields of the struct (see
* brw_stage_prog_data_compare()).
*/
- const float **param;
- const float **pull_param;
+ const gl_constant_value **param;
+ const gl_constant_value **pull_param;
};
/* Data about a particular attempt to compile a program. Note that
/* BRW_NEW_CURBE_OFFSETS */
const GLuint sz = brw->curbe.total_size;
const GLuint bufsz = sz * 16 * sizeof(GLfloat);
- GLfloat *buf;
+ gl_constant_value *buf;
GLuint i;
gl_clip_plane *clip_planes;
buf = intel_upload_space(brw, bufsz, 64,
&brw->curbe.curbe_bo, &brw->curbe.curbe_offset);
+ STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
+
/* fragment shader constants */
if (brw->curbe.wm_size) {
/* BRW_NEW_CURBE_OFFSETS */
/* If any planes are going this way, send them all this way:
*/
for (i = 0; i < 6; i++) {
- buf[offset + i * 4 + 0] = fixed_plane[i][0];
- buf[offset + i * 4 + 1] = fixed_plane[i][1];
- buf[offset + i * 4 + 2] = fixed_plane[i][2];
- buf[offset + i * 4 + 3] = fixed_plane[i][3];
+ buf[offset + i * 4 + 0].f = fixed_plane[i][0];
+ buf[offset + i * 4 + 1].f = fixed_plane[i][1];
+ buf[offset + i * 4 + 2].f = fixed_plane[i][2];
+ buf[offset + i * 4 + 3].f = fixed_plane[i][3];
}
/* Clip planes: _NEW_TRANSFORM plus _NEW_PROJECTION to get to
clip_planes = brw_select_clip_planes(ctx);
for (j = 0; j < MAX_CLIP_PLANES; j++) {
if (ctx->Transform.ClipPlanesEnabled & (1<<j)) {
- buf[offset + i * 4 + 0] = clip_planes[j][0];
- buf[offset + i * 4 + 1] = clip_planes[j][1];
- buf[offset + i * 4 + 2] = clip_planes[j][2];
- buf[offset + i * 4 + 3] = clip_planes[j][3];
+ buf[offset + i * 4 + 0].f = clip_planes[j][0];
+ buf[offset + i * 4 + 1].f = clip_planes[j][1];
+ buf[offset + i * 4 + 2].f = clip_planes[j][2];
+ buf[offset + i * 4 + 3].f = clip_planes[j][3];
i++;
}
}
if (0) {
for (i = 0; i < sz*16; i+=4)
fprintf(stderr, "curbe %d.%d: %f %f %f %f\n", i/8, i&4,
- buf[i+0], buf[i+1], buf[i+2], buf[i+3]);
+ buf[i+0].f, buf[i+1].f, buf[i+2].f, buf[i+3].f);
}
/* Because this provokes an action (ie copy the constants into the
slots *= storage->array_elements;
for (unsigned i = 0; i < slots; i++) {
- stage_prog_data->param[uniforms++] = &storage->storage[i].f;
+ stage_prog_data->param[uniforms++] = &storage->storage[i];
}
}
last_swiz = swiz;
stage_prog_data->param[uniforms++] =
- &fp->Base.Parameters->ParameterValues[index][swiz].f;
+ &fp->Base.Parameters->ParameterValues[index][swiz];
}
}
}
* add it.
*/
if (pull_constant_loc[uniform] == -1) {
- const float **values = &stage_prog_data->param[uniform];
+ const gl_constant_value **values = &stage_prog_data->param[uniform];
assert(param_size[uniform]);
p < prog->Parameters->NumParameters; p++) {
for (unsigned int i = 0; i < 4; i++) {
stage_prog_data->param[uniforms++] =
- &prog->Parameters->ParameterValues[p][i].f;
+ &prog->Parameters->ParameterValues[p][i];
}
}
}
/* Try to find existing copies of the texrect scale uniforms. */
for (unsigned i = 0; i < uniforms; i++) {
if (stage_prog_data->param[i] ==
- &prog->Parameters->ParameterValues[index][0].f) {
+ &prog->Parameters->ParameterValues[index][0]) {
scale_x = fs_reg(UNIFORM, i);
scale_y = fs_reg(UNIFORM, i + 1);
break;
scale_y = fs_reg(UNIFORM, uniforms + 1);
stage_prog_data->param[uniforms++] =
- &prog->Parameters->ParameterValues[index][0].f;
+ &prog->Parameters->ParameterValues[index][0];
stage_prog_data->param[uniforms++] =
- &prog->Parameters->ParameterValues[index][1].f;
+ &prog->Parameters->ParameterValues[index][1];
}
}
pull_constant_loc[i / 4] = -1;
if (i >= max_uniform_components) {
- const float **values = &stage_prog_data->param[i];
+ const gl_constant_value **values = &stage_prog_data->param[i];
/* Try to find an existing copy of this uniform in the pull
* constants if it was part of an array access already.
this->uniform_vector_size[this->uniforms] = 1;
stage_prog_data->param =
- reralloc(NULL, stage_prog_data->param, const float *, 4);
+ reralloc(NULL, stage_prog_data->param, const gl_constant_value *, 4);
for (unsigned int i = 0; i < 4; i++) {
unsigned int slot = this->uniforms * 4 + i;
- static float zero = 0.0;
+ static gl_constant_value zero = { .f = 0.0 };
stage_prog_data->param[slot] = &zero;
}
param_count += MAX_CLIP_PLANES * 4;
c.prog_data.base.base.param =
- rzalloc_array(NULL, const float *, param_count);
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
c.prog_data.base.base.pull_param =
- rzalloc_array(NULL, const float *, param_count);
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
/* Setting nr_params here NOT to the size of the param and pull_param
* arrays, but to the number of uniform components vec4_visitor
* needs. vec4_visitor::setup_uniforms() will set it back to a proper value.
int i;
for (i = 0; i < uniform_vector_size[uniforms]; i++) {
- stage_prog_data->param[uniforms * 4 + i] = &components->f;
+ stage_prog_data->param[uniforms * 4 + i] = components;
components++;
}
for (; i < 4; i++) {
- static float zero = 0;
+ static gl_constant_value zero = { .f = 0.0 };
stage_prog_data->param[uniforms * 4 + i] = &zero;
}
this->userplane[i] = dst_reg(UNIFORM, this->uniforms);
this->userplane[i].type = BRW_REGISTER_TYPE_F;
for (int j = 0; j < 4; ++j) {
- stage_prog_data->param[this->uniforms * 4 + j] = &clip_planes[i][j];
+ stage_prog_data->param[this->uniforms * 4 + j] =
+ (gl_constant_value *) &clip_planes[i][j];
}
++this->uniforms;
}
*/
int index = _mesa_add_state_reference(this->prog->Parameters,
(gl_state_index *)slots[i].tokens);
- float *values = &this->prog->Parameters->ParameterValues[index][0].f;
+ gl_constant_value *values =
+ &this->prog->Parameters->ParameterValues[index][0];
assert(this->uniforms < uniform_array_size);
this->uniform_vector_size[this->uniforms] = 0;
* add it.
*/
if (pull_constant_loc[uniform] == -1) {
- const float **values = &stage_prog_data->param[uniform * 4];
+ const gl_constant_value **values =
+ &stage_prog_data->param[uniform * 4];
pull_constant_loc[uniform] = stage_prog_data->nr_pull_params / 4;
unsigned i;
for (i = 0; i < params->NumParameters * 4; i++) {
stage_prog_data->pull_param[i] =
- ¶ms->ParameterValues[i / 4][i % 4].f;
+ ¶ms->ParameterValues[i / 4][i % 4];
}
stage_prog_data->nr_pull_params = i;
}
this->uniform_vector_size[this->uniforms] = components;
for (unsigned i = 0; i < 4; i++) {
stage_prog_data->param[this->uniforms * 4 + i] = i >= components
- ? 0 : &plist->ParameterValues[p][i].f;
+ ? 0 : &plist->ParameterValues[p][i];
}
this->uniforms++; /* counted in vec4 units */
}
*/
param_count += c.key.base.nr_userclip_plane_consts * 4;
- stage_prog_data->param = rzalloc_array(NULL, const float *, param_count);
- stage_prog_data->pull_param = rzalloc_array(NULL, const float *, param_count);
+ stage_prog_data->param =
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
+ stage_prog_data->pull_param =
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
/* Setting nr_params here NOT to the size of the param and pull_param
* arrays, but to the number of uniform components vec4_visitor
uint32_t size = prog_data->nr_pull_params * 4;
drm_intel_bo *const_bo = NULL;
uint32_t const_offset;
- float *constants = intel_upload_space(brw, size, 64,
- &const_bo, &const_offset);
+ gl_constant_value *constants = intel_upload_space(brw, size, 64,
+ &const_bo, &const_offset);
+
+ STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
for (i = 0; i < prog_data->nr_pull_params; i++) {
constants[i] = *prog_data->pull_param[i];
if (0) {
for (i = 0; i < ALIGN(prog_data->nr_pull_params, 4) / 4; i++) {
- float *row = &constants[i * 4];
+ const gl_constant_value *row = &constants[i * 4];
fprintf(stderr, "const surface %3d: %4.3f %4.3f %4.3f %4.3f\n",
- i, row[0], row[1], row[2], row[3]);
+ i, row[0].f, row[1].f, row[2].f, row[3].f);
}
}
}
/* The backend also sometimes adds params for texture size. */
param_count += 2 * ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
- prog_data.base.param = rzalloc_array(NULL, const float *, param_count);
+ prog_data.base.param =
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
prog_data.base.pull_param =
- rzalloc_array(NULL, const float *, param_count);
+ rzalloc_array(NULL, const gl_constant_value *, param_count);
prog_data.base.nr_params = param_count;
prog_data.barycentric_interp_modes =
if (prog_data->nr_params == 0) {
stage_state->push_const_size = 0;
} else {
- float *param;
+ gl_constant_value *param;
int i;
param = brw_state_batch(brw, type,
- prog_data->nr_params * sizeof(float),
+ prog_data->nr_params * sizeof(gl_constant_value),
32, &stage_state->push_const_offset);
+ STATIC_ASSERT(sizeof(gl_constant_value) == sizeof(float));
+
/* _NEW_PROGRAM_CONSTANTS
*
* Also _NEW_TRANSFORM -- we may reference clip planes other than as a
if ((i & 7) == 0)
fprintf(stderr, "g%d: ",
prog_data->dispatch_grf_start_reg + i / 8);
- fprintf(stderr, "%8f ", param[i]);
+ fprintf(stderr, "%8f ", param[i].f);
if ((i & 7) == 7)
fprintf(stderr, "\n");
}