From: Jean-Philippe Bruyère Date: Mon, 7 Jan 2019 06:46:33 +0000 (+0100) Subject: add sample count to device, add vkvg_device_create_multisample X-Git-Tag: v0.1-alpha~107^2~2 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=0978fa3c5c22ff1575fdc0a6fc09596b8390757f;p=jp%2Fvkvg.git add sample count to device, add vkvg_device_create_multisample --- diff --git a/include/vkvg.h b/include/vkvg.h index c3ea617..7591769 100644 --- a/include/vkvg.h +++ b/include/vkvg.h @@ -35,8 +35,6 @@ extern "C" { #define VKVG_TILING VK_IMAGE_TILING_LINEAR #endif -#define VKVG_SAMPLES 4 - #define LOG_ERR 0x00 #define LOG_DEBUG 0x10 #define LOG_INFO 0x20 @@ -161,8 +159,9 @@ typedef struct _vkvg_surface_t* VkvgSurface; typedef struct _vkvg_device_t* VkvgDevice; typedef struct _vkvg_pattern_t* VkvgPattern; -VkvgDevice vkvg_device_create (VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex); -void vkvg_device_destroy (VkvgDevice dev); +VkvgDevice vkvg_device_create (VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex); +VkvgDevice vkvg_device_create_multisample (VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples); +void vkvg_device_destroy (VkvgDevice dev); VkvgDevice vkvg_device_reference (VkvgDevice dev); uint32_t vkvg_device_get_reference_count (VkvgDevice dev); diff --git a/src/vkvg_context.c b/src/vkvg_context.c index 2843c05..8798951 100644 --- a/src/vkvg_context.c +++ b/src/vkvg_context.c @@ -697,7 +697,7 @@ void vkvg_save (VkvgContext ctx){ VkvgDevice dev = ctx->pSurf->dev; vkvg_context_save_t* sav = (vkvg_context_save_t*)calloc(1,sizeof(vkvg_context_save_t)); - sav->stencilMS = vkh_image_ms_create (dev,VK_FORMAT_S8_UINT, VKVG_SAMPLES, ctx->pSurf->width, ctx->pSurf->height, + sav->stencilMS = vkh_image_ms_create (dev,VK_FORMAT_S8_UINT, dev->samples, ctx->pSurf->width, ctx->pSurf->height, VMA_MEMORY_USAGE_GPU_ONLY, VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT); diff --git a/src/vkvg_device.c b/src/vkvg_device.c index 8a3c078..52e0571 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -26,6 +26,10 @@ #include "vk_mem_alloc.h" VkvgDevice vkvg_device_create(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex) +{ + return vkvg_device_create_multisample (inst,phy,vkdev,qFamIdx,qIndex, VK_SAMPLE_COUNT_4_BIT); +} +VkvgDevice vkvg_device_create_multisample(VkInstance inst, VkPhysicalDevice phy, VkDevice vkdev, uint32_t qFamIdx, uint32_t qIndex, VkSampleCountFlags samples) { LOG(LOG_INFO, "CREATE Device: qFam = %d; qIdx = %d\n", qFamIdx, qIndex); @@ -34,6 +38,7 @@ VkvgDevice vkvg_device_create(VkInstance inst, VkPhysicalDevice phy, VkDevice vk dev->instance = inst; dev->hdpi = 72; dev->vdpi = 72; + dev->samples= samples; dev->vkDev = vkdev; dev->phy = phy; diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index cca37a6..4cf185f 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -47,7 +47,7 @@ void _setupRenderPass(VkvgDevice dev) { VkAttachmentDescription attColor = { .format = FB_COLOR_FORMAT, - .samples = VKVG_SAMPLES, + .samples = dev->samples, .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, .storeOp = VK_ATTACHMENT_STORE_OP_STORE, .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, @@ -65,7 +65,7 @@ void _setupRenderPass(VkvgDevice dev) .finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; VkAttachmentDescription attDS = { .format = VK_FORMAT_S8_UINT, - .samples = VKVG_SAMPLES, + .samples = dev->samples, .loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE, .storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE, .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD, @@ -165,7 +165,7 @@ void _setupPipelines(VkvgDevice dev) .viewportCount = 1, .scissorCount = 1 }; VkPipelineMultisampleStateCreateInfo multisampleState = { .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, - .rasterizationSamples = VKVG_SAMPLES }; + .rasterizationSamples = dev->samples }; /*if (VKVG_SAMPLES != VK_SAMPLE_COUNT_1_BIT){ multisampleState.sampleShadingEnable = VK_TRUE; multisampleState.minSampleShading = 0.25f; diff --git a/src/vkvg_device_internal.h b/src/vkvg_device_internal.h index 1f6e35d..b4d4fd9 100644 --- a/src/vkvg_device_internal.h +++ b/src/vkvg_device_internal.h @@ -88,7 +88,7 @@ typedef struct _vkvg_device_t{ VkInstance instance; VkhImage emptyImg;//prevent unbound descriptor to trigger Validation error 61 - + VkSampleCountFlags samples;//samples count for all surfaces _font_cache_t* fontCache; VkvgContext lastCtx; //double linked list last elmt diff --git a/src/vkvg_surface.c b/src/vkvg_surface.c index 694895d..1e3bd4f 100644 --- a/src/vkvg_surface.c +++ b/src/vkvg_surface.c @@ -77,9 +77,9 @@ void _init_surface (VkvgSurface surf) { surf->format = FB_COLOR_FORMAT;//force bgra internally surf->img = vkh_image_create(surf->dev,surf->format,surf->width,surf->height,VKVG_TILING,VMA_MEMORY_USAGE_GPU_ONLY, VK_IMAGE_USAGE_SAMPLED_BIT|VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT); - surf->imgMS = vkh_image_ms_create(surf->dev,surf->format,VKVG_SAMPLES,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY, + surf->imgMS = vkh_image_ms_create(surf->dev,surf->format,surf->dev->samples,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT); - surf->stencilMS = vkh_image_ms_create(surf->dev,VK_FORMAT_S8_UINT,VKVG_SAMPLES,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY, + surf->stencilMS = vkh_image_ms_create(surf->dev,VK_FORMAT_S8_UINT,surf->dev->samples,surf->width,surf->height,VMA_MEMORY_USAGE_GPU_ONLY, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT); vkh_image_create_descriptor(surf->img, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT, VK_FILTER_NEAREST, VK_FILTER_NEAREST, VK_SAMPLER_MIPMAP_MODE_NEAREST,VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE);