Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/AntiDupl/AntiDupl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ typedef ad::TEngine* adEngineHandle;
if(p == NULL) \
return AD_ERROR_INVALID_POINTER;

#define AD_DEBUG(msg) OutputDebugStringA(msg)


BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
Expand Down Expand Up @@ -153,9 +155,14 @@ DLLAPI adEngineHandle adCreateA(const adCharA * userPath)

DLLAPI adEngineHandle adCreateW(const adCharW * userPath)
{
AD_DEBUG("adCreateW: Starting\n");
ad::DumpInit();
AD_DEBUG("adCreateW: DumpInit done\n");

return new ad::TEngine(ad::TString(userPath));
adEngineHandle handle = new ad::TEngine(ad::TString(userPath));
AD_DEBUG("adCreateW: TEngine created\n");

return handle;
}

DLLAPI adError adRelease(adEngineHandle handle)
Expand Down
18 changes: 17 additions & 1 deletion src/AntiDupl/AntiDupl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 12.8.props" />
<PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
Expand Down Expand Up @@ -51,14 +52,22 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_WINDOWS;_USRDLL;ANTIDUPL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WINDOWS;_USRDLL;ANTIDUPL_EXPORTS;ENABLE_CUDA;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings Condition="'$(Platform)'=='x64'">4267</DisableSpecificWarnings>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<AdditionalDependencies>cudart.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
</Link>
<Cudart>
<TargetMachinePlatform>64</TargetMachinePlatform>
</Cudart>
<CudaCompile>
<TargetMachinePlatform>64</TargetMachinePlatform>
<CodeGeneration>compute_89,sm_89</CodeGeneration>
</CudaCompile>
<PreBuildEvent>
<Command>"$(ProjectDir)".\adExternal.cmd</Command>
</PreBuildEvent>
Expand All @@ -78,6 +87,7 @@
<ClCompile Include="adFileUtils.cpp" />
<ClCompile Include="adGdiplus.cpp" />
<ClCompile Include="adHeif.cpp" />
<ClCompile Include="adGPUManager.cpp" />
<ClCompile Include="adHintSetter.cpp" />
<ClCompile Include="adImage.cpp" />
<ClCompile Include="adImageComparer.cpp" />
Expand Down Expand Up @@ -113,6 +123,7 @@
<ClCompile Include="adUndoRedoEngine.cpp" />
<ClCompile Include="adUndoRedoTypes.cpp" />
<ClCompile Include="adWebp.cpp" />
<CudaCompile Include="adGPU.cu" />
<ClCompile Include="AntiDupl.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -128,6 +139,8 @@
<ClInclude Include="adFileStream.h" />
<ClInclude Include="adFileUtils.h" />
<ClInclude Include="adGdiplus.h" />
<ClInclude Include="adGPU.h" />
<ClInclude Include="adGPUManager.h" />
<ClInclude Include="adHeif.h" />
<ClInclude Include="adHintSetter.h" />
<ClInclude Include="adImage.h" />
Expand Down Expand Up @@ -169,4 +182,7 @@
<ClInclude Include="AntiDupl.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 12.8.targets" />
</ImportGroup>
</Project>
4 changes: 2 additions & 2 deletions src/AntiDupl/adConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
#include <limits>

//#define AD_PERFORMANCE_TEST_ENABLE
//#define AD_LOGGER_ENABLE
//#define AD_DUMP_ENABLE
#define AD_LOGGER_ENABLE
#define AD_DUMP_ENABLE
#define AD_TURBO_JPEG_ENABLE

#include "adSimd.h"
Expand Down
44 changes: 41 additions & 3 deletions src/AntiDupl/adDataCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@
#include "adImageUtils.h"
#include "adPixelData.h"
#include "adBlurringDetector.h"
#include "adGPUManager.h"
#include <windows.h>

#define AD_DEBUG(msg) OutputDebugStringA(msg)

