Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/compiler/glsl/ast_to_hir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3925,7 +3925,8 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
"`invariant' after being used",
var->name);
} else {
var->data.invariant = 1;
var->data.explicit_invariant = true;
var->data.invariant = true;
}
}

Expand Down Expand Up @@ -4133,8 +4134,10 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
}
}

if (state->all_invariant && var->data.mode == ir_var_shader_out)
if (state->all_invariant && var->data.mode == ir_var_shader_out) {
var->data.explicit_invariant = true;
var->data.invariant = true;
}

var->data.interpolation =
interpret_interpolation_qualifier(qual, var->type,
Expand Down Expand Up @@ -4845,6 +4848,7 @@ ast_declarator_list::hir(exec_list *instructions,
"`invariant' after being used",
earlier->name);
} else {
earlier->data.explicit_invariant = true;
earlier->data.invariant = true;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/compiler/glsl/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->data.centroid = false;
this->data.sample = false;
this->data.patch = false;
this->data.explicit_invariant = false;
this->data.invariant = false;
this->data.how_declared = ir_var_declared_normally;
this->data.mode = mode;
Expand Down
13 changes: 13 additions & 0 deletions src/compiler/glsl/ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,19 @@ class ir_variable : public ir_instruction {
unsigned centroid:1;
unsigned sample:1;
unsigned patch:1;
/**
* Was an 'invariant' qualifier explicitly set in the shader?
*
* This is used to cross validate qualifiers.
*/
unsigned explicit_invariant:1;
/**
* Is the variable invariant?
*
* It can happen either by having the 'invariant' qualifier
* explicitly set in the shader or by being used in calculations
* of other invariant variables.
*/
unsigned invariant:1;
unsigned precise:1;

Expand Down
3 changes: 2 additions & 1 deletion src/compiler/glsl/ir_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,8 @@ ir_reader::read_declaration(s_expression *expr)
} else if (strcmp(qualifier->value(), "patch") == 0) {
var->data.patch = 1;
} else if (strcmp(qualifier->value(), "invariant") == 0) {
var->data.invariant = 1;
var->data.explicit_invariant = true;
var->data.invariant = true;
} else if (strcmp(qualifier->value(), "uniform") == 0) {
var->data.mode = ir_var_uniform;
} else if (strcmp(qualifier->value(), "shader_storage") == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/glsl/link_varyings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,16 @@ cross_validate_types_and_qualifiers(struct gl_context *ctx,
* "The invariance of varyings that are declared in both the vertex
* and fragment shaders must match."
*/
if (input->data.invariant != output->data.invariant &&
if (input->data.explicit_invariant != output->data.explicit_invariant &&
prog->data->Version < (prog->IsES ? 300 : 430)) {
linker_error(prog,
"%s shader output `%s' %s invariant qualifier, "
"but %s shader input %s invariant qualifier\n",
_mesa_shader_stage_to_string(producer_stage),
output->name,
(output->data.invariant) ? "has" : "lacks",
(output->data.explicit_invariant) ? "has" : "lacks",
_mesa_shader_stage_to_string(consumer_stage),
(input->data.invariant) ? "has" : "lacks");
(input->data.explicit_invariant) ? "has" : "lacks");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/glsl/linker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ cross_validate_globals(struct gl_context *ctx, struct gl_shader_program *prog,
}
}

if (existing->data.invariant != var->data.invariant) {
if (existing->data.explicit_invariant != var->data.explicit_invariant) {
linker_error(prog, "declarations for %s `%s' have "
"mismatching invariant qualifiers\n",
mode_string(var), var->name);
Expand Down
15 changes: 11 additions & 4 deletions src/mesa/drivers/dri/i965/intel_batchbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,11 +742,18 @@ submit_batch(struct brw_context *brw, int in_fence_fd, int *out_fence_fd)
int ret = 0;

if (batch->use_shadow_copy) {
void *bo_map = brw_bo_map(brw, batch->batch.bo, MAP_WRITE);
memcpy(bo_map, batch->batch.map, 4 * USED_BATCH(*batch));
void *state_map, *batch_map = brw_bo_map(brw, batch->batch.bo, MAP_WRITE);
if(batch_map == NULL)
return -1;

state_map = brw_bo_map(brw, batch->state.bo, MAP_WRITE);
if (state_map == NULL) {
brw_bo_unmap(batch->batch.bo);
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would the mapping fail, what was the failing usecase/app?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem happened only once and a core dump was the only thing the customer could provide, I found the the application tried to access a NULL pointer and triggered A/V. To answer your question: we don't know the root cause of the mapping failure,

This is simply a w/a to fail the submission in case of mapping failure, hopefully the user app checks the error and fails gracefully instead of crashes to terminal.

}

bo_map = brw_bo_map(brw, batch->state.bo, MAP_WRITE);
memcpy(bo_map, batch->state.map, batch->state_used);
memcpy(batch_map, batch->batch.map, 4 * USED_BATCH(*batch));
memcpy(state_map, batch->state.map, batch->state_used);
}

brw_bo_unmap(batch->batch.bo);
Expand Down