d3d12: Use openMP to upload texture

Does not really increase performance so far
This commit is contained in:
vlj 2015-06-04 22:32:46 +02:00 committed by Vincent Lejeune
parent cfe058dc82
commit 459ab17d74
4 changed files with 10 additions and 6 deletions

View file

@ -29,9 +29,9 @@ size_t powerOf2Align(size_t unalignedVal, size_t powerOf2)
inline
void streamToBuffer(void* dst, void* src, size_t sizeInBytes)
{
for (unsigned i = 0; i < sizeInBytes / 16; i++)
#pragma omp parallel for
for (int i = 0; i < sizeInBytes / 16; i++)
{
const __m128i &srcPtr = _mm_loadu_si128((__m128i*) ((char*)src + i * 16));
_mm_stream_si128((__m128i*)((char*)dst + i * 16), srcPtr);
}
@ -45,9 +45,10 @@ inline
void streamBuffer(void* dst, void* src, size_t sizeInBytes)
{
// Assume 64 bytes cache line
unsigned offset = 0;
int offset = 0;
bool isAligned = !((size_t)src & 15);
for (; (offset + 64) < sizeInBytes; offset += 64)
#pragma omp parallel for
for (offset = 0; offset < sizeInBytes - 64; offset += 64)
{
char *line = (char*)src + offset;
char *dstline = (char*)dst + offset;

View file

@ -222,10 +222,9 @@ ID3D12Resource *uploadSingleTexture(
log2width = (u32)(logf(w) / logf(2.f));
log2height = (u32)(logf(h) / logf(2.f));
#pragma omp parallel for
for (int j = 0; j < w; j++)
{
dst[(row * rowPitch / 4) + j] = src[LinearToSwizzleAddress(j, row, 0, log2width, log2height, 0)];
}
}
else
streamBuffer((char*)textureData + row * rowPitch, (char*)pixels + row * m_texture_pitch, m_texture_pitch);

View file

@ -758,6 +758,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View file

@ -84,6 +84,7 @@
<PrecompiledHeaderFile>stdafx_gui.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)_gui.pch</PrecompiledHeaderOutputFile>
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions);DX12_SUPPORT</PreprocessorDefinitions>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -114,6 +115,7 @@
<ExceptionHandling>Async</ExceptionHandling>
<PrecompiledHeaderFile>stdafx_gui.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)_gui.pch</PrecompiledHeaderOutputFile>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -150,6 +152,7 @@
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeaderFile>stdafx_gui.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)$(TargetName)_gui.pch</PrecompiledHeaderOutputFile>
<OpenMPSupport>true</OpenMPSupport>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>