Mesa (main): i915g: Mark program errors on setting up temps, constants, and immediates.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 28 22:17:31 UTC 2021


Module: Mesa
Branch: main
Commit: ccc9418b27d06e8880cc9158d06df1e7fbe40eef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccc9418b27d06e8880cc9158d06df1e7fbe40eef

Author: Emma Anholt <emma at anholt.net>
Date:   Sun Jun 27 15:00:59 2021 -0700

i915g: Mark program errors on setting up temps, constants, and immediates.

We would proceed through the compiler, and usually fail for some other
reason (ALU ops, etc.), but best to be sure.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11617>

---

 .../drivers/i915/ci/deqp-i915-g33-fails.txt        |  2 +-
 .../drivers/i915/ci/piglit-i915-g33-fails.txt      |  4 +--
 src/gallium/drivers/i915/i915_fpc_translate.c      | 35 ++++++++++++++--------
 3 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt
index fb82641f366..d0f7cebbc53 100644
--- a/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt
+++ b/src/gallium/drivers/i915/ci/deqp-i915-g33-fails.txt
@@ -928,7 +928,7 @@ dEQP-GLES2.functional.uniform_api.random.21,Fail
 dEQP-GLES2.functional.uniform_api.random.24,Fail
 dEQP-GLES2.functional.uniform_api.random.54,Fail
 dEQP-GLES2.functional.uniform_api.random.71,Fail
-dEQP-GLES2.functional.uniform_api.random.74,Crash
+dEQP-GLES2.functional.uniform_api.random.74,Fail
 dEQP-GLES2.functional.uniform_api.random.80,Fail
 dEQP-GLES2.functional.uniform_api.random.81,Fail
 dEQP-GLES2.functional.uniform_api.value.assigned.by_pointer.render.array_in_struct.int_ivec4_both,Fail
diff --git a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
index aa7d173db18..d78d0f5db9d 100644
--- a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
+++ b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt
@@ -688,14 +688,14 @@ spec at glsl-1.10@execution at fs-frontfacing-ternary-0.0-neg-1.0,Fail
 spec at glsl-1.10@execution at fs-frontfacing-ternary-1-neg-1,Fail
 spec at glsl-1.10@execution at fs-frontfacing-ternary-1.0-neg-1.0,Fail
 spec at glsl-1.10@execution at fs-frontfacing-ternary-neg-1.0-1.0,Fail
-spec at glsl-1.10@execution at fs-loop-bounds-unrolled,Crash
+spec at glsl-1.10@execution at fs-loop-bounds-unrolled,Fail
 spec at glsl-1.10@execution at fs-notequal-of-expression,Fail
 spec at glsl-1.10@execution at fs-sign-times-abs,Fail
 spec at glsl-1.10@execution at fs-sign-times-neg,Fail
 spec at glsl-1.10@execution at fs-sign-times-neg-abs,Fail
 spec at glsl-1.10@execution at fs-sign-times-sign,Fail
 spec at glsl-1.10@execution at gl_lightsource_indirect,Fail
-spec at glsl-1.10@execution at glsl-1.10-built-in-matrix-state,Crash
+spec at glsl-1.10@execution at glsl-1.10-built-in-matrix-state,Fail
 spec at glsl-1.10@execution at glsl-1.10-built-in-uniform-state,Crash
 spec at glsl-1.10@execution at glsl-clamp-vertex-color,Fail
 spec at glsl-1.10@execution at glsl-fs-convolution-1,Fail
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
index 4f4b2ea020b..6c8291f76bf 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -844,24 +844,29 @@ i915_translate_token(struct i915_fp_compile *p,
 
    case TGSI_TOKEN_TYPE_DECLARATION:
       if (token->FullDeclaration.Declaration.File == TGSI_FILE_CONSTANT) {
-         uint32_t i;
-         for (i = token->FullDeclaration.Range.First;
-              i <=
-              MIN2(token->FullDeclaration.Range.Last, I915_MAX_CONSTANT - 1);
-              i++) {
-            ifs->constant_flags[i] = I915_CONSTFLAG_USER;
-            ifs->num_constants = MAX2(ifs->num_constants, i + 1);
+         if (token->FullDeclaration.Range.Last >= I915_MAX_CONSTANT) {
+            i915_program_error(p, "Exceeded %d max uniforms",
+                               I915_MAX_CONSTANT);
+         } else {
+            uint32_t i;
+            for (i = token->FullDeclaration.Range.First;
+                 i <= token->FullDeclaration.Range.Last; i++) {
+               ifs->constant_flags[i] = I915_CONSTFLAG_USER;
+               ifs->num_constants = MAX2(ifs->num_constants, i + 1);
+            }
          }
       } else if (token->FullDeclaration.Declaration.File ==
                  TGSI_FILE_TEMPORARY) {
-         uint32_t i;
-         for (i = token->FullDeclaration.Range.First;
-              i <= token->FullDeclaration.Range.Last; i++) {
-            if (i >= I915_MAX_TEMPORARY)
-               debug_printf("Too many temps (%d)\n", i);
-            else
+         if (token->FullDeclaration.Range.Last >= I915_MAX_TEMPORARY) {
+            i915_program_error(p, "Exceeded %d max TGSI temps",
+                               I915_MAX_TEMPORARY);
+         } else {
+            uint32_t i;
+            for (i = token->FullDeclaration.Range.First;
+                 i <= token->FullDeclaration.Range.Last; i++) {
                /* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
                p->temp_flag |= (1 << i); /* mark temp as used */
+            }
          }
       }
       break;
@@ -893,6 +898,10 @@ i915_translate_token(struct i915_fp_compile *p,
                   break;
                }
             }
+            if (j == I915_MAX_CONSTANT) {
+               i915_program_error(p, "Exceeded %d max uniforms and immediates.",
+                                  I915_MAX_CONSTANT);
+            }
          }
 
          p->first_instruction = false;



More information about the mesa-commit mailing list