vk: make sure deleted textures are not referenced in staging
This fixes -vkvalidate and fixes #464
This commit is contained in:
parent
8ed23cb40f
commit
dc698c16dc
|
@ -51,7 +51,7 @@ void R_VkStagingShutdown(void) {
|
|||
R_VkCommandPoolDestroy( &g_staging.upload_pool );
|
||||
}
|
||||
|
||||
static void flushStagingBufferSync(void) {
|
||||
void R_VkStagingFlushSync( void ) {
|
||||
const VkCommandBuffer cmdbuf = R_VkStagingCommit();
|
||||
if (!cmdbuf)
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@ static void flushStagingBufferSync(void) {
|
|||
XVK_CHECK(vkEndCommandBuffer(cmdbuf));
|
||||
g_staging.cmdbuf = VK_NULL_HANDLE;
|
||||
|
||||
gEngine.Con_Reportf(S_WARN "flushing staging buffer img count=%d\n", g_staging.images.count);
|
||||
//gEngine.Con_Reportf(S_WARN "flushing staging buffer img count=%d\n", g_staging.images.count);
|
||||
|
||||
const VkSubmitInfo subinfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||
|
@ -84,14 +84,14 @@ static uint32_t allocateInRing(uint32_t size, uint32_t alignment) {
|
|||
if (offset != ALO_ALLOC_FAILED)
|
||||
return offset;
|
||||
|
||||
flushStagingBufferSync();
|
||||
R_VkStagingFlushSync();
|
||||
|
||||
return R_FlippingBuffer_Alloc(&g_staging.buffer_alloc, size, alignment );
|
||||
}
|
||||
|
||||
vk_staging_region_t R_VkStagingLockForBuffer(vk_staging_buffer_args_t args) {
|
||||
if ( g_staging.buffers.count >= MAX_STAGING_ALLOCS )
|
||||
flushStagingBufferSync();
|
||||
R_VkStagingFlushSync();
|
||||
|
||||
const uint32_t offset = allocateInRing(args.size, args.alignment);
|
||||
if (offset == ALO_ALLOC_FAILED)
|
||||
|
@ -116,7 +116,7 @@ vk_staging_region_t R_VkStagingLockForBuffer(vk_staging_buffer_args_t args) {
|
|||
|
||||
vk_staging_region_t R_VkStagingLockForImage(vk_staging_image_args_t args) {
|
||||
if ( g_staging.images.count >= MAX_STAGING_ALLOCS )
|
||||
flushStagingBufferSync();
|
||||
R_VkStagingFlushSync();
|
||||
|
||||
const uint32_t offset = allocateInRing(args.size, args.alignment);
|
||||
if (offset == ALO_ALLOC_FAILED)
|
||||
|
|
|
@ -47,3 +47,7 @@ VkCommandBuffer R_VkStagingFrameEnd(void);
|
|||
// Gets the current command buffer.
|
||||
// WARNING: Can be invalidated by any of the Lock calls
|
||||
VkCommandBuffer R_VkStagingGetCommandBuffer(void);
|
||||
|
||||
// Commit all staging data into current cmdbuf, submit it and wait for completion.
|
||||
// Needed for CPU-GPU sync
|
||||
void R_VkStagingFlushSync( void );
|
||||
|
|
|
@ -830,7 +830,10 @@ void VK_FreeTexture( unsigned int texnum ) {
|
|||
gEngine.FS_FreeImage( tex->original );
|
||||
*/
|
||||
|
||||
// TODO how to do this properly?
|
||||
// Need to make sure that there are no references to this texture anywhere.
|
||||
// It might have been added to staging and then immediately deleted, leaving references to its vkimage
|
||||
// in the staging command buffer. See https://github.com/w23/xash3d-fwgs/issues/464
|
||||
R_VkStagingFlushSync();
|
||||
XVK_CHECK(vkDeviceWaitIdle(vk_core.device));
|
||||
|
||||
XVK_ImageDestroy(&tex->vk.image);
|
||||
|
|
Loading…
Reference in New Issue