gryphn + vulkan stuff for depth textures

This commit is contained in:
Gregory Wells
2025-06-17 14:32:56 -04:00
parent e5a11b1ef4
commit 86f2ac6e5a
11 changed files with 99 additions and 48 deletions

View File

@@ -23,11 +23,26 @@ VkImageLayout vkGryphnImageLayout(gnImageLayout layout) {
case GN_LAYOUT_UNDEFINED: return VK_IMAGE_LAYOUT_UNDEFINED; case GN_LAYOUT_UNDEFINED: return VK_IMAGE_LAYOUT_UNDEFINED;
case GN_LAYOUT_PRESENTATION_QUEUE_IMAGE: return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; case GN_LAYOUT_PRESENTATION_QUEUE_IMAGE: return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
case GN_LAYOUT_TRANSFER_DESTINATION: return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; case GN_LAYOUT_TRANSFER_DESTINATION: return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
case GN_COLOR_ATTACHMENT: return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; case GN_LAYOUT_COLOR_ATTACHMENT: return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
case GN_LAYOUT_DEPTH_STENCIL: return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
} }
} }
gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* renderPass, struct gnOutputDevice_t* device, struct gnRenderPassDescriptorInfo_t info) { VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage) {
VkPipelineStageFlags flags = 0;
if ((stage & GN_COLOR_ATTACHMENT_OUTPUT) == GN_COLOR_ATTACHMENT_OUTPUT) flags |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
if ((stage & GN_EARLY_FRAGMENT_TEST) == GN_EARLY_FRAGMENT_TEST) flags |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
return flags;
}
VkAccessFlags vkGryphnRenderPassAccess(gnRenderPassAccess access) {
VkAccessFlags flags = 0;
if ((flags & GN_COLOR_ATTACHMENT_WRITE) == GN_COLOR_ATTACHMENT_WRITE) flags |= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
if ((flags & GN_DEPTH_STENCIL_WRITE) == GN_DEPTH_STENCIL_WRITE) flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
return flags;
}
gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* renderPass, struct gnOutputDevice_t* device, gnRenderPassDescriptorInfo info) {
renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor)); renderPass->renderPassDescriptor = malloc(sizeof(gnPlatformRenderPassDescriptor));
renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount; renderPass->renderPassDescriptor->attachmentCount = info.attachmentCount;
@@ -50,11 +65,7 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
renderPass->renderPassDescriptor->subpassCount = info.subpassCount; renderPass->renderPassDescriptor->subpassCount = info.subpassCount;
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);
VkAttachmentReference ref = {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
};
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);
@@ -66,13 +77,20 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
}; };
} }
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]
}; };
if (info.subpassInfos[i].depthAttachment != NULL) {
renderPass->renderPassDescriptor->depthAttachments[i] = (VkAttachmentReference){
.attachment = info.subpassInfos[i].depthAttachment->index,
.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
};
renderPass->renderPassDescriptor->subpasses[i].pDepthStencilAttachment = &renderPass->renderPassDescriptor->depthAttachments[i];
}
} }
renderPass->renderPassDescriptor->dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount); renderPass->renderPassDescriptor->dependencies = malloc(sizeof(VkSubpassDependency) * info.dependencyCount);
@@ -80,10 +98,10 @@ gnReturnCode gnCreateRenderPassDescriptorFn(struct gnRenderPassDescriptor_t* ren
renderPass->renderPassDescriptor->dependencies[i] = (VkSubpassDependency) { renderPass->renderPassDescriptor->dependencies[i] = (VkSubpassDependency) {
.srcSubpass = (info.dependencies[i].source == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].source, .srcSubpass = (info.dependencies[i].source == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].source,
.dstSubpass = (info.dependencies[i].destination == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].destination, .dstSubpass = (info.dependencies[i].destination == GN_SUBPASS_EXTERNAL) ? VK_SUBPASS_EXTERNAL : info.dependencies[i].destination,
.srcStageMask = info.dependencies[i].soruceStageMask, .srcStageMask = vkGryphnRenderPassStage(info.dependencies[i].soruceStageMask),
.srcAccessMask = info.dependencies[i].sourceAccessMask, .srcAccessMask = vkGryphnRenderPassAccess(info.dependencies[i].sourceAccessMask),
.dstStageMask = info.dependencies[i].destinationStageMask, .dstStageMask = vkGryphnRenderPassStage(info.dependencies[i].destinationStageMask),
.dstAccessMask = info.dependencies[i].destinationAccessMask .dstAccessMask = vkGryphnRenderPassAccess(info.dependencies[i].destinationAccessMask)
}; };
} }
@@ -113,4 +131,5 @@ void gnDestroyRenderPassDescriptorFn(gnRenderPassDescriptor renderPass) {
free(renderPass->renderPassDescriptor->attachments); free(renderPass->renderPassDescriptor->attachments);
free(renderPass->renderPassDescriptor->subpasses); free(renderPass->renderPassDescriptor->subpasses);
free(renderPass->renderPassDescriptor->dependencies); free(renderPass->renderPassDescriptor->dependencies);
free(renderPass->renderPassDescriptor->depthAttachments);
} }

