gryphn texture API

This commit is contained in:
Gregory Wells
2025-06-14 21:29:21 -04:00
parent bc64fc0731
commit 8bc0f4afbc
7 changed files with 19 additions and 4 deletions

View File

@@ -8,7 +8,7 @@ gnReturnCode gnCreateFramebufferFn(struct gnFramebuffer_t* framebuffer, struct g
VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount); VkImageView* attachments = malloc(sizeof(VkImageView) * info.attachmentCount);
for (int i = 0; i < info.attachmentCount; i++) for (int i = 0; i < info.attachmentCount; i++)
attachments[i] = info.attachments[i]->texture->imageView; attachments[i] = info.attachments[i]->texture->image.imageView;
VkFramebufferCreateInfo framebufferInfo = { VkFramebufferCreateInfo framebufferInfo = {
.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,

View File

@@ -116,8 +116,8 @@ gnReturnCode gnCreatePresentationQueueFn(gnPresentationQueueHandle presentationQ
if (vkCreateImageView(device->outputDevice->device, &imageViewCreateInfo, NULL, &presentationQueue->presentationQueue->swapChainImageViews[i]) != VK_SUCCESS) if (vkCreateImageView(device->outputDevice->device, &imageViewCreateInfo, NULL, &presentationQueue->presentationQueue->swapChainImageViews[i]) != VK_SUCCESS)
return GN_FAILED_TO_CREATE_IMAGE_VIEW; return GN_FAILED_TO_CREATE_IMAGE_VIEW;
presentationQueue->images[i]->texture->image = presentationQueue->presentationQueue->swapChainImages[i]; presentationQueue->images[i]->texture->image.image = presentationQueue->presentationQueue->swapChainImages[i];
presentationQueue->images[i]->texture->imageView = presentationQueue->presentationQueue->swapChainImageViews[i]; presentationQueue->images[i]->texture->image.imageView = presentationQueue->presentationQueue->swapChainImageViews[i];
} }
return GN_SUCCESS; return GN_SUCCESS;

View File

@@ -115,7 +115,7 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, .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 = 100, .width = info.width,
.height = info.height, .height = info.height,
.depth = 1 .depth = 1
}, },
@@ -147,6 +147,8 @@ gnReturnCode gnCreateTextureFn(gnTexture texture, gnDevice device, const gnTextu
texture->texture->width = info.width; texture->texture->width = info.width;
texture->texture->height = info.height; texture->texture->height = info.height;
texture->texture->beenWrittenToo = gnFalse;
return GN_SUCCESS; return GN_SUCCESS;
} }

View File

@@ -93,6 +93,8 @@ typedef struct gnDeviceFunctions_t {
void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo); void (*_gnUpdateBufferUniform)(gnUniform uniform, gnBufferUniformInfo* bufferInfo);
gnReturnCode (*_gnCreateTexture)(gnTexture texture, gnDevice device, const gnTextureInfo info); gnReturnCode (*_gnCreateTexture)(gnTexture texture, gnDevice device, const gnTextureInfo info);
void (*_gnTextureData)(gnTextureHandle texture, void* pixelData);
void (*_gnDestroyTexture)(gnTexture texture);
gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device); gnReturnCode (*_gnCreateFence)(gnFenceHandle fence, gnOutputDeviceHandle device);
void (*_gnSignalFence)(gnFenceHandle fence); void (*_gnSignalFence)(gnFenceHandle fence);

View File

@@ -94,6 +94,8 @@ void gnLoadDeviceFunctions(struct gnDynamicLibrary_t* lib, struct gnDeviceFuncti
gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn"); gnLoadDLLFunction(lib, functions->_gnDestroyUniformPool, "gnDestroyUniformPoolFn");
gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn"); gnLoadDLLFunction(lib, functions->_gnUpdateBufferUniform, "gnUpdateBufferUniformFn");
gnLoadDLLFunction(lib, functions->_gnCreateTexture, "gnCreateTextureFn"); gnLoadDLLFunction(lib, functions->_gnCreateTexture, "gnCreateTextureFn");
gnLoadDLLFunction(lib, functions->_gnTextureData, "gnTextureDataFn");
gnLoadDLLFunction(lib, functions->_gnDestroyTexture, "gnDestroyTextureFn");
gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn"); gnLoadDLLFunction(lib, functions->_gnCreateFence, "gnCreateFenceFn");
gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn"); gnLoadDLLFunction(lib, functions->_gnSignalFence, "gnSignalFenceFn");
gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn"); gnLoadDLLFunction(lib, functions->_gnWaitForFence, "gnWaitForFenceFn");

View File

@@ -6,3 +6,10 @@ gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextur
(*texture)->device = device; (*texture)->device = device;
return device->deviceFunctions->_gnCreateTexture(*texture, device, info); return device->deviceFunctions->_gnCreateTexture(*texture, device, info);
} }
void gnTextureData(gnTextureHandle texture, void* pixelData) {
texture->device->deviceFunctions->_gnTextureData(texture, pixelData);
}
void gnDestroyTexture(gnTexture texture) {
texture->device->deviceFunctions->_gnDestroyTexture(texture);
}

View File

@@ -23,3 +23,5 @@ struct gnTexture_t {
#endif #endif
gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info); gnReturnCode gnCreateTexture(gnTexture* texture, gnDevice device, const gnTextureInfo info);
void gnTextureData(gnTextureHandle texture, void* pixelData);
void gnDestroyTexture(gnTexture texture);