return;
}
//check if at least 3 points are present
- if (ctx->pointCount - ctx->pathes [ctx->pathPtr-1] > 2){
- //set end idx of path to the same as start idx
- ctx->pathes[ctx->pathPtr] = ctx->pathes [ctx->pathPtr-1];
- //if last point of path is same pos as first point, remove it
- //if (vec2_equ(ctx->points[ctx->pointCount-1], ctx->points[ctx->pathes[ctx->pathPtr]]))
- // ctx->pointCount--;
+ if (ctx->pointCount - (ctx->pathes [ctx->pathPtr-1]&PATH_ELT_MASK) > 2){
+ ctx->pathes[ctx->pathPtr] = ctx->pointCount - 1;
+ ctx->pathes[ctx->pathPtr-1] |= PATH_CLOSED_BIT;
_check_pathes_array(ctx);
ctx->pathPtr++;
}else
while (ptrPath < ctx->pathPtr){
uint32_t firstIdx = ctx->vertCount;
- i = ctx->pathes[ptrPath];
+ i = ctx->pathes[ptrPath]&PATH_ELT_MASK;
- LOG(LOG_INFO_PATH, "\tPATH: start = %d; ", ctx->pathes[ptrPath], ctx->pathes[ptrPath+1]);
+ LOG(LOG_INFO_PATH, "\tPATH: start = %d; ", ctx->pathes[ptrPath]&PATH_ELT_MASK, ctx->pathes[ptrPath+1]&PATH_ELT_MASK);
if (_path_is_closed(ctx,ptrPath)){
- lastPathPointIdx = _get_last_point_of_closed_path(ctx,ptrPath);
+ lastPathPointIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;// _get_last_point_of_closed_path(ctx,ptrPath);
LOG(LOG_INFO_PATH, "end = %d\n", lastPathPointIdx);
//prevent closing on the same position, this could be generalize
//to prevent processing of two consecutive point at the same position
lastPathPointIdx--;
iL = lastPathPointIdx;
}else{
- lastPathPointIdx = ctx->pathes[ptrPath+1];
+ lastPathPointIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;
LOG(LOG_INFO_PATH, "end = %d\n", lastPathPointIdx);
vec2 n = vec2_line_norm(ctx->points[i], ctx->points[i+1]);
i++;
}else{
- iR = ctx->pathes[ptrPath];
+ iR = ctx->pathes[ptrPath]&PATH_ELT_MASK;
_build_vb_step(ctx,v,hw,iL,i,iR);
uint32_t* inds = (uint32_t*)(ctx->indices.allocInfo.pMappedData + ((ctx->indCount-6) * sizeof(uint32_t)));
ctx->pointCount = 0;
}
inline bool _path_is_closed (VkvgContext ctx, uint32_t ptrPath){
- return (ctx->pathes[ptrPath] == ctx->pathes[ptrPath+1]);
+ return ctx->pathes[ptrPath] & PATH_CLOSED_BIT;
}
uint32_t _get_last_point_of_closed_path(VkvgContext ctx, uint32_t ptrPath){
if (ptrPath+2 < ctx->pathPtr) //this is not the last path
void _create_cmd_buff (VkvgContext ctx){
ctx->cmd = vkh_cmd_buff_create((VkhDevice)ctx->pSurf->dev, ctx->cmdPool,VK_COMMAND_BUFFER_LEVEL_PRIMARY);
+#if DEBUG
+ vkh_device_set_object_name((VkhDevice)ctx->pSurf->dev, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, (uint64_t)ctx->cmd, "vkvgCtxCmd");
+#endif
}
void _record_draw_cmd (VkvgContext ctx){
if (ctx->indCount == ctx->curIndStart)
v.uv.z = -1;
while (ptrPath < ctx->pathPtr){
- if (!_path_is_closed(ctx, ptrPath))
- ctx->pathes[ptrPath+1] = ctx->pathes[ptrPath];//close path by setting start and end equal
+ //close path
+ ctx->pathes[ptrPath] |= PATH_CLOSED_BIT;// ctx->pathes[ptrPath];//close path by setting start and end equal
- uint32_t firstPtIdx = ctx->pathes[ptrPath];
- uint32_t lastPtIdx = _get_last_point_of_closed_path (ctx, ptrPath);
- uint32_t pathPointCount = lastPtIdx - ctx->pathes[ptrPath] + 1;
+ uint32_t firstPtIdx = ctx->pathes[ptrPath]&PATH_ELT_MASK;
+ uint32_t lastPtIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;//_get_last_point_of_closed_path (ctx, ptrPath);
+ uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
uint32_t firstVertIdx = ctx->vertCount;
-
for (int i = 0; i < pathPointCount; i++) {
v.pos = ctx->points[i+firstPtIdx];
_add_vertex(ctx, v);
v.uv.z = -1;
while (ptrPath < ctx->pathPtr){
- if (!_path_is_closed(ctx, ptrPath))
- //close path
- ctx->pathes[ptrPath+1] = ctx->pathes[ptrPath];
- uint32_t firstPtIdx = ctx->pathes[ptrPath];
- uint32_t lastPtIdx = _get_last_point_of_closed_path (ctx, ptrPath);
- uint32_t pathPointCount = lastPtIdx - ctx->pathes[ptrPath] + 1;
+ ctx->pathes[ptrPath]|=PATH_CLOSED_BIT;//close path
+
+ uint32_t firstPtIdx = ctx->pathes[ptrPath]&PATH_ELT_MASK;
+ uint32_t lastPtIdx = ctx->pathes[ptrPath+1]&PATH_ELT_MASK;
+ uint32_t pathPointCount = lastPtIdx - firstPtIdx + 1;
uint32_t firstVertIdx = ctx->vertCount;
ear_clip_point ecps[pathPointCount];
#include <float.h>
#include <math.h>
-# define M_PIF 3.14159265358979323846f /* float pi */
+#define M_PIF 3.14159265358979323846f /* float pi */
+#define PATH_CLOSED_BIT 0x80000000 /* most significant bit of path elmts is closed/open path state */
+#define PATH_ELT_MASK 0x7FFFFFFF /* Bit mask for fetching path element value */
#define ROUNDF(f, c) (((float)((int)((f) * (c))) / (c)))
#define ROUND_DOWN(v,p) (floorf(v * p) / p)
VkFormatProperties formatProps;
vkGetPhysicalDeviceFormatProperties(e->dev->phy, e->renderer->format, &formatProps);
-#if VKVG_TILING_OPTIMAL
+#ifdef VKVG_TILING_OPTIMAL
assert((formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && "Format cannot be used as transfer source");
#else
assert((formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT) && "Format cannot be used as transfer source");
printf("max tex array layers = %d\n", e->gpu_props.limits.maxImageArrayLayers);
printf("max mem alloc count = %d\n", e->gpu_props.limits.maxMemoryAllocationCount);
- for (int i = 0; i < e->memory_properties.memoryHeapCount; i++) {
+ for (uint32_t i = 0; i < e->memory_properties.memoryHeapCount; i++) {
printf("Mem Heap %d\n", i);
printf("\tflags= %d\n", e->memory_properties.memoryHeaps[i].flags);
- printf("\tsize = %d Mo\n", e->memory_properties.memoryHeaps[i].size/ (1024*1024));
+ printf("\tsize = %lu Mo\n", e->memory_properties.memoryHeaps[i].size/ (uint32_t)(1024*1024));
}
- for (int i = 0; i < e->memory_properties.memoryTypeCount; i++) {
+ for (uint32_t i = 0; i < e->memory_properties.memoryTypeCount; i++) {
printf("Mem type %d\n", i);
printf("\theap %d: ", e->memory_properties.memoryTypes[i].heapIndex);
if (e->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
}
}
+void vkengine_dump_available_layers () {
+ uint32_t layerCount;
+ vkEnumerateInstanceLayerProperties(&layerCount, NULL);
+
+ VkLayerProperties availableLayers [layerCount];
+ vkEnumerateInstanceLayerProperties(&layerCount, availableLayers);
+
+ printf("Available Layers:\n");
+ printf("-----------------\n");
+ for (uint i=0; i<layerCount; i++) {
+ printf ("\t - %s\n", availableLayers[i].layerName);
+ }
+ printf("-----------------\n\n");
+}
+
static VkDebugReportCallbackEXT dbgReport;
vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height) {
}vk_engine_t;
vk_engine_t* vkengine_create (VkPhysicalDeviceType preferedGPU, VkPresentModeKHR presentMode, uint32_t width, uint32_t height);
-
+void vkengine_dump_available_layers ();
void vkengine_destroy (VkEngine e);
bool vkengine_should_close (VkEngine e);
void vkengine_close (VkEngine e);