Browse Source

workaround the shape specialization constant not respected properly in padding reflect mode on nvidia gpu

tags/20200727
nihui 6 years ago
parent
commit
dfee9a75ea
3 changed files with 20 additions and 7 deletions
  1. +8
    -3
      src/layer/vulkan/shader/padding.comp
  2. +6
    -2
      src/layer/vulkan/shader/padding_pack4.comp
  3. +6
    -2
      src/layer/vulkan/shader/padding_pack8.comp

+ 8
- 3
src/layer/vulkan/shader/padding.comp View File

@@ -134,9 +134,14 @@ void main()
x = abs(x);
y = abs(y);
z = abs(z);
x = (psc(w) - 1) - abs(x - (psc(w) - 1));
y = (psc(h) - 1) - abs(y - (psc(h) - 1));
z = (psc(c) - 1) - abs(z - (psc(c) - 1));
// NOTE psc(X) get zeros on nvidia
// TODO only enable this workaround for some nvidia driver
x = (p.w - 1) - abs(x - (p.w - 1));
y = (p.h - 1) - abs(y - (p.h - 1));
z = (p.c - 1) - abs(z - (p.c - 1));
// x = (psc(w) - 1) - abs(x - (psc(w) - 1));
// y = (psc(h) - 1) - abs(y - (psc(h) - 1));
// z = (psc(c) - 1) - abs(z - (psc(c) - 1));

#if NCNN_image_shader
image3d_cp1(top_blob, ivec3(gx, gy, gz), bottom_blob, ivec3(x, y, z));


+ 6
- 2
src/layer/vulkan/shader/padding_pack4.comp View File

@@ -131,8 +131,12 @@ void main()
{
x = abs(x);
y = abs(y);
x = (psc(w) - 1) - abs(x - (psc(w) - 1));
y = (psc(h) - 1) - abs(y - (psc(h) - 1));
// NOTE psc(X) get zeros on nvidia
// TODO only enable this workaround for some nvidia driver
x = (p.w - 1) - abs(x - (p.w - 1));
y = (p.h - 1) - abs(y - (p.h - 1));
// x = (psc(w) - 1) - abs(x - (psc(w) - 1));
// y = (psc(h) - 1) - abs(y - (psc(h) - 1));

#if NCNN_image_shader
image3d_cp4(top_blob, ivec3(gx, gy, gz), bottom_blob, ivec3(x, y, gz));


+ 6
- 2
src/layer/vulkan/shader/padding_pack8.comp View File

@@ -133,8 +133,12 @@ void main()
{
x = abs(x);
y = abs(y);
x = (psc(w) - 1) - abs(x - (psc(w) - 1));
y = (psc(h) - 1) - abs(y - (psc(h) - 1));
// NOTE psc(X) get zeros on nvidia
// TODO only enable this workaround for some nvidia driver
x = (p.w - 1) - abs(x - (p.w - 1));
y = (p.h - 1) - abs(y - (p.h - 1));
// x = (psc(w) - 1) - abs(x - (psc(w) - 1));
// y = (psc(h) - 1) - abs(y - (psc(h) - 1));

#if NCNN_image_shader
image3d_cp8(top_blob, ivec3(gx, gy, gz), bottom_blob, ivec3(x, y, gz));


Loading…
Cancel
Save