@@ -2018,8 +2018,12 @@ class MetaDeviceMemoryAllocator final
2018
2018
{
2019
2019
auto * gpuObj = pGpuObj->get ();
2020
2020
const IDeviceMemoryBacked::SDeviceMemoryRequirements& memReqs = gpuObj->getMemoryReqs ();
2021
- // this shouldn't be possible
2022
- assert (memReqs.memoryTypeBits &memoryTypeConstraint);
2021
+ // overconstrained
2022
+ if ((memReqs.memoryTypeBits &memoryTypeConstraint)==0 )
2023
+ {
2024
+ m_logger.log (" Overconstrained the Memory Type Index bitmask %d with %d for %s" ,system::ILogger::ELL_ERROR,memReqs.memoryTypeBits ,memoryTypeConstraint,gpuObj->getObjectDebugName ());
2025
+ return false ;
2026
+ }
2023
2027
//
2024
2028
bool needsDeviceAddress = false ;
2025
2029
if constexpr (std::is_same_v<std::remove_pointer_t <decltype (gpuObj)>,IGPUBuffer>)
@@ -3323,7 +3327,8 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult
3323
3327
// record if a device memory allocation will be needed
3324
3328
if constexpr (std::is_base_of_v<IDeviceMemoryBacked,typename asset_traits<AssetType>::video_t >)
3325
3329
{
3326
- if (!deferredAllocator.request (&created.gpuObj ))
3330
+ const auto constrainMask = inputs.constrainMemoryTypeBits (uniqueCopyGroupID,instance.asset ,contentHash,created.gpuObj .get ());
3331
+ if (!deferredAllocator.request (&created.gpuObj ,constrainMask))
3327
3332
{
3328
3333
created.gpuObj .value = nullptr ;
3329
3334
return ;
@@ -3352,6 +3357,32 @@ auto CAssetConverter::reserve(const SInputs& inputs) -> SReserveResult
3352
3357
dedupCreateProp.operator ()<ICPUImage>();
3353
3358
// now allocate the memory for buffers and images
3354
3359
deferredAllocator.finalize ();
3360
+
3361
+ // can remove buffers from conversion requests which can be written to directly
3362
+ {
3363
+ core::vector<ILogicalDevice::MappedMemoryRange> flushRanges;
3364
+ flushRanges.reserve (retval.m_bufferConversions .size ());
3365
+ std::erase_if (retval.m_bufferConversions ,[&flushRanges](const SReserveResult::SConvReqBuffer& conv)->bool
3366
+ {
3367
+ const auto boundMemory = conv.gpuObj ->getBoundMemory ();
3368
+ auto * const memory = boundMemory.memory ;
3369
+ if (!boundMemory.memory ->isMappable ())
3370
+ return false ;
3371
+ const size_t size = conv.gpuObj ->getSize ();
3372
+ const IDeviceMemoryAllocation::MemoryRange range = {boundMemory.offset ,size};
3373
+ // slightly inefficient but oh well
3374
+ void * dst = memory->map (range,IDeviceMemoryAllocation::EMCAF_WRITE);
3375
+ memcpy (dst,conv.canonical ->getPointer (),size);
3376
+ if (boundMemory.memory ->haveToMakeVisible ())
3377
+ flushRanges.emplace_back (memory,range.offset ,range.length ,ILogicalDevice::MappedMemoryRange::align_non_coherent_tag);
3378
+ return true ;
3379
+ }
3380
+ );
3381
+ if (!flushRanges.empty ())
3382
+ device->flushMappedMemoryRanges (flushRanges);
3383
+ }
3384
+
3385
+
3355
3386
#ifdef NBL_ACCELERATION_STRUCTURE_CONVERSION
3356
3387
// Deal with Deferred Creation of Acceleration structures
3357
3388
{
0 commit comments