namespace ad
{
TDataCollector::TDataCollector(TEngine *pEngine)
:m_pOptions(pEngine->Options()),
:m_pEngine(pEngine),
m_pOptions(pEngine->Options()),
m_pResult(pEngine->Result())
{
for(int size = INITIAL_REDUCED_IMAGE_SIZE; size > m_pOptions->advanced.reducedImageSize; size >>= 1)
Expand Down Expand Up @@ -73,7 +78,7 @@ namespace ad
TImage *pImage = TImage::Load(pImageData->hGlobal, m_pOptions);
if(pImage)
{
pImageData->height = (TUInt32)pImage->View()->height;
pImageData->height = (TUInt32)pImage->View()->height;
pImageData->width = (TUInt32)pImage->View()->width;
pImageData->type = (TImageType)pImage->Format();

Expand All @@ -98,13 +103,46 @@ namespace ad

pImageData->imageExif = pImage->ImageExif();

Simd::ResizeBilinear(gray, *m_pGrayBuffers.front());
Simd::Resize(gray, *m_pGrayBuffers.front());
for(size_t i = 1; i < m_pGrayBuffers.size(); ++i)
Simd::ReduceGray2x2(*m_pGrayBuffers[i - 1], *m_pGrayBuffers[i]);
TPixelData & data = *pImageData->data;
ReduceGray2x2(*m_pGrayBuffers.back(), TView(data.side, data.side, data.side, TView::Gray8, data.main));
data.filled = true;

// Upload thumbnail to GPU — only for non-AllVsAll mode
// In AllVsAll mode, ExecuteGpuAllVsAllComparison does its own mass upload
if (!m_pEngine->SkipComparisonDuringCollection())
{
// Ensure GPU buffer is initialized before first upload
static bool gpuBufferInitialized = false;
if (!gpuBufferInitialized)
{
AD_DEBUG("FillPixelData: Initializing GPU buffer\n");
size_t estimatedCapacity = 10000; // Start with reasonable estimate
size_t thumbSize = m_pOptions->advanced.reducedImageSize * m_pOptions->advanced.reducedImageSize;
if (m_pEngine->GpuManager()->EnsureCapacity(estimatedCapacity, thumbSize))
{
gpuBufferInitialized = true;
AD_DEBUG("FillPixelData: GPU buffer initialized\n");
}
else
{
AD_DEBUG("FillPixelData: GPU buffer initialization FAILED\n");
}
}

// Upload thumbnail to GPU immediately
if (m_pEngine->GpuManager()->UploadThumbnail(pImageData->globalIdx, data.main))
{
// Successfully uploaded
}
else
{
AD_DEBUG("FillPixelData: UploadThumbnail FAILED\n");
}
}

delete pImage;
}
else
Expand Down
1 change: 1 addition & 0 deletions src/AntiDupl/adDataCollector.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace ad
//-------------------------------------------------------------------------
class TDataCollector
{
TEngine *m_pEngine;
TOptions *m_pOptions;
TResultStorage *m_pResult;
std::vector<TView*> m_pGrayBuffers;
Expand Down
4 changes: 2 additions & 2 deletions src/AntiDupl/adDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace ad
{
const DWORD STATUS_FATAL_APP_EXIT = 0x40000015;
const DWORD AD_STATUS_FATAL_APP_EXIT = 0x40000015;

typedef BOOL (*MiniDumpWriteDumpPtr)(
HANDLE hProcess,
Expand Down Expand Up @@ -107,7 +107,7 @@ namespace ad
{
DWORD exception_code = info->ExceptionRecord->ExceptionCode;
void *address = info->ExceptionRecord->ExceptionAddress;
if (exception_code == STATUS_FATAL_APP_EXIT)
if (exception_code == AD_STATUS_FATAL_APP_EXIT)
{// abort()
MessageBox(NULL, TEXT("Program aborted."),
TEXT("Crash report"), MB_OK | MB_ICONERROR);
Expand Down
Loading