render pass stuff for multisampling
This commit is contained in:
@@ -3,12 +3,8 @@
|
|||||||
#include <output_device/vulkan_device_extensions.h>
|
#include <output_device/vulkan_device_extensions.h>
|
||||||
#include <vulkan_surface/vulkan_surface.h>
|
#include <vulkan_surface/vulkan_surface.h>
|
||||||
|
|
||||||
gnMultisampleCountFlags getVulkanSampleCount(VkPhysicalDevice device) {
|
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts) {
|
||||||
VkPhysicalDeviceProperties physicalDeviceProperties;
|
gnMultisampleCountFlags sampleCount = 0;
|
||||||
vkGetPhysicalDeviceProperties(device, &physicalDeviceProperties);
|
|
||||||
VkSampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts;
|
|
||||||
|
|
||||||
gnMultisampleCountFlags sampleCount = GN_SAMPLES_NONE;
|
|
||||||
if (counts & VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }
|
if (counts & VK_SAMPLE_COUNT_64_BIT) { sampleCount |= GN_SAMPLE_BIT_64; }
|
||||||
if (counts & VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; }
|
if (counts & VK_SAMPLE_COUNT_32_BIT) { sampleCount |= GN_SAMPLE_BIT_32; }
|
||||||
if (counts & VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; }
|
if (counts & VK_SAMPLE_COUNT_16_BIT) { sampleCount |= GN_SAMPLE_BIT_16; }
|
||||||
@@ -16,6 +12,21 @@ gnMultisampleCountFlags getVulkanSampleCount(VkPhysicalDevice device) {
|
|||||||
if (counts & VK_SAMPLE_COUNT_4_BIT) { sampleCount |= GN_SAMPLE_BIT_4; }
|
if (counts & VK_SAMPLE_COUNT_4_BIT) { sampleCount |= GN_SAMPLE_BIT_4; }
|
||||||
if (counts & VK_SAMPLE_COUNT_2_BIT) { sampleCount |= GN_SAMPLE_BIT_2; }
|
if (counts & VK_SAMPLE_COUNT_2_BIT) { sampleCount |= GN_SAMPLE_BIT_2; }
|
||||||
if (counts & VK_SAMPLE_COUNT_1_BIT) { sampleCount |= GN_SAMPLE_BIT_1; }
|
if (counts & VK_SAMPLE_COUNT_1_BIT) { sampleCount |= GN_SAMPLE_BIT_1; }
|
||||||
|
return sampleCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts) {
|
||||||
|
VkSampleCountFlags sampleCount = 0;
|
||||||
|
|
||||||
|
if ((counts & GN_SAMPLE_BIT_64) == GN_SAMPLE_BIT_64) { sampleCount |= VK_SAMPLE_COUNT_64_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_32) == GN_SAMPLE_BIT_32) { sampleCount |= VK_SAMPLE_COUNT_32_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_16) == GN_SAMPLE_BIT_16) { sampleCount |= VK_SAMPLE_COUNT_16_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_8) == GN_SAMPLE_BIT_8) { sampleCount |= VK_SAMPLE_COUNT_8_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_4) == GN_SAMPLE_BIT_4) { sampleCount |= VK_SAMPLE_COUNT_4_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_2) == GN_SAMPLE_BIT_2) { sampleCount |= VK_SAMPLE_COUNT_2_BIT; }
|
||||||
|
if ((counts & GN_SAMPLE_BIT_1) == GN_SAMPLE_BIT_1) { sampleCount |= VK_SAMPLE_COUNT_1_BIT; }
|
||||||
|
|
||||||
return sampleCount;
|
return sampleCount;
|
||||||
}
|
}
|
||||||
@@ -61,7 +72,11 @@ gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* device
|
|||||||
outputDevices[i].queueProperties.queueProperties[i].queueType = finalQueueType;
|
outputDevices[i].queueProperties.queueProperties[i].queueType = finalQueueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
outputDevices[i].features.avaliableSamples = getVulkanSampleCount(physicalDevices[i]);
|
VkPhysicalDeviceProperties physicalDeviceProperties;
|
||||||
|
vkGetPhysicalDeviceProperties(physicalDevices[i], &physicalDeviceProperties);
|
||||||
|
VkSampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts;
|
||||||
|
|
||||||
|
outputDevices[i].features.avaliableSamples = vkSampleCountToGryphn(counts);
|
||||||
}
|
}
|
||||||
free(physicalDevices);
|
free(physicalDevices);
|
||||||
|
|
||||||
|
@@ -8,3 +8,7 @@ typedef struct gnPlatformPhysicalDevice_t {
|
|||||||
|
|
||||||
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
gnPhysicalDevice* getPhysicalDevices(gnInstanceHandle instance, uint32_t* deviceCount);
|
||||||
gnBool queueCanPresentToSurface(const gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface);
|
gnBool queueCanPresentToSurface(const gnPhysicalDevice device, uint32_t queueIndex, gnWindowSurfaceHandle windowSurface);
|
||||||
|
|
||||||
|
|
||||||
|
gnMultisampleCountFlags vkSampleCountToGryphn(VkSampleCountFlags counts);
|
||||||
|
VkSampleCountFlags gnSampleCountToVulkan(gnMultisampleCountFlags counts);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#include "vulkan_render_pass_descriptor.h"
|
#include "vulkan_render_pass_descriptor.h"
|
||||||
#include "vulkan_surface/vulkan_surface.h"
|
#include "vulkan_surface/vulkan_surface.h"
|
||||||
#include "output_device/vulkan_output_devices.h"
|
#include "output_device/vulkan_output_devices.h"
|
||||||
|
#include <output_device/vulkan_physical_device.h>
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
|
||||||
VkAttachmentLoadOp vkGryphnLoadOperation(gnLoadOperation loadOperation) {
|
VkAttachmentLoadOp vkGryphnLoadOperation(gnLoadOperation loadOperation) {
|
||||||
@@ -50,7 +51,7 @@ gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device
|
|||||||
for (int i = 0; i < info.attachmentCount; i++) {
|
for (int i = 0; i < info.attachmentCount; i++) {
|
||||||
renderPass->renderPassDescriptor->attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
|
renderPass->renderPassDescriptor->attachments[i].format = vkGryphnFormatToVulkanFormat(info.attachmentInfos[i].format);
|
||||||
renderPass->renderPassDescriptor->attachments[i].flags = 0;
|
renderPass->renderPassDescriptor->attachments[i].flags = 0;
|
||||||
renderPass->renderPassDescriptor->attachments[i].samples = VK_SAMPLE_COUNT_1_BIT;
|
renderPass->renderPassDescriptor->attachments[i].samples = gnSampleCountToVulkan(info.attachmentInfos[i].samples);
|
||||||
|
|
||||||
renderPass->renderPassDescriptor->attachments[i].loadOp = vkGryphnLoadOperation(info.attachmentInfos[i].loadOperation);
|
renderPass->renderPassDescriptor->attachments[i].loadOp = vkGryphnLoadOperation(info.attachmentInfos[i].loadOperation);
|
||||||
renderPass->renderPassDescriptor->attachments[i].storeOp = vkGryphnStoreOperation(info.attachmentInfos[i].storeOperation);
|
renderPass->renderPassDescriptor->attachments[i].storeOp = vkGryphnStoreOperation(info.attachmentInfos[i].storeOperation);
|
||||||
@@ -66,9 +67,12 @@ gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device
|
|||||||
renderPass->renderPassDescriptor->subpasses = malloc(sizeof(VkSubpassDescription) * info.subpassCount);
|
renderPass->renderPassDescriptor->subpasses = malloc(sizeof(VkSubpassDescription) * info.subpassCount);
|
||||||
renderPass->renderPassDescriptor->colorAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
|
renderPass->renderPassDescriptor->colorAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
|
||||||
renderPass->renderPassDescriptor->depthAttachments = malloc(sizeof(VkAttachmentReference) * info.subpassCount);
|
renderPass->renderPassDescriptor->depthAttachments = malloc(sizeof(VkAttachmentReference) * info.subpassCount);
|
||||||
|
renderPass->renderPassDescriptor->resolveAttachments = malloc(sizeof(VkAttachmentReference*) * info.subpassCount);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < info.subpassCount; i++) {
|
for (int i = 0; i < info.subpassCount; i++) {
|
||||||
renderPass->renderPassDescriptor->colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
renderPass->renderPassDescriptor->colorAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].colorAttachmentCount);
|
||||||
|
renderPass->renderPassDescriptor->resolveAttachments[i] = malloc(sizeof(VkAttachmentReference) * info.subpassInfos[i].resolveAttachmentCount);
|
||||||
|
|
||||||
for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
|
for (int c = 0; c < info.subpassInfos[i].colorAttachmentCount; c++) {
|
||||||
renderPass->renderPassDescriptor->colorAttachments[i][c] = (VkAttachmentReference){
|
renderPass->renderPassDescriptor->colorAttachments[i][c] = (VkAttachmentReference){
|
||||||
@@ -77,11 +81,19 @@ gnReturnCode createRenderPass(gnRenderPassDescriptor renderPass, gnDevice device
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < info.subpassInfos[i].resolveAttachmentCount; c++) {
|
||||||
|
renderPass->renderPassDescriptor->resolveAttachments[i][c] = (VkAttachmentReference){
|
||||||
|
.attachment = info.subpassInfos[i].resolveAttachments[c].index,
|
||||||
|
.layout = vkGryphnImageLayout(info.subpassInfos[i].resolveAttachments[c].imageLayout)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
renderPass->renderPassDescriptor->subpasses[i] = (VkSubpassDescription){
|
renderPass->renderPassDescriptor->subpasses[i] = (VkSubpassDescription){
|
||||||
.flags = 0,
|
.flags = 0,
|
||||||
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
|
||||||
.colorAttachmentCount = info.subpassInfos[i].colorAttachmentCount,
|
.colorAttachmentCount = info.subpassInfos[i].colorAttachmentCount,
|
||||||
.pColorAttachments = renderPass->renderPassDescriptor->colorAttachments[i]
|
.pColorAttachments = renderPass->renderPassDescriptor->colorAttachments[i],
|
||||||
|
.pResolveAttachments = renderPass->renderPassDescriptor->resolveAttachments[i]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (info.subpassInfos[i].depthAttachment != NULL) {
|
if (info.subpassInfos[i].depthAttachment != NULL) {
|
||||||
|
@@ -14,6 +14,7 @@ typedef struct gnPlatformRenderPassDescriptor_t {
|
|||||||
|
|
||||||
VkAttachmentReference** colorAttachments;
|
VkAttachmentReference** colorAttachments;
|
||||||
VkAttachmentReference* depthAttachments;
|
VkAttachmentReference* depthAttachments;
|
||||||
|
VkAttachmentReference** resolveAttachments;
|
||||||
} gnPlatformRenderPassDescriptor;
|
} gnPlatformRenderPassDescriptor;
|
||||||
|
|
||||||
VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage);
|
VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage);
|
||||||
|
@@ -146,7 +146,7 @@ gnReturnCode createTexture(gnTexture texture, gnDevice device, const gnTextureIn
|
|||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||||
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
.samples = gnSampleCountToVulkan(info.samples),
|
||||||
.extent = {
|
.extent = {
|
||||||
.width = info.extent.width,
|
.width = info.extent.width,
|
||||||
.height = info.extent.height,
|
.height = info.extent.height,
|
||||||
|
@@ -8,7 +8,6 @@ typedef enum gnDeviceType {
|
|||||||
} gnDeviceType;
|
} gnDeviceType;
|
||||||
|
|
||||||
typedef enum gnMultisampleCountFlags {
|
typedef enum gnMultisampleCountFlags {
|
||||||
GN_SAMPLES_NONE = 0,
|
|
||||||
GN_SAMPLE_BIT_1 = 1 << 0, // 0x01
|
GN_SAMPLE_BIT_1 = 1 << 0, // 0x01
|
||||||
GN_SAMPLE_BIT_2 = 1 << 1, // 0x02
|
GN_SAMPLE_BIT_2 = 1 << 1, // 0x02
|
||||||
GN_SAMPLE_BIT_4 = 1 << 2, // 0x04
|
GN_SAMPLE_BIT_4 = 1 << 2, // 0x04
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include "utils/gryphn_image_format.h"
|
#include "utils/gryphn_image_format.h"
|
||||||
#include "utils/gryphn_error_code.h"
|
#include "utils/gryphn_error_code.h"
|
||||||
|
#include "core/src/output_device/gryphn_physical_output_device.h"
|
||||||
#include "gryphn_handles.h"
|
#include "gryphn_handles.h"
|
||||||
|
|
||||||
typedef enum gnRenderPassStage {
|
typedef enum gnRenderPassStage {
|
||||||
@@ -32,6 +33,8 @@ typedef struct gnRenderPassAttachmentInfo_t {
|
|||||||
|
|
||||||
gnImageLayout initialLayout;
|
gnImageLayout initialLayout;
|
||||||
gnImageLayout finalLayout;
|
gnImageLayout finalLayout;
|
||||||
|
|
||||||
|
gnMultisampleCountFlags samples;
|
||||||
} gnRenderPassAttachmentInfo;
|
} gnRenderPassAttachmentInfo;
|
||||||
|
|
||||||
typedef struct gnSubpassAttachmentInfo_t {
|
typedef struct gnSubpassAttachmentInfo_t {
|
||||||
@@ -42,7 +45,11 @@ typedef struct gnSubpassAttachmentInfo_t {
|
|||||||
typedef struct gnSubpassInfo_t {
|
typedef struct gnSubpassInfo_t {
|
||||||
uint32_t colorAttachmentCount;
|
uint32_t colorAttachmentCount;
|
||||||
gnSubpassAttachmentInfo* colorAttachments;
|
gnSubpassAttachmentInfo* colorAttachments;
|
||||||
|
|
||||||
gnSubpassAttachmentInfo* depthAttachment;
|
gnSubpassAttachmentInfo* depthAttachment;
|
||||||
|
|
||||||
|
uint32_t resolveAttachmentCount;
|
||||||
|
gnSubpassAttachmentInfo* resolveAttachments;
|
||||||
} gnSubpassInfo;
|
} gnSubpassInfo;
|
||||||
|
|
||||||
#define GN_SUBPASS_EXTERNAL -1
|
#define GN_SUBPASS_EXTERNAL -1
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#include "utils/gryphn_image_format.h"
|
#include "utils/gryphn_image_format.h"
|
||||||
#include "utils/gryphn_error_code.h"
|
#include "utils/gryphn_error_code.h"
|
||||||
#include "utils/math/gryphn_vec3.h"
|
#include "utils/math/gryphn_vec3.h"
|
||||||
|
#include "core/src/output_device/gryphn_physical_output_device.h"
|
||||||
#include <gryphn_handles.h>
|
#include <gryphn_handles.h>
|
||||||
|
|
||||||
typedef enum gnTextureType {
|
typedef enum gnTextureType {
|
||||||
@@ -18,6 +19,7 @@ typedef enum gnTextureWrap {
|
|||||||
|
|
||||||
typedef struct gnTextureInfo {
|
typedef struct gnTextureInfo {
|
||||||
gnExtent3D extent;
|
gnExtent3D extent;
|
||||||
|
gnMultisampleCountFlags samples;
|
||||||
uint32_t mipmapLevels;
|
uint32_t mipmapLevels;
|
||||||
gnTextureType type;
|
gnTextureType type;
|
||||||
gnImageFormat format;
|
gnImageFormat format;
|
||||||
|
Reference in New Issue
Block a user