[Mesa-dev] [PATCH] gallium: Add support for frame_cropping_flag of VAEncSequenceParameterBufferH264

2019-04-07 Thread Sahu, Satyajit
From: suresh guttula 

This patch will add support for frame_cropping when the input size is not
matched with aligned size. Currently vaapi driver ignores frame cropping
values provided by client. This change will update SPS nalu with proper
cropping values.

Signed-off-by: suresh guttula 
Signed-off-by: Satyajit Sahu 
---
 src/gallium/drivers/radeon/radeon_vce_52.c   | 8 ++--
 src/gallium/include/pipe/p_video_state.h | 5 +
 src/gallium/state_trackers/va/picture_h264_enc.c | 8 
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_vce_52.c 
b/src/gallium/drivers/radeon/radeon_vce_52.c
index fc7ddc62a90..593730756d5 100644
--- a/src/gallium/drivers/radeon/radeon_vce_52.c
+++ b/src/gallium/drivers/radeon/radeon_vce_52.c
@@ -81,8 +81,12 @@ static void get_pic_control_param(struct rvce_encoder *enc, 
struct pipe_h264_enc
unsigned encNumMBsPerSlice;
encNumMBsPerSlice = align(enc->base.width, 16) / 16;
encNumMBsPerSlice *= align(enc->base.height, 16) / 16;
-   enc->enc_pic.pc.enc_crop_right_offset = (align(enc->base.width, 16) - 
enc->base.width) >> 1;
-   enc->enc_pic.pc.enc_crop_bottom_offset = (align(enc->base.height, 16) - 
enc->base.height) >> 1;
+   if (pic->pic_ctrl.enc_frame_cropping_flag) {
+   enc->enc_pic.pc.enc_crop_left_offset = 
pic->pic_ctrl.enc_frame_crop_left_offset;
+   enc->enc_pic.pc.enc_crop_right_offset = 
pic->pic_ctrl.enc_frame_crop_right_offset;
+   enc->enc_pic.pc.enc_crop_top_offset = 
pic->pic_ctrl.enc_frame_crop_top_offset;
+   enc->enc_pic.pc.enc_crop_bottom_offset = 
pic->pic_ctrl.enc_frame_crop_bottom_offset;
+   }
enc->enc_pic.pc.enc_num_mbs_per_slice = encNumMBsPerSlice;
enc->enc_pic.pc.enc_b_pic_pattern = MAX2(enc->base.max_references, 1) - 
1;
enc->enc_pic.pc.enc_number_of_reference_frames = 
MIN2(enc->base.max_references, 2);
diff --git a/src/gallium/include/pipe/p_video_state.h 
b/src/gallium/include/pipe/p_video_state.h
index 05855a36e23..1369f1a8ca6 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -395,6 +395,11 @@ struct pipe_h264_enc_pic_control
 {
unsigned enc_cabac_enable;
unsigned enc_constraint_set_flags;
+   unsigned enc_frame_cropping_flag;
+   unsigned enc_frame_crop_left_offset;
+   unsigned enc_frame_crop_right_offset;
+   unsigned enc_frame_crop_top_offset;
+   unsigned enc_frame_crop_bottom_offset;
 };
 
 struct pipe_h264_enc_picture_desc
diff --git a/src/gallium/state_trackers/va/picture_h264_enc.c 
b/src/gallium/state_trackers/va/picture_h264_enc.c
index abfd39633de..f46b3425566 100644
--- a/src/gallium/state_trackers/va/picture_h264_enc.c
+++ b/src/gallium/state_trackers/va/picture_h264_enc.c
@@ -127,6 +127,14 @@ vlVaHandleVAEncSequenceParameterBufferTypeH264(vlVaDriver 
*drv, vlVaContext *con
context->desc.h264enc.rate_ctrl.frame_rate_num = h264->time_scale / 2;
context->desc.h264enc.rate_ctrl.frame_rate_den = h264->num_units_in_tick;
context->desc.h264enc.pic_order_cnt_type = 
h264->seq_fields.bits.pic_order_cnt_type;
+
+   if (h264->frame_cropping_flag) {
+  context->desc.h264enc.pic_ctrl.enc_frame_cropping_flag = 
h264->frame_cropping_flag;
+  context->desc.h264enc.pic_ctrl.enc_frame_crop_left_offset = 
h264->frame_crop_left_offset;
+  context->desc.h264enc.pic_ctrl.enc_frame_crop_right_offset = 
h264->frame_crop_right_offset;
+  context->desc.h264enc.pic_ctrl.enc_frame_crop_top_offset = 
h264->frame_crop_top_offset;
+  context->desc.h264enc.pic_ctrl.enc_frame_crop_bottom_offset = 
h264->frame_crop_bottom_offset;
+   }
return VA_STATUS_SUCCESS;
 }
 
-- 
2.19.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH v2 1/2] nir: Add nir_lower_viewport_transform

