summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shader_query.cpp
diff options
context:
space:
mode:
authorTapani Pälli <tapani.palli@intel.com>2015-11-05 12:52:26 +0200
committerTapani Pälli <tapani.palli@intel.com>2015-11-12 09:50:14 +0200
commit7e6dac11866d264c21a108b9623114943d6e88ec (patch)
treeb86850f4dcd588f3184d25f669797d93ce7166c8 /src/mesa/main/shader_query.cpp
parent5bd122cad9d16596f89260f3b115cd0fb72cb886 (diff)
downloadexternal_mesa3d-7e6dac11866d264c21a108b9623114943d6e88ec.zip
external_mesa3d-7e6dac11866d264c21a108b9623114943d6e88ec.tar.gz
external_mesa3d-7e6dac11866d264c21a108b9623114943d6e88ec.tar.bz2
mesa: validate precision of varyings during ValidateProgramPipeline
Fixes following failing ES3.1 CTS tests: ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingFloat ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingInt ES31-CTS.sepshaderobjs.InterfacePrecisionMatchingUInt Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Diffstat (limited to 'src/mesa/main/shader_query.cpp')
-rw-r--r--src/mesa/main/shader_query.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 5cb877b..58ba041 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1359,3 +1359,65 @@ _mesa_get_program_resourceiv(struct gl_shader_program *shProg,
if (length)
*length = amount;
}
+
+static bool
+validate_io(const struct gl_shader *input_stage,
+ const struct gl_shader *output_stage)
+{
+ assert(input_stage && output_stage);
+
+ /* For each output in a, find input in b and do any required checks. */
+ foreach_in_list(ir_instruction, out, input_stage->ir) {
+ ir_variable *out_var = out->as_variable();
+ if (!out_var || out_var->data.mode != ir_var_shader_out)
+ continue;
+
+ foreach_in_list(ir_instruction, in, output_stage->ir) {
+ ir_variable *in_var = in->as_variable();
+ if (!in_var || in_var->data.mode != ir_var_shader_in)
+ continue;
+
+ if (strcmp(in_var->name, out_var->name) == 0) {
+ /* From OpenGL ES 3.1 spec:
+ * "When both shaders are in separate programs, mismatched
+ * precision qualifiers will result in a program interface
+ * mismatch that will result in program pipeline validation
+ * failures, as described in section 7.4.1 (“Shader Interface
+ * Matching”) of the OpenGL ES 3.1 Specification."
+ */
+ if (in_var->data.precision != out_var->data.precision)
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+/**
+ * Validate inputs against outputs in a program pipeline.
+ */
+extern "C" bool
+_mesa_validate_pipeline_io(struct gl_pipeline_object *pipeline)
+{
+ struct gl_shader_program **shProg =
+ (struct gl_shader_program **) pipeline->CurrentProgram;
+
+ /* Find first active stage in pipeline. */
+ unsigned idx, prev = 0;
+ for (idx = 0; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) {
+ if (shProg[idx]) {
+ prev = idx;
+ break;
+ }
+ }
+
+ for (idx = prev + 1; idx < ARRAY_SIZE(pipeline->CurrentProgram); idx++) {
+ if (shProg[idx]) {
+ if (!validate_io(shProg[prev]->_LinkedShaders[prev],
+ shProg[idx]->_LinkedShaders[idx]))
+ return false;
+ prev = idx;
+ }
+ }
+ return true;
+}