#define VKVG_LOG_INFO_VBO 0x00000020
#define VKVG_LOG_INFO_IBO 0x00000040
#define VKVG_LOG_INFO_VAO (VKVG_LOG_INFO_VBO|VKVG_LOG_INFO_IBO)
+ #define VKVG_LOG_THREAD 0x00000080
#define VKVG_LOG_DBG_ARRAYS 0x00001000
+#define VKVG_LOG_STROKE 0x00010000
#define VKVG_LOG_FULL 0xffffffff
#define VKVG_LOG_INFO 0x00008000//(VKVG_LOG_INFO_PTS|VKVG_LOG_INFO_PATH|VKVG_LOG_INFO_CMD|VKVG_LOG_INFO_VAO)
*
* @{ */
+/**
+ * @brief vkvg_device_set_thread_aware
+ * @param dev
+ * @param thread_awayre
+ */
vkvg_public
void vkvg_device_set_thread_aware (VkvgDevice dev, uint32_t thread_awayre);
-
+ vkvg_public
+ /**
+ * @brief Set maximum cached context count.
+ *
+ * The context cache stored destroyed contexts per thread to speed-up new context creation.
+ * To disable context cache, call this method with maxCount=0.
+ *
+ * @param dev A valid vkvg device pointer.
+ * @param maxCount The maximum count of saved contexts for fast context instanciation.
+ */
+ void vkvg_device_set_context_cache_size (VkvgDevice dev, uint32_t maxCount);
/**
* @brief Create a new vkvg device.
*
ctx->renderPassBeginInfo.renderArea.extent.height = ctx->pSurf->height;
ctx->renderPassBeginInfo.pClearValues = clearValues;
- if (ctx->pSurf->new)
+ LOCK_SURFACE (ctx->pSurf)
+
+ if (ctx->pSurf->newSurf)
ctx->renderPassBeginInfo.renderPass = ctx->dev->renderPass_ClearAll;
else
ctx->renderPassBeginInfo.renderPass = ctx->dev->renderPass_ClearStencil;
--
- ctx->pSurf->new = false;
+ ctx->pSurf->newSurf = false;
+
+ UNLOCK_SURFACE (ctx->pSurf);
+
vkvg_surface_reference (ctx->pSurf);
if (ctx->dev->samples == VK_SAMPLE_COUNT_1_BIT)
LOCK_DEVICE
- dev->cachedContext[dev->cachedContextCount++] = ctx;
- if (dev->gQLastFence == ctx->flushFence)
- dev->gQLastFence = VK_NULL_HANDLE;
-
+ _cached_ctx* cur = (_cached_ctx*)calloc(1, sizeof(_cached_ctx));
+ cur->ctx = ctx;
+ cur->thread = thrd_current ();
+ cur->pNext = dev->cachedContextLast;
+
+ dev->cachedContextLast = cur;
+ dev->cachedContextCount++;
+
+ LOG(VKVG_LOG_THREAD,"store context: %p, thd:%lu cached ctx: %d\n", cur->ctx, cur->thread, dev->cachedContextCount);
+
ctx->references++;
UNLOCK_DEVICE
#define STENCIL_CLIP_BIT 0x2
#define STENCIL_ALL_BIT 0x3
--#define VKVG_MAX_CACHED_CONTEXT_COUNT 2
++#define VKVG_MAX_CACHED_CONTEXT_COUNT 36
extern PFN_vkCmdBindPipeline CmdBindPipeline;
extern PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets;
#include "test.h"
#include "tinycthread.h"
--#define THREAD_COUNT 64
++#define THREAD_COUNT 32
static int finishedThreadCount = 0;