2019-04-07 Thread Alyssa Rosenzweig
On Mali hardware (supported by Panfrost and Lima), the fixed-function
transformation from world-space to screen-space coordinates is done in
the vertex shader prior to writing out the gl_Position varying, rather
than in dedicated hardware. This commit adds a shared NIR pass for
implementing coordinate transformation and lowering gl_Position writes
into screen-space gl_Position writes.

v2: Run directly on derefs before io/vars are lowered to cleanup the
code substantially. Thank you to Qiang for this suggestion!

Signed-off-by: Alyssa Rosenzweig 
Suggested-by: Qiang Yu 
Cc: Jason Ekstrand 
Cc: Eric Anholt 
---
 src/compiler/nir/meson.build  |  1 +
 src/compiler/nir/nir.h|  1 +
 .../nir/nir_lower_viewport_transform.c| 98 +++
 3 files changed, 100 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_viewport_transform.c

diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index c65f2ff62ff..c274361bdc4 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -151,6 +151,7 @@ files_libnir = files(
   'nir_lower_vars_to_ssa.c',
   'nir_lower_var_copies.c',
   'nir_lower_vec_to_movs.c',
+  'nir_lower_viewport_transform.c',
   'nir_lower_wpos_center.c',
   'nir_lower_wpos_ytransform.c',
   'nir_lower_bit_size.c',
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index bc72d8f83f5..0f6ed734efa 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3124,6 +3124,7 @@ void nir_lower_io_to_scalar(nir_shader *shader, 
nir_variable_mode mask);
 void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask);
 bool nir_lower_io_to_vector(nir_shader *shader, nir_variable_mode mask);
 
+void nir_lower_viewport_transform(nir_shader *shader);
 bool nir_lower_uniforms_to_ubo(nir_shader *shader, int multiplier);
 
 typedef struct nir_lower_subgroups_options {
diff --git a/src/compiler/nir/nir_lower_viewport_transform.c 
b/src/compiler/nir/nir_lower_viewport_transform.c
new file mode 100644
index 000..9646b72c053
--- /dev/null
+++ b/src/compiler/nir/nir_lower_viewport_transform.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2019 Alyssa Rosenzweig
+ *
+ * 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.
+ */
+
+/* On some hardware (particularly, all current versions of Mali GPUs),
+ * vertex shaders do not output gl_Position in world-space. Instead, they
+ * output gl_Position in transformed screen space via the "pseudo"
+ * position varying. Thus, this pass finds writes to gl_Position and
+ * changes them to transformed writes, still to gl_Position. The
+ * outputted screen space is still written back to VARYING_SLOT_POS,
+ * which is semantically ambiguous but nevertheless a good match for
+ * Gallium/NIR/Mali.
+ *
+ * Implements coordinate transformation as defined in section 12.5
+ * "Coordinate Transformation" of the OpenGL ES 3.2 full specification.
+ *
+ * This pass must run before lower_vars/lower_io such that derefs are
+ * still in place.
+ */
+
+#include "nir/nir.h"
+#include "nir/nir_builder.h"
+
+void
+nir_lower_viewport_transform(nir_shader *shader)
+{
+   assert(shader->info.stage == MESA_SHADER_VERTEX);
+
+   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_POS) continue;
+
+nir_builder b;
+nir_builder_init(, func->impl);
+b.cursor = nir_before_instr(instr);
+
+/* Grab the source and viewport */
+nir_ssa_def *input_point = 

[Mesa-dev] [PATCH v2 2/2] panfrost/midgard: Use shared nir_lower_viewport_transform

2019-04-07 Thread Alyssa Rosenzweig
v2: Run before lowering I/O.

Signed-off-by: Alyssa Rosenzweig 
---
 .../panfrost/midgard/midgard_compile.c| 105 +-
 1 file changed, 4 insertions(+), 101 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c 
b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index f91fa972246..5216cc124fa 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -3059,100 +3059,6 @@ actualise_ssa_to_alias(compiler_context *ctx)
 emit_leftover_move(ctx);
 }
 
