panfrost: Clamp point size
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 18:30:00 +0000 (11:30 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 10 Jul 2019 18:30:00 +0000 (11:30 -0700)
It's not clear the hardware really has a maximum which confuses dEQP;
clamp to whatever we report as our maximum.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/ci/expected-failures.txt
src/gallium/drivers/panfrost/meson.build
src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c [new file with mode: 0644]
src/gallium/drivers/panfrost/pan_screen.c
src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c

index 6f52773cc73430b2afdc345e34d63db8d5a66311..e76ef331a134875527f2e0d6c0041a8550fc2eb6 100644 (file)
@@ -252,7 +252,6 @@ dEQP-GLES2.functional.polygon_offset.fixed16_enable
 dEQP-GLES2.functional.polygon_offset.fixed16_render_with_factor
 dEQP-GLES2.functional.polygon_offset.fixed16_render_with_units
 dEQP-GLES2.functional.polygon_offset.fixed16_result_depth_clamp
-dEQP-GLES2.functional.rasterization.limits.points
 dEQP-GLES2.functional.shaders.builtin_variable.fragcoord_w
 dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_fragment
 dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.line_2_vertex
index 7fdbddc026828035be285c33e13b4557e613ce7b..03dd4f5c20ae8dce2fc3ca8192ef715d039c48aa 100644 (file)
@@ -29,6 +29,7 @@ files_panfrost = files(
   'nir/nir_undef_to_zero.c',
   'nir/nir_lower_blend.c',
   'nir/nir_lower_framebuffer.c',
+  'nir/nir_clamp_psiz.c',
 
   'pan_context.c',
   'pan_afbc.c',
diff --git a/src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c b/src/gallium/drivers/panfrost/nir/nir_clamp_psiz.c
new file mode 100644 (file)
index 0000000..fb42406
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2019 Collabora, Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * @file
+ *
+ * Clamps writes to VARYING_SLOT_PSIZ to a given limit.
+ */
+
+#include "compiler/nir/nir.h"
+#include "compiler/nir/nir_builder.h"
+
+void
+nir_clamp_psiz(nir_shader *shader, float min_size, float max_size);
+
+void
+nir_clamp_psiz(nir_shader *shader, float min_size, float max_size)
+{
+   nir_foreach_function(func, shader) {
+      nir_foreach_block(block, func->impl) {
+         nir_foreach_instr_safe(instr, block) {
+            if (instr->type != nir_instr_type_intrinsic)
+               continue;
+
+            nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+            if (intr->intrinsic != nir_intrinsic_store_deref)
+               continue;
+
+            nir_variable *var = nir_intrinsic_get_var(intr, 0);
+            if (var->data.location != VARYING_SLOT_PSIZ)
+               continue;
+
+            nir_builder b;
+            nir_builder_init(&b, func->impl);
+            b.cursor = nir_before_instr(instr);
+
+            nir_ssa_def *in_size = nir_ssa_for_src(&b, intr->src[1], 1);
+
+            nir_ssa_def *clamped =
+               nir_fmin(&b,
+                        nir_fmax(&b, in_size, nir_imm_float(&b, min_size)),
+                        nir_imm_float(&b, max_size));
+
+            nir_instr_rewrite_src(instr, &intr->src[1],
+                                  nir_src_for_ssa(clamped));
+
+         }
+      }
+
+      nir_metadata_preserve(func->impl, nir_metadata_block_index |
+                            nir_metadata_dominance);
+   }
+}
+
index 9be9bad6693df268fcb00c8470edae7b2adfd1ab..f8a637be850aaa43b8999593a35eb32b8d5fa9c0 100644 (file)
@@ -335,7 +335,7 @@ panfrost_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
 
         /* fall-through */
         case PIPE_CAPF_MAX_POINT_WIDTH_AA:
-                return 255.0; /* arbitrary */
+                return 1024.0;
 
         case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
                 return 16.0;
index 79fe7dfc78ac9215434290c31c2edce7bb144454..59176f3c0ee2d20385281681e40b4e8c6610ea54 100644 (file)
@@ -448,9 +448,12 @@ void emit_binary_bundle(
         struct util_dynarray *emission,
         int next_tag);
 
-/* NIR stuff */
+/* NIR stuff. TODO: Move? Share? Something? */
 
 bool
 nir_undef_to_zero(nir_shader *shader);
 
+void
+nir_clamp_psiz(nir_shader *shader, float min_size, float max_size);
+
 #endif
index 9c1349094bdbd048415d90cc9829db3b4f3bd1f7..5eb61455a75153e05bb1644adb7dd84fc1fb737c 100644 (file)
@@ -2596,8 +2596,10 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl
 
         NIR_PASS_V(nir, nir_lower_vars_to_ssa);
 
-        if (ctx->stage == MESA_SHADER_VERTEX)
+        if (ctx->stage == MESA_SHADER_VERTEX) {
                 NIR_PASS_V(nir, nir_lower_viewport_transform);
+                NIR_PASS_V(nir, nir_clamp_psiz, 1.0, 1024.0);
+        }
 
         NIR_PASS_V(nir, nir_lower_var_copies);
         NIR_PASS_V(nir, nir_lower_vars_to_ssa);