You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

crop.comp 1.7 kB

7 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #version 450
  15. layout (constant_id = 0) const int woffset = 0;
  16. layout (constant_id = 1) const int hoffset = 0;
  17. layout (constant_id = 2) const int coffset = 0;
  18. layout (local_size_x_id = 233) in;
  19. layout (local_size_y_id = 234) in;
  20. layout (local_size_z_id = 235) in;
  21. layout (binding = 0) readonly buffer bottom_blob { float bottom_blob_data[]; };
  22. layout (binding = 1) writeonly buffer top_blob { float top_blob_data[]; };
  23. layout (push_constant) uniform parameter
  24. {
  25. int dims;
  26. int w;
  27. int h;
  28. int c;
  29. int cstep;
  30. int outdims;
  31. int outw;
  32. int outh;
  33. int outc;
  34. int outcstep;
  35. } p;
  36. void main()
  37. {
  38. int gx = int(gl_GlobalInvocationID.x);
  39. int gy = int(gl_GlobalInvocationID.y);
  40. int gz = int(gl_GlobalInvocationID.z);
  41. if (gx >= p.outw || gy >= p.outh || gz >= p.outc)
  42. return;
  43. int x = gx + woffset;
  44. int y = gy + hoffset;
  45. int z = gz + coffset;
  46. int v_offset = z * p.cstep + y * p.w + x;
  47. top_blob_data[gz * p.outcstep + gy * p.outw + gx] = bottom_blob_data[v_offset];
  48. }