-/* Vertex shaders do not write gl_Position as is; instead, they write a
- * transformed screen space position as a varying. See section 12.5 "Coordinate
- * Transformation" of the ES 3.2 full specification for details.
- *
- * This transformation occurs early on, as NIR and prior to optimisation, in
- * order to take advantage of NIR optimisation passes of the transform itself.
- * */
-
-static void
-write_transformed_position(nir_builder *b, nir_src input_point_src)
-{
-nir_ssa_def *input_point = nir_ssa_for_src(b, input_point_src, 4);
-nir_ssa_def *scale = nir_load_viewport_scale(b);
-nir_ssa_def *offset = nir_load_viewport_offset(b);
-
-/* World space to normalised device coordinates to screen space */
-
-nir_ssa_def *w_recip = nir_frcp(b, nir_channel(b, input_point, 3));
-nir_ssa_def *ndc_point = nir_fmul(b, nir_channels(b, input_point, 
0x7), w_recip);
-nir_ssa_def *screen = nir_fadd(b, nir_fmul(b, ndc_point, scale), 
offset);
-
-/* gl_Position will be written out in screenspace xyz, with w set to
- * the reciprocal we computed earlier. The transformed w component is
- * then used for perspective-correct varying interpolation. The
- * transformed w component must preserve its original sign; this is
- * used in depth clipping computations */
-
-nir_ssa_def *screen_space = nir_vec4(b,
- nir_channel(b, screen, 0),
- nir_channel(b, screen, 1),
- nir_channel(b, screen, 2),
- w_recip);
-
-/* Finally, write out the transformed values to the varying */
-
-nir_intrinsic_instr *store;
-store = nir_intrinsic_instr_create(b->shader, 
nir_intrinsic_store_output);
-store->num_components = 4;
-nir_intrinsic_set_base(store, 0);
-nir_intrinsic_set_write_mask(store, 0xf);
-store->src[0].ssa = screen_space;
-store->src[0].is_ssa = true;
-store->src[1] = nir_src_for_ssa(nir_imm_int(b, 0));
-nir_builder_instr_insert(b, >instr);
-}
-
-static void
-transform_position_writes(nir_shader *shader)
-{
-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);
-nir_variable *out = NULL;
-
-switch (intr->intrinsic) {
-case nir_intrinsic_store_output:
-/* already had i/o lowered.. lookup 
the matching output var: */
-nir_foreach_variable(var, 
>outputs) {
-int drvloc = 
var->data.driver_location;
-
-if (nir_intrinsic_base(intr) 
== drvloc) {
-out = var;
-break;
-}
-}
-
-break;
-
-default:
-break;
-}
-
-if (!out) continue;
-
-if (out->data.mode != nir_var_shader_out)
-continue;
-
-if (out->data.location != VARYING_SLOT_POS)
-continue;
-
-nir_builder b;
-nir_builder_init(, func->impl);
-b.cursor = nir_before_instr(instr);
-
-write_transformed_position(, intr->src[0]);
-nir_instr_remove(instr);
-}
-}
-}
-}
-
 static void
 emit_fragment_epilogue(compiler_context *ctx)
 {
@@ -3522,7 +3428,10 @@ midgard_compile_shader_nir(nir_shader *nir, 

[Mesa-dev] [PATCH v2 0/2] NIR viewport lowering

2019-04-07 Thread Alyssa Rosenzweig
This adds a lowering pass for transforming gl_Position to screenspace.
Previously, the pass lived inside the Panfrost (Midgard) compiler, but
now that Lima is en route to the tree, it's best we share it (Lima
developed a separate machine-IR-based transform, but we can share the
code as NIR).

We're careful to vectorize everything as well (related to last week's
sysval patch), to ensure good performance on Midgard (a vector arch).

This might be helpful for either GPUs too; I'm not sure.

v2: Cleanup considerably by running before IO/var lowering.

