{
const struct lp_fragment_shader_variant *variant = state->variant;
const struct lp_tgsi_info *info = &variant->shader->info;
- struct lp_jit_linear_context jit;
- int nr_consts = info->base.file_max[TGSI_FILE_CONSTANT]+1;
+ uint8_t constants[LP_MAX_LINEAR_CONSTANTS * 4];
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
/* XXX: Per statechange:
*/
+ int nr_consts; // in floats, not float[4]
if (variant->shader->base.type == PIPE_SHADER_IR_TGSI) {
- uint8_t constants[LP_MAX_LINEAR_CONSTANTS][4];
-
- for (int i = 0; i < nr_consts; i++) {
- for (int j = 0; j < 4; j++) {
- float val = state->jit_context.constants[0][i*4+j];
- if (val < 0.0f || val > 1.0f) {
- if (LP_DEBUG & DEBUG_LINEAR2)
- debug_printf(" -- const[%d] out of range %f\n", i, val);
- goto fail;
- }
- constants[i][j] = (uint8_t)(val * 255.0f);
- }
- }
- jit.constants = (const uint8_t (*)[4])constants;
+ nr_consts = (info->base.file_max[TGSI_FILE_CONSTANT] + 1) * 4;
} else {
- uint8_t nir_constants[LP_MAX_LINEAR_CONSTANTS * 4];
-
- for (int i = 0; i < state->jit_context.num_constants[0]; i++){
- float val = state->jit_context.constants[0][i];
- if (val < 0.0f || val > 1.0f) {
- if (LP_DEBUG & DEBUG_LINEAR2)
- debug_printf(" -- const[%d] out of range %f\n", i, val);
- goto fail;
- }
- nir_constants[i] = (uint8_t)(val * 255.0f);
+ nr_consts = state->jit_context.num_constants[0];
+ }
+ for (int i = 0; i < nr_consts; i++){
+ float val = state->jit_context.constants[0][i];
+ if (val < 0.0f || val > 1.0f) {
+ if (LP_DEBUG & DEBUG_LINEAR2)
+ debug_printf(" -- const[%d] out of range %f\n", i, val);
+ goto fail;
}
- jit.constants = (const uint8_t (*)[4])nir_constants;
+ constants[i] = (uint8_t)(val * 255.0f);
}
+ struct lp_jit_linear_context jit;
+ jit.constants = (const uint8_t (*)[4])constants;
+
/* We assume BGRA ordering */
assert(variant->key.cbuf_format[0] == PIPE_FORMAT_B8G8R8X8_UNORM ||
variant->key.cbuf_format[0] == PIPE_FORMAT_B8G8R8A8_UNORM);