@DetectSimilarTextures.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /******************************************************************************/
  2. /******************************************************************************/
  3. class DetectSimilarTextures : PropWin
  4. {
  5. static const bool Decompress; // performance was the same for both options, so keep 'Decompress' as false, to be able to process bigger sizes for better precision
  6. static const int MaxTexSize; // a very big project can have ~7000 textures, total memory for that would be (7000*128*128)>>20 = 109 MB when using BC7, which is acceptable memory usage
  7. class Data
  8. {
  9. UID id;
  10. Str name;
  11. void set(C UID &id);
  12. public:
  13. Data();
  14. };
  15. class Pair
  16. {
  17. UID a, b;
  18. void set(C UID &a, C UID &b);
  19. };
  20. class UIDEx : UID
  21. {
  22. bool mtrl_base_1;
  23. public:
  24. UIDEx();
  25. };
  26. class ImageEx
  27. {
  28. bool mtrl_base_1;
  29. Mems<Image> mips; // since we can't lock multiple mip-maps at the same time, we need to store them as separate images
  30. void create(bool mtrl_base_1, C Image &src);
  31. public:
  32. ImageEx();
  33. };
  34. Memc<Data> data;
  35. List<Data> list;
  36. Region region;
  37. Progress progress;
  38. Threads threads;
  39. Thread io_thread;
  40. uintptr io_thread_id;
  41. Memc<UIDEx> proj_texs;
  42. ThreadSafeMap<UID, ImageEx> loaded_texs; // make thread-safe just in case
  43. Memc<Pair> similar_pair;
  44. SyncLock similar_pair_lock;
  45. bool pause;
  46. int compared;
  47. bool mtrl_base_1 ;
  48. flt avg_difference,
  49. similar ,
  50. similar_dif ;
  51. static void CompareImage(UID &a_id, UID &b_id, int thread_index);
  52. static int ImageLoad(ImageHeader &header, C Str &name);
  53. static bool IOThread(Thread &t);
  54. bool ioThread();
  55. static void Changed(C Property &prop);
  56. void reset();
  57. ~DetectSimilarTextures();
  58. void stop2();
  59. void stop();
  60. virtual DetectSimilarTextures& show()override;
  61. virtual DetectSimilarTextures& hide()override;
  62. void clearProj();
  63. void addSimilar(C UID &a, C UID &b);
  64. void addSimilarAll(C UID &a, C UID &b);
  65. virtual Rect sizeLimit()C override;
  66. C Rect& rect()C;
  67. virtual DetectSimilarTextures& rect(C Rect &rect)override;
  68. static void CurChanged(DetectSimilarTextures &dst);
  69. void create();
  70. virtual void update(C GuiPC &gpc)override;
  71. public:
  72. DetectSimilarTextures();
  73. };
  74. /******************************************************************************/
  75. /******************************************************************************/
  76. extern DetectSimilarTextures DST;
  77. /******************************************************************************/