Alyssa Rosenzweig (2):
  nir: Add nir_lower_viewport_transform
  panfrost/midgard: Use shared nir_lower_viewport_transform

 src/compiler/nir/meson.build  |   1 +
 src/compiler/nir/nir.h|   1 +
 .../nir/nir_lower_viewport_transform.c|  98 
 .../panfrost/midgard/midgard_compile.c| 105 +-
 4 files changed, 104 insertions(+), 101 deletions(-)
 create mode 100644 src/compiler/nir/nir_lower_viewport_transform.c

-- 
2.20.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [Bug 110261] Segmentation fault when using vulkaninfo on Radeon

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110261

--- Comment #7 from Kenneth Endfinger  ---
Oddly enough, with vulkan-tools 1.1.102:

/build/vulkan-tools/src/Vulkan-Tools-1.1.102/vulkaninfo/vulkaninfo.c:4504:
failed with VK_ERROR_OUT_OF_HOST_MEMORY

is now the error...

-- 
You are receiving this mail because:
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [Bug 110261] Segmentation fault when using vulkaninfo on Radeon

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110261

--- Comment #6 from Kenneth Endfinger  ---
Is this what you are looking for?

(gdb) thread apply all backtrace

Thread 2 (Thread 0x738f8700 (LWP 8010)):
#0  0x77ba7afc in pthread_cond_wait@@GLIBC_2.3.2 () from
/usr/lib/libpthread.so.0
#1  0x75669e24 in cnd_wait (mtx=0x556f8208, cond=0x556f8230) at
../mesa-19.0.1/src/../include/c11/threads_posix.h:155
#2  util_queue_thread_func (input=input@entry=0x55723f70) at
../mesa-19.0.1/src/util/u_queue.c:270
#3  0x75669b48 in impl_thrd_routine (p=) at
../mesa-19.0.1/src/../include/c11/threads_posix.h:87
#4  0x77ba1a9d in start_thread () from /usr/lib/libpthread.so.0
#5  0x77cdfb23 in clone () from /usr/lib/libc.so.6

Thread 1 (Thread 0x77a10740 (LWP 8004)):
#0  0x754300f7 in XGetXCBConnection () from /usr/lib/libX11-xcb.so.1
#1  0x7565c961 in x11_surface_get_connection
(icd_surface=0x55a19510) at
../mesa-19.0.1/src/vulkan/wsi/wsi_common_x11.c:404
#2  x11_surface_get_connection (icd_surface=0x55a19510) at
../mesa-19.0.1/src/vulkan/wsi/wsi_common_x11.c:401
#3  x11_surface_get_support (icd_surface=0x55a19510,
wsi_device=0x557428f0, queueFamilyIndex=,
pSupported=0x7fffdef4) at
../mesa-19.0.1/src/vulkan/wsi/wsi_common_x11.c:424
#4  0x555626e3 in AppGpuDumpQueueProps (out=0x77da35c0
<_IO_2_1_stdout_>, id=0, gpu=0x55a1b190) at
/usr/src/debug/Vulkan-Tools-1.1.101/vulkaninfo/vulkaninfo.c:4461
#5  AppGpuDump (gpu=0x55a1b190, out=0x77da35c0 <_IO_2_1_stdout_>) at
/usr/src/debug/Vulkan-Tools-1.1.101/vulkaninfo/vulkaninfo.c:4764
#6  0x7f24 in main (argc=, argv=) at
/usr/src/debug/Vulkan-Tools-1.1.101/vulkaninfo/vulkaninfo.c:5328

-- 
You are receiving this mail because:
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Re: [Mesa-dev] [PATCH 1/2] nir: Add nir_lower_viewport_transform

