This time its related to the setNumThreadGroupsBasedOn() function which makes it easy to set the num thread groups for the job based on a texture or uav size. However, when i was working with mipmaps it was not functioning as expected as it did not take the mip level into account and also the number of thread groups that came out at the end was always "1,1,(depth)".
So i made a few tweaks that make it much easier to work with uavs and compute passes that need to edit each mip level without having to change the thread groups per mip resolution.
so ill get straight to the tweaks. All the changes are based in "OgreHlmsComputeJob.cpp" on function "_calculateNumThreadGroupsBasedOnSetting()"
after this line,
Code: Select all
const TexturePtr &tex = texSlots[mThreadGroupsBasedOnTexSlot].texture;
Code: Select all
const int32 mipLevel = texSlots[mThreadGroupsBasedOnTexSlot].mipmapLevel;
Code: Select all
uint32 resolution[3];
resolution[0] = tex->getWidth() >> mipLevel;
resolution[1] = tex->getHeight() >> mipLevel;
resolution[2] = tex->getDepth();// >> mipLevel;
Code: Select all
resolution[i] = (resolution[i] + mThreadGroupsBasedDivisor[i] - 1u) /
mThreadGroupsBasedDivisor[i];
uint32 numThreadGroups = (resolution[i] + mThreadsPerGroup[i] - 1u) /
mThreadsPerGroup[i];
Code: Select all
uint32 numThreadGroups = (resolution[i] + mThreadGroupsBasedDivisor[i] - 1u) / mThreadGroupsBasedDivisor[i];
Code: Select all
void HlmsComputeJob::_calculateNumThreadGroupsBasedOnSetting()
{
bool hasChanged = false;
if( mThreadGroupsBasedOnTexture != ThreadGroupsBasedOnNothing )
{
const TextureSlotVec &texSlots = mThreadGroupsBasedOnTexture == ThreadGroupsBasedOnTexture ?
mTextureSlots : mUavSlots;
if( mThreadGroupsBasedOnTexSlot < texSlots.size() &&
!texSlots[mThreadGroupsBasedOnTexSlot].texture.isNull() )
{
const TexturePtr &tex = texSlots[mThreadGroupsBasedOnTexSlot].texture;
const int32 mipLevel = texSlots[mThreadGroupsBasedOnTexSlot].mipmapLevel;
uint32 resolution[3];
resolution[0] = tex->getWidth() >> mipLevel;
resolution[1] = tex->getHeight() >> mipLevel;
resolution[2] = tex->getDepth();// >> mipLevel;
if( tex->getTextureType() == TEX_TYPE_CUBE_MAP )
resolution[2] = tex->getNumFaces();
for( int i=0; i<3; ++i )
{
uint32 numThreadGroups = (resolution[i] + mThreadGroupsBasedDivisor[i] - 1u) / mThreadGroupsBasedDivisor[i];
if( mNumThreadGroups[i] != numThreadGroups )
{
mNumThreadGroups[i] = numThreadGroups;
hasChanged = true;
}
}
}
else
{
LogManager::getSingleton().logMessage(
"WARNING: No texture/uav bound to compute job '" + mName.getFriendlyText() +
"' at slot " + StringConverter::toString(mThreadGroupsBasedOnTexSlot) +
" while calculating number of thread groups based on texture");
}
}
if( hasChanged )
mPsoCacheHash = -1;
}
Now all i need to figure out is how to bind a constant buffer and change the value of a property per mip map.