View File

@@ -13,4 +13,7 @@ typedef struct gnPlatformRenderPassDescriptor_t {
VkSubpassDependency* dependencies; VkSubpassDependency* dependencies;
VkAttachmentReference** colorAttachments; VkAttachmentReference** colorAttachments;
VkAttachmentReference* depthAttachments;
} gnPlatformRenderPassDescriptor; } gnPlatformRenderPassDescriptor;
VkPipelineStageFlags vkGryphnRenderPassStage(gnRenderPassStage stage);

View File

@@ -4,13 +4,8 @@
#include "sync/fence/vulkan_fence.h" #include "sync/fence/vulkan_fence.h"
#include "commands/command_buffer/vulkan_command_buffer.h" #include "commands/command_buffer/vulkan_command_buffer.h"
#include "output_device/vulkan_output_devices.h" #include "output_device/vulkan_output_devices.h"
#include "core/renderpass/gryphn_render_pass_descriptor.h" #include "renderpass/vulkan_render_pass_descriptor.h"
VkPipelineStageFlags vkGryphnWaitStage(enum gnRenderPassStage_e stage) {
switch(stage) {
case GN_COLOR_ATTACHMENT_OUTPUT: return VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
}
}
gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) { gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t info) {
VK_SUBPASS_EXTERNAL; VK_SUBPASS_EXTERNAL;
@@ -18,7 +13,7 @@ gnReturnCode gnSubmitFn(struct gnOutputDevice_t* device, struct gnSubmitInfo_t i
VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount); VkSemaphore* waitSemaphores = malloc(sizeof(VkSemaphore) * info.waitCount);
VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount); VkPipelineStageFlags* waitStages = malloc(sizeof(VkPipelineStageFlags) * info.waitCount);
for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore; for (int i = 0; i < info.waitCount; i++) waitSemaphores[i] = info.waitSemaphores[i]->semaphore->semaphore;
for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnWaitStage(info.waitStages[i]); for (int i = 0; i < info.waitCount; i++) waitStages[i] = vkGryphnRenderPassStage(info.waitStages[i]);
VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount); VkCommandBuffer* commandBuffers = malloc(sizeof(VkCommandBuffer) * info.commandBufferCount);
for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer; for (int i = 0; i < info.commandBufferCount; i++) commandBuffers[i] = info.commandBuffers[i]->commandBuffer->buffer;

View File

@@ -25,7 +25,18 @@ VkSamplerAddressMode vkGryphnTextureWrap(gnTextureWrap wrap) {
} }
} }
void VkTransitionImageLayout(gnDevice device, VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout) { VkImageAspectFlags vkGryphnGetAspectFlags(gnImageFormat format) {
VkImageAspectFlags aspectMask = 0;
if (format == GN_FORMAT_D32S8_UINT || format == GN_FORMAT_D24S8_UINT) aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
else { aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; }
return aspectMask;
}
gnBool vkGryphnIsDepthStencil(gnImageFormat format) { return (format == GN_FORMAT_D32S8_UINT || format == GN_FORMAT_D24S8_UINT); }
void VkTransitionImageLayout(gnDevice device, VkImage image, gnImageFormat format, VkImageLayout oldLayout, VkImageLayout newLayout) {
VkCommandBuffer transferBuffer = gnBeginVulkanTransferOperation(device); VkCommandBuffer transferBuffer = gnBeginVulkanTransferOperation(device);
VkPipelineStageFlags sourceStage, destinationStage; VkPipelineStageFlags sourceStage, destinationStage;
@@ -43,6 +54,12 @@ void VkTransitionImageLayout(gnDevice device, VkImage image, VkFormat format, Vk
destinationStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT; destinationStage = VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
destinationAccessMask = VK_ACCESS_SHADER_READ_BIT; destinationAccessMask = VK_ACCESS_SHADER_READ_BIT;
} else if (oldLayout == VK_IMAGE_LAYOUT_UNDEFINED && newLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL) {
sourceAccessMask = 0;
sourceStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
destinationAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
destinationStage = VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT;
} }
VkImageMemoryBarrier barrier = { VkImageMemoryBarrier barrier = {
@@ -58,7 +75,7 @@ void VkTransitionImageLayout(gnDevice device, VkImage image, VkFormat format, Vk
.newLayout = newLayout, .newLayout = newLayout,
.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .subresourceRange.aspectMask = vkGryphnGetAspectFlags(format),
.subresourceRange.baseMipLevel = 0, .subresourceRange.baseMipLevel = 0,
.subresourceRange.levelCount = 1, .subresourceRange.levelCount = 1,
.subresourceRange.baseArrayLayer = 0, .subresourceRange.baseArrayLayer = 0,
@@ -109,6 +126,8 @@ void VkCopyBufferToImage(VkGryphnBuffer buffer, VkGryphnImage image, uint32_t wi
gnEndVulkanTransferOperation(device, transferBuffer); gnEndVulkanTransferOperation(device, transferBuffer);
} }
#include "stdio.h"
gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextureInfo info) { gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextureInfo info) {
texture->texture = malloc(sizeof(struct gnPlatformTexture_t)); texture->texture = malloc(sizeof(struct gnPlatformTexture_t));
@@ -128,7 +147,6 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
.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,
.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
.samples = VK_SAMPLE_COUNT_1_BIT, .samples = VK_SAMPLE_COUNT_1_BIT,
.extent = { .extent = {
.width = info.width, .width = info.width,
@@ -141,6 +159,11 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
.format = vkGryphnFormatToVulkanFormat(info.format) .format = vkGryphnFormatToVulkanFormat(info.format)
}; };
if (vkGryphnIsDepthStencil(info.format))
imageInfo.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
else
imageInfo.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
if (vkCreateImage(device->outputDevice->device, &imageInfo, NULL, &texture->texture->image.image) != VK_SUCCESS) if (vkCreateImage(device->outputDevice->device, &imageInfo, NULL, &texture->texture->image.image) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_IMAGE; return GN_FAILED_TO_CREATE_IMAGE;
@@ -171,7 +194,7 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
.viewType = vkGryphnTextureTypeView(info.type), .viewType = vkGryphnTextureTypeView(info.type),
.format = vkGryphnFormatToVulkanFormat(info.format), .format = vkGryphnFormatToVulkanFormat(info.format),
.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, .subresourceRange.aspectMask = vkGryphnGetAspectFlags(info.format),
.subresourceRange.baseMipLevel = 0, .subresourceRange.baseMipLevel = 0,
.subresourceRange.levelCount = 1, .subresourceRange.levelCount = 1,
.subresourceRange.baseArrayLayer = 0, .subresourceRange.baseArrayLayer = 0,
@@ -210,6 +233,9 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
if (vkCreateSampler(device->outputDevice->device, &samplerInfo, NULL, &texture->texture->sampler) != VK_SUCCESS) if (vkCreateSampler(device->outputDevice->device, &samplerInfo, NULL, &texture->texture->sampler) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_SAMPLER; return GN_FAILED_TO_CREATE_SAMPLER;
if (vkGryphnIsDepthStencil(info.format))
VkTransitionImageLayout(texture->device, texture->texture->image.image, texture->info.format, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
return GN_SUCCESS; return GN_SUCCESS;
} }
@@ -226,9 +252,9 @@ void gnTextureDataFn(gnTextureHandle texture, void* pixelData) {
} }
//gnDevice device, VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout //gnDevice device, VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout
VkTransitionImageLayout(texture->device, texture->texture->image.image, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); VkTransitionImageLayout(texture->device, texture->texture->image.image, texture->info.format, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
VkCopyBufferToImage(texture->texture->buffer, texture->texture->image, texture->texture->width, texture->texture->height, texture->device); VkCopyBufferToImage(texture->texture->buffer, texture->texture->image, texture->texture->width, texture->texture->height, texture->device);
VkTransitionImageLayout(texture->device, texture->texture->image.image, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); VkTransitionImageLayout(texture->device, texture->texture->image.image, texture->info.format, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
texture->texture->beenWrittenToo = gnTrue; texture->texture->beenWrittenToo = gnTrue;
} }

View File

@@ -110,9 +110,11 @@ gnSurfaceDetails gnGetSurfaceDetailsFn(
VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format) { VkFormat vkGryphnFormatToVulkanFormat(gnImageFormat format) {
switch (format) { switch (format) {
case GN_FORMAT_NONE: return VK_FORMAT_UNDEFINED;
case GN_FORMAT_BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB; case GN_FORMAT_BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB;
case GN_FORMAT_RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB; case GN_FORMAT_RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB;
default: return VK_FORMAT_UNDEFINED; case GN_FORMAT_D32S8_UINT: return VK_FORMAT_D32_SFLOAT_S8_UINT;
case GN_FORMAT_D24S8_UINT: return VK_FORMAT_D24_UNORM_S8_UINT;
} }
} }
VkColorSpaceKHR vkGryphnColorSpaceToVulkanColorSpace(gnColorSpace colorSpace) { VkColorSpaceKHR vkGryphnColorSpaceToVulkanColorSpace(gnColorSpace colorSpace) {

View File

@@ -1,7 +1,7 @@
#include "gryphn_render_pass_descriptor.h" #include "gryphn_render_pass_descriptor.h"
#include "core/gryphn_platform_functions.h" #include "core/gryphn_platform_functions.h"
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info) { gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info) {
*renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t)); *renderPass = malloc(sizeof(struct gnRenderPassDescriptor_t));
(*renderPass)->device = device; (*renderPass)->device = device;
(*renderPass)->info = info; (*renderPass)->info = info;

View File

@@ -4,12 +4,14 @@
#include "utils/gryphn_error_code.h" #include "utils/gryphn_error_code.h"
#include "core/gryphn_handles.h" #include "core/gryphn_handles.h"
typedef enum gnRenderPassStage_e { typedef enum gnRenderPassStage {
GN_COLOR_ATTACHMENT_OUTPUT = 0x00000400 GN_COLOR_ATTACHMENT_OUTPUT = 1,
GN_EARLY_FRAGMENT_TEST = 2
} gnRenderPassStage; // I stole these from vulkan to make that conversion easier } gnRenderPassStage; // I stole these from vulkan to make that conversion easier
typedef enum gnRenderPassAccess_e { typedef enum gnRenderPassAccess {
GN_COLOR_ATTACHMENT_WRITE = 0x00000100 GN_COLOR_ATTACHMENT_WRITE = 1,
GN_DEPTH_STENCIL_WRITE = 2
} gnRenderPassAccess; } gnRenderPassAccess;
typedef enum gnLoadOperation_e { typedef enum gnLoadOperation_e {
@@ -39,7 +41,8 @@ typedef struct gnSubpassAttachmentInfo_t {
typedef struct gnSubpassInfo_t { typedef struct gnSubpassInfo_t {
uint32_t colorAttachmentCount; uint32_t colorAttachmentCount;
struct gnSubpassAttachmentInfo_t* colorAttachments; gnSubpassAttachmentInfo* colorAttachments;
gnSubpassAttachmentInfo* depthAttachment;
} gnSubpassInfo; } gnSubpassInfo;
#define GN_SUBPASS_EXTERNAL -1 #define GN_SUBPASS_EXTERNAL -1
@@ -47,31 +50,31 @@ typedef struct gnSubpassInfo_t {
typedef struct gnSubpassDependencyInfo_t { typedef struct gnSubpassDependencyInfo_t {
int source, destination; int source, destination;
enum gnRenderPassStage_e soruceStageMask; gnRenderPassStage soruceStageMask;
enum gnRenderPassAccess_e sourceAccessMask; gnRenderPassAccess sourceAccessMask;
enum gnRenderPassStage_e destinationStageMask; gnRenderPassStage destinationStageMask;
enum gnRenderPassAccess_e destinationAccessMask; gnRenderPassAccess destinationAccessMask;
} gnSubpassDependencyInfo; } gnSubpassDependencyInfo;
typedef struct gnRenderPassDescriptorInfo_t { typedef struct gnRenderPassDescriptorInfo {
uint32_t attachmentCount; uint32_t attachmentCount;
struct gnRenderPassAttachmentInfo_t* attachmentInfos; gnRenderPassAttachmentInfo* attachmentInfos;
uint32_t subpassCount; uint32_t subpassCount;
struct gnSubpassInfo_t* subpassInfos; gnSubpassInfo* subpassInfos;
uint32_t dependencyCount; uint32_t dependencyCount;
struct gnSubpassDependencyInfo_t* dependencies; gnSubpassDependencyInfo* dependencies;
} gnRenderPassDescriptorInfo; } gnRenderPassDescriptorInfo;
#ifdef GN_REVEAL_IMPL #ifdef GN_REVEAL_IMPL
struct gnRenderPassDescriptor_t { struct gnRenderPassDescriptor_t {
struct gnPlatformRenderPassDescriptor_t* renderPassDescriptor; struct gnPlatformRenderPassDescriptor_t* renderPassDescriptor;
struct gnRenderPassDescriptorInfo_t info; gnRenderPassDescriptorInfo info;
struct gnOutputDevice_t* device; gnDeviceHandle device;
}; };
#endif #endif
gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, struct gnRenderPassDescriptorInfo_t info); gnReturnCode gnCreateRenderPassDescriptor(gnRenderPassDescriptorHandle* renderPass, gnOutputDeviceHandle device, gnRenderPassDescriptorInfo info);
void gnDestroyRenderPassDescriptor(gnRenderPassDescriptorHandle renderPass); void gnDestroyRenderPassDescriptor(gnRenderPassDescriptorHandle renderPass);

View File

@@ -1,17 +1,18 @@
#pragma once #pragma once
#include "stdint.h" #include "stdint.h"
#include "core/sync/fence/gryphn_fence.h" #include "core/renderpass/gryphn_render_pass_descriptor.h"
#include "core/gryphn_handles.h"
typedef struct gnSubmitInfo_t { typedef struct gnSubmitInfo_t {
uint32_t waitCount; uint32_t waitCount;
enum gnRenderPassStage_e* waitStages; gnRenderPassStage* waitStages;
gnSemaphoreHandle* waitSemaphores; gnSemaphoreHandle* waitSemaphores;
uint32_t signalCount; uint32_t signalCount;
gnSemaphoreHandle* signalSemaphores; gnSemaphoreHandle* signalSemaphores;
uint32_t commandBufferCount; uint32_t commandBufferCount;
gnCommandBufferHandle* commandBuffers; gnCommandBufferHandle* commandBuffers;
uint32_t queueIndex; uint32_t queueIndex;
struct gnFence_t* fence; gnFenceHandle fence;
} gnSubmitInfo; } gnSubmitInfo;
gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info); gnReturnCode gnSubmit(gnOutputDevice device, gnSubmitInfo info);

View File

@@ -4,6 +4,7 @@
gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info) { gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info) {
*texture = malloc(sizeof(struct gnTexture_t)); *texture = malloc(sizeof(struct gnTexture_t));
(*texture)->device = device; (*texture)->device = device;
(*texture)->info = info;
return device->deviceFunctions->_gnCreateTexture(*texture, device, info); return device->deviceFunctions->_gnCreateTexture(*texture, device, info);
} }

View File

@@ -29,6 +29,7 @@ typedef struct gnTextureInfo {
struct gnTexture_t { struct gnTexture_t {
struct gnPlatformTexture_t* texture; struct gnPlatformTexture_t* texture;
gnDeviceHandle device; gnDeviceHandle device;
gnTextureInfo info;
}; };
#endif #endif