2019-04-07 Thread Qiang Yu
On Mon, Apr 8, 2019 at 12:41 AM Alyssa Rosenzweig  wrote:
>
> On Mali hardware (supported by Panfrost and Lima), the fixed-function
> transformation from world-space to screen-space coordinates is done in
> the vertex shader prior to writing out the gl_Position varying, rather
> than in dedicated hardware. This commit adds a shared NIR pass for
> implementing coordinate transformation and lowering gl_Position writes
> into screen-space gl_Position writes.
>
> Signed-off-by: Alyssa Rosenzweig 
> Suggested-by: Qiang Yu 
> Cc: Jason Ekstrand 
> Cc: Eric Anholt 
> ---
>  src/compiler/nir/meson.build  |   1 +
>  src/compiler/nir/nir.h|   1 +
>  .../nir/nir_lower_viewport_transform.c| 126 ++
>  3 files changed, 128 insertions(+)
>  create mode 100644 src/compiler/nir/nir_lower_viewport_transform.c
>
> diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
> index c65f2ff62ff..c274361bdc4 100644
> --- a/src/compiler/nir/meson.build
> +++ b/src/compiler/nir/meson.build
> @@ -151,6 +151,7 @@ files_libnir = files(
>'nir_lower_vars_to_ssa.c',
>'nir_lower_var_copies.c',
>'nir_lower_vec_to_movs.c',
> +  'nir_lower_viewport_transform.c',
>'nir_lower_wpos_center.c',
>'nir_lower_wpos_ytransform.c',
>'nir_lower_bit_size.c',
> diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
> index bc72d8f83f5..0f6ed734efa 100644
> --- a/src/compiler/nir/nir.h
> +++ b/src/compiler/nir/nir.h
> @@ -3124,6 +3124,7 @@ void nir_lower_io_to_scalar(nir_shader *shader, 
> nir_variable_mode mask);
>  void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode 
> mask);
>  bool nir_lower_io_to_vector(nir_shader *shader, nir_variable_mode mask);
>
> +void nir_lower_viewport_transform(nir_shader *shader);
>  bool nir_lower_uniforms_to_ubo(nir_shader *shader, int multiplier);
>
>  typedef struct nir_lower_subgroups_options {
> diff --git a/src/compiler/nir/nir_lower_viewport_transform.c 
> b/src/compiler/nir/nir_lower_viewport_transform.c
> new file mode 100644
> index 000..34a248d5871
> --- /dev/null
> +++ b/src/compiler/nir/nir_lower_viewport_transform.c
> @@ -0,0 +1,126 @@
> +/*
> + * Copyright (C) 2019 Alyssa Rosenzweig
> + *
> + * 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.
> + */
> +
> +/* On some hardware (particularly, all current versions of Mali GPUs),
> + * vertex shaders do not output gl_Position in world-space. Instead, they
> + * output gl_Position in transformed screen space via the "pseudo"
> + * position varying. Thus, this pass finds writes to gl_Position and
> + * changes them to transformed writes, still to gl_Position. The
> + * outputted screen space is still written back to VARYING_SLOT_POS,
> + * which is semantically ambiguous but nevertheless a good match for
> + * Gallium/NIR/Mali.
> + *
> + * Implements coordinate transformation as defined in section 12.5
> + * "Coordinate Transformation" of the OpenGL ES 3.2 full specification.
> + */
> +
> +#include "nir/nir.h"
> +#include "nir/nir_builder.h"
> +
> +static void write_transformed_position(nir_builder *b, nir_src
> +  input_point_src)
> +{
> +   nir_ssa_def *input_point = nir_ssa_for_src(b, input_point_src, 4);
> +   nir_ssa_def *scale = nir_load_viewport_scale(b);
> +   nir_ssa_def *offset = nir_load_viewport_offset(b);
> +
> +   /* World space to normalised device coordinates to screen space */
> +
> +   nir_ssa_def *w_recip = nir_frcp(b, nir_channel(b, input_point, 3));
> +   nir_ssa_def *ndc_point = nir_fmul(b, nir_channels(b, input_point, 0x7), 
> w_recip);
> +   nir_ssa_def *screen = nir_fadd(b, nir_fmul(b, ndc_point, scale), offset);
> +
> +   /* gl_Position will be written out in screenspace xyz, with w set to
> +* the reciprocal we computed earlier. The transformed w component is
> +* then used for perspective-correct varying 

[Mesa-dev] [Bug 110349] radv: Dragon Quest XI (DXVK) has a graphical glitch (regression, bisected)

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110349

Bug ID: 110349
   Summary: radv: Dragon Quest XI (DXVK) has a graphical glitch
(regression, bisected)
   Product: Mesa
   Version: git
  Hardware: x86-64 (AMD64)
OS: Linux (All)
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Vulkan/radeon
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: asheldo...@gmail.com
QA Contact: mesa-dev@lists.freedesktop.org

When running Dragon Quest XI with DXVK, a graphical glitch can be seen. The
glitch tends to flicker in and out from a distance, but once you get closer, it
remains static. I've only tested it at one location, so I can't say if it
appears elsewhere. Here's a screenshot: https://imgur.com/a/v7RnxE9

The first bad commit is a66b186bebf9b63897199b9b6e26d40977417f74:

Author: Samuel Pitoiset 
Date:   Tue Feb 26 13:42:28 2019 +0100

radv: use typed buffer loads for vertex input fetches

This drastically reduces the number of SGPRs because the driver
now uses descriptors per vertex binding, instead of per vertex
attribute format.

29077 shaders in 15096 tests
Totals:
SGPRS: 1354285 -> 1282109 (-5.33 %)
VGPRS: 909896 -> 908800 (-0.12 %)
Spilled SGPRs: 24840 -> 24811 (-0.12 %)
Code Size: 49221144 -> 48986628 (-0.48 %) bytes
Max Waves: 243930 -> 244229 (0.12 %)

Totals from affected shaders:
SGPRS: 390648 -> 318472 (-18.48 %)
VGPRS: 288432 -> 287336 (-0.38 %)
Spilled SGPRs: 94 -> 65 (-30.85 %)
Code Size: 11548412 -> 11313896 (-2.03 %) bytes
Max Waves: 86460 -> 86759 (0.35 %)

This gives a really tiny boost.

Signed-off-by: Samuel Pitoiset 
Reviewed-by: Bas Nieuwenhuizen 

Reverting the commit fixes the glitch. The glitch also doesn't exist when using
AMDVLK.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [Bug 110348] radv: Resolve attachments do not work if view format differs from image format

2019-04-07 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=110348

Bug ID: 110348
   Summary: radv: Resolve attachments do not work if view format
differs from image format
   Product: Mesa
   Version: git
  Hardware: Other
OS: All
Status: NEW
  Severity: normal
  Priority: medium
 Component: Drivers/Vulkan/radeon
  Assignee: mesa-dev@lists.freedesktop.org
  Reporter: philip.rebo...@tu-dortmund.de
QA Contact: mesa-dev@lists.freedesktop.org

Created attachment 143889
  --> https://bugs.freedesktop.org/attachment.cgi?id=143889=edit
Probably incomplete fix

Hello,

using resolve attachments where the image view format differs from the actual
image format sometimes leads to incorrect or garbled results. The following
renderdoc capture (recorded on Polaris 10) shows one such example:

https://mega.nz/#!FeoBSKBS!AaXSH5e_VTs05s7_xStBVB-ptbl-C_lGx7854Apel8o

Here, the image format is R16G16B16A16_UNORM, while the view format is
R16G16B16A16_SFLOAT. The resolved image is garbled.

Playing around in the code, I observed the following:
- The HW path is the one that's used here and produces the broken image.
- The CS path works, but interprets image data using the image format, not the
view format.
- The FS path works and uses the view format.

The attached patch fixes the problem for this sample, but more work is likely
needed since radv_pick_resolve_method_images currently only takes the image
format into account as well.

I'm also not sure which format should actually be used for the resolve
operation; both AMDVLK and Nvidia use the image format and not the view format,
which is not what I need, and it doesn't look like the Vulkan spec actually
defines this.

- Philip

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 0/2] Implement coordinate transformation

2019-04-07 Thread Alyssa Rosenzweig
This adds a lowering pass for transforming gl_Position to screenspace.
Previously, the pass lived inside the Panfrost (Midgard) compiler, but
now that Lima is en route to the tree, it's best we share it (Lima
developed a separate machine-IR-based transform, but we can share the
code as NIR).

We're careful to vectorize everything as well (related to last week's
sysval patch), to ensure good performance on Midgard (a vector arch).

This might be helpful for either GPUs too; I'm not sure.

Alyssa Rosenzweig (2):
  nir: Add nir_lower_viewport_transform
  panfrost/midgard: Use shared nir_lower_viewport_transform

 src/compiler/nir/meson.build  |   1 +
 src/compiler/nir/nir.h|   1 +
 .../nir/nir_lower_viewport_transform.c| 126 ++
 .../panfrost/midgard/midgard_compile.c|  99 +-
 4 files changed, 130 insertions(+), 97 deletions(-)
 create mode 100644 src/compiler/nir/nir_lower_viewport_transform.c

-- 
2.20.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

[Mesa-dev] [PATCH 1/2] nir: Add nir_lower_viewport_transform

2019-04-07 Thread Alyssa Rosenzweig
On Mali hardware (supported by Panfrost and Lima), the fixed-function
transformation from world-space to screen-space coordinates is done in
the vertex shader prior to writing out the gl_Position varying, rather
than in dedicated hardware. This commit adds a shared NIR pass for
implementing coordinate transformation and lowering gl_Position writes
into screen-space gl_Position writes.

Signed-off-by: Alyssa Rosenzweig 
Suggested-by: Qiang Yu 
Cc: Jason Ekstrand 
Cc: Eric Anholt 
---
 src/compiler/nir/meson.build  |   1 +
 src/compiler/nir/nir.h|   1 +
 .../nir/nir_lower_viewport_transform.c| 126 ++
 3 files changed, 128 insertions(+)
 create mode 100644 src/compiler/nir/nir_lower_viewport_transform.c

diff --git a/src/compiler/nir/meson.build b/src/compiler/nir/meson.build
index c65f2ff62ff..c274361bdc4 100644
--- a/src/compiler/nir/meson.build
+++ b/src/compiler/nir/meson.build
@@ -151,6 +151,7 @@ files_libnir = files(
   'nir_lower_vars_to_ssa.c',
   'nir_lower_var_copies.c',
   'nir_lower_vec_to_movs.c',
+  'nir_lower_viewport_transform.c',
   'nir_lower_wpos_center.c',
   'nir_lower_wpos_ytransform.c',
   'nir_lower_bit_size.c',
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index bc72d8f83f5..0f6ed734efa 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3124,6 +3124,7 @@ void nir_lower_io_to_scalar(nir_shader *shader, 
nir_variable_mode mask);
 void nir_lower_io_to_scalar_early(nir_shader *shader, nir_variable_mode mask);
 bool nir_lower_io_to_vector(nir_shader *shader, nir_variable_mode mask);
 
+void nir_lower_viewport_transform(nir_shader *shader);
 bool nir_lower_uniforms_to_ubo(nir_shader *shader, int multiplier);
 
 typedef struct nir_lower_subgroups_options {
diff --git a/src/compiler/nir/nir_lower_viewport_transform.c 
b/src/compiler/nir/nir_lower_viewport_transform.c
new file mode 100644
index 000..34a248d5871
--- /dev/null
+++ b/src/compiler/nir/nir_lower_viewport_transform.c
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2019 Alyssa Rosenzweig
+ *
+ * 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.
+ */
+
+/* On some hardware (particularly, all current versions of Mali GPUs),
+ * vertex shaders do not output gl_Position in world-space. Instead, they
+ * output gl_Position in transformed screen space via the "pseudo"
+ * position varying. Thus, this pass finds writes to gl_Position and
+ * changes them to transformed writes, still to gl_Position. The
+ * outputted screen space is still written back to VARYING_SLOT_POS,
+ * which is semantically ambiguous but nevertheless a good match for
+ * Gallium/NIR/Mali.
+ *
+ * Implements coordinate transformation as defined in section 12.5
+ * "Coordinate Transformation" of the OpenGL ES 3.2 full specification.
+ */
+
+#include "nir/nir.h"
+#include "nir/nir_builder.h"
+
+static void write_transformed_position(nir_builder *b, nir_src
+  input_point_src)
+{
+   nir_ssa_def *input_point = nir_ssa_for_src(b, input_point_src, 4);
+   nir_ssa_def *scale = nir_load_viewport_scale(b);
+   nir_ssa_def *offset = nir_load_viewport_offset(b);
+
+   /* World space to normalised device coordinates to screen space */
+
+   nir_ssa_def *w_recip = nir_frcp(b, nir_channel(b, input_point, 3));
+   nir_ssa_def *ndc_point = nir_fmul(b, nir_channels(b, input_point, 0x7), 
w_recip);
+   nir_ssa_def *screen = nir_fadd(b, nir_fmul(b, ndc_point, scale), offset);
+
+   /* gl_Position will be written out in screenspace xyz, with w set to
+* the reciprocal we computed earlier. The transformed w component is
+* then used for perspective-correct varying interpolation. The
+* transformed w component must preserve its original sign; this is
+* used in depth clipping computations */
+
+   nir_ssa_def *screen_space = nir_vec4(b,
+nir_channel(b, screen, 0),
+nir_channel(b, 

[Mesa-dev] [PATCH 2/2] panfrost/midgard: Use shared nir_lower_viewport_transform

2019-04-07 Thread Alyssa Rosenzweig
Signed-off-by: Alyssa Rosenzweig 
---
 .../panfrost/midgard/midgard_compile.c| 99 +--
 1 file changed, 2 insertions(+), 97 deletions(-)

diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.c 
b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
index f91fa972246..a2fc64e9ae4 100644
--- a/src/gallium/drivers/panfrost/midgard/midgard_compile.c
+++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.c
@@ -3059,100 +3059,6 @@ actualise_ssa_to_alias(compiler_context *ctx)
 emit_leftover_move(ctx);
 }
 
-/* Vertex shaders do not write gl_Position as is; instead, they write a
- * transformed screen space position as a varying. See section 12.5 "Coordinate
- * Transformation" of the ES 3.2 full specification for details.
- *
- * This transformation occurs early on, as NIR and prior to optimisation, in
- * order to take advantage of NIR optimisation passes of the transform itself.
- * */
-
-static void
-write_transformed_position(nir_builder *b, nir_src input_point_src)
-{
-nir_ssa_def *input_point = nir_ssa_for_src(b, input_point_src, 4);
-nir_ssa_def *scale = nir_load_viewport_scale(b);
-nir_ssa_def *offset = nir_load_viewport_offset(b);
-
-/* World space to normalised device coordinates to screen space */
-
-nir_ssa_def *w_recip = nir_frcp(b, nir_channel(b, input_point, 3));
-nir_ssa_def *ndc_point = nir_fmul(b, nir_channels(b, input_point, 
0x7), w_recip);
-nir_ssa_def *screen = nir_fadd(b, nir_fmul(b, ndc_point, scale), 
offset);
-
-/* gl_Position will be written out in screenspace xyz, with w set to
- * the reciprocal we computed earlier. The transformed w component is
- * then used for perspective-correct varying interpolation. The
- * transformed w component must preserve its original sign; this is
- * used in depth clipping computations */
-
-nir_ssa_def *screen_space = nir_vec4(b,
- nir_channel(b, screen, 0),
- nir_channel(b, screen, 1),
- nir_channel(b, screen, 2),
- w_recip);
-
-/* Finally, write out the transformed values to the varying */
-
-nir_intrinsic_instr *store;
-store = nir_intrinsic_instr_create(b->shader, 
nir_intrinsic_store_output);
-store->num_components = 4;
-nir_intrinsic_set_base(store, 0);
-nir_intrinsic_set_write_mask(store, 0xf);
-store->src[0].ssa = screen_space;
-store->src[0].is_ssa = true;
-store->src[1] = nir_src_for_ssa(nir_imm_int(b, 0));
-nir_builder_instr_insert(b, >instr);
-}
-
-static void
-transform_position_writes(nir_shader *shader)
-{
-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);
-nir_variable *out = NULL;
-
-switch (intr->intrinsic) {
-case nir_intrinsic_store_output:
-/* already had i/o lowered.. lookup 
the matching output var: */
-nir_foreach_variable(var, 
>outputs) {
-int drvloc = 
var->data.driver_location;
-
-if (nir_intrinsic_base(intr) 
== drvloc) {
-out = var;
-break;
-}
-}
-
-break;
-
-default:
-break;
-}
-
-if (!out) continue;
-
-if (out->data.mode != nir_var_shader_out)
-continue;
-
-if (out->data.location != VARYING_SLOT_POS)
-continue;
-
-nir_builder b;
-nir_builder_init(, func->impl);
-b.cursor = nir_before_instr(instr);
-
-write_transformed_position(, intr->src[0]);
-nir_instr_remove(instr);
-}
-}
-}
-}
-
 static void
 emit_fragment_epilogue(compiler_context *ctx)
 {
@@ -3535,11 +3441,10 @@ midgard_compile_shader_nir(nir_shader *nir, 
midgard_program *program, bool