some housekeeping
This commit is contained in:
@@ -41,6 +41,12 @@ Gryphn works to abstract away platform API functions (Vulkan, Metal, D3D11/D3D12
|
|||||||
- buffers store GPU data so that it can be used in shaders <br />
|
- buffers store GPU data so that it can be used in shaders <br />
|
||||||
- Textures:
|
- Textures:
|
||||||
- Store image data so that it can be sampled in shaders <br />
|
- Store image data so that it can be sampled in shaders <br />
|
||||||
|
# Extentions
|
||||||
|
- GN_EXT_SYNCHRONIZATION
|
||||||
|
- allows sync primatives (fence, semaphore) and sync functions (gnPresentationQueueGetImageAsync, gnSubmitSync, gnPresentSync)<br />
|
||||||
|
- Supported APIs<br />
|
||||||
|
- Vulkan <br />
|
||||||
|
- Metal* (metal support is buggy, fences are nonatomic so they cannot be used across multible threads) <br />
|
||||||
|
|
||||||
# Validation
|
# Validation
|
||||||
Gryphn its an interesting API to work with so ive attempted to put together a somewhat comprehensive set of validation tools that will tell you what you (or I) am doing wrong. Gryphn currently has support for 2 validation layers but I plan to support more in the future <br />
|
Gryphn its an interesting API to work with so ive attempted to put together a somewhat comprehensive set of validation tools that will tell you what you (or I) am doing wrong. Gryphn currently has support for 2 validation layers but I plan to support more in the future <br />
|
||||||
@@ -61,7 +67,6 @@ Gryphn validation layers are meant to be more specific so there are certain ones
|
|||||||
- APIs like OpenGL dont support the full capabilities of vulkan so things like synchronization
|
- APIs like OpenGL dont support the full capabilities of vulkan so things like synchronization
|
||||||
I currently am planning to move synchronization primatives to be an extension.
|
I currently am planning to move synchronization primatives to be an extension.
|
||||||
Planned extensions: <br />
|
Planned extensions: <br />
|
||||||
- GN_EXT_SYNCHRONIZATION, my only problem with this extension is that I might be able to fake support for things like semaphores in OpenGL, im not 100% sure yet<br />
|
|
||||||
- GN_EXT_COMPUTE, while compute pipelines might be a vulkan standard they are not an OpenGL standard so this does need to be an exension <br /><br />
|
- GN_EXT_COMPUTE, while compute pipelines might be a vulkan standard they are not an OpenGL standard so this does need to be an exension <br /><br />
|
||||||
- I will add more exensions as Gryphn grows in complexity, my current biggest task is going to be moving synchronization primatives over into extension land and not a core part of the Gryphn standard. My biggest problem with exentensions is that I don't want them to be something like, this feature is only supported on Vulkan which I think removes part of the reason for my making this project.
|
- I will add more exensions as Gryphn grows in complexity, my current biggest task is going to be moving synchronization primatives over into extension land and not a core part of the Gryphn standard. My biggest problem with exentensions is that I don't want them to be something like, this feature is only supported on Vulkan which I think removes part of the reason for my making this project.
|
||||||
#### Standardization
|
#### Standardization
|
||||||
|
@@ -103,8 +103,7 @@ gnReturnCode createMetalGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gn
|
|||||||
|
|
||||||
MTLDepthStencilDescriptor* depthStencilDesc = [[MTLDepthStencilDescriptor alloc] init];
|
MTLDepthStencilDescriptor* depthStencilDesc = [[MTLDepthStencilDescriptor alloc] init];
|
||||||
depthStencilDesc.depthWriteEnabled = info.depthStencil.depthWriteEnable;
|
depthStencilDesc.depthWriteEnabled = info.depthStencil.depthWriteEnable;
|
||||||
depthStencilDesc.depthCompareFunction = MTLCompareFunctionLess;
|
depthStencilDesc.depthCompareFunction = mtlGrypnCompareOperation(info.depthStencil.operation);
|
||||||
|
|
||||||
graphicsPipeline->graphicsPipeline->depthState = [device->outputDevice->device newDepthStencilStateWithDescriptor:depthStencilDesc];
|
graphicsPipeline->graphicsPipeline->depthState = [device->outputDevice->device newDepthStencilStateWithDescriptor:depthStencilDesc];
|
||||||
|
|
||||||
[descriptor setVertexDescriptor:vertexDescriptor];
|
[descriptor setVertexDescriptor:vertexDescriptor];
|
||||||
|
@@ -31,14 +31,6 @@ gnReturnCode createMetalShaderModule(gnShaderModule module, gnDevice device, gnS
|
|||||||
|
|
||||||
spvc_compiler_create_shader_resources(compiler, &resources);
|
spvc_compiler_create_shader_resources(compiler, &resources);
|
||||||
|
|
||||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_SHADER_RECORD_BUFFER, &list, &count);
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
uint32_t set = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationDescriptorSet),
|
|
||||||
binding = spvc_compiler_get_decoration(compiler, list[i].id, SpvDecorationBinding),
|
|
||||||
mslBinding = spvc_compiler_msl_get_automatic_resource_binding(compiler, list[i].id);
|
|
||||||
printf("%s: set %ui, binding %ui, mslBinding %ui\n", list[i].name, set, binding, mslBinding);
|
|
||||||
}
|
|
||||||
|
|
||||||
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count);
|
spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_UNIFORM_BUFFER, &list, &count);
|
||||||
// [[buffer(0)]] is reserved for stage_in, [[buffer(1)]] is reserved for push_constant
|
// [[buffer(0)]] is reserved for stage_in, [[buffer(1)]] is reserved for push_constant
|
||||||
uint32_t currentBufferBinding = 2, currentTextureBinding = 0;
|
uint32_t currentBufferBinding = 2, currentTextureBinding = 0;
|
||||||
|
@@ -46,7 +46,7 @@ gnReturnCode createMetalTexture(gnTexture texture, gnDevice device, const gnText
|
|||||||
void metalTextureData(gnTextureHandle texture, void* pixelData) {
|
void metalTextureData(gnTextureHandle texture, void* pixelData) {
|
||||||
MTLRegion region = {
|
MTLRegion region = {
|
||||||
{ 0, 0, 0 },
|
{ 0, 0, 0 },
|
||||||
{texture->info.extent.width, texture->info.extent.width, texture->info.extent.depth}
|
{texture->info.extent.width, texture->info.extent.height, texture->info.extent.depth}
|
||||||
};
|
};
|
||||||
|
|
||||||
NSUInteger bytesPerRow = 4 * texture->info.extent.width; // TODO: fix this should not be set to 4
|
NSUInteger bytesPerRow = 4 * texture->info.extent.width; // TODO: fix this should not be set to 4
|
||||||
@@ -54,7 +54,6 @@ void metalTextureData(gnTextureHandle texture, void* pixelData) {
|
|||||||
mipmapLevel:0
|
mipmapLevel:0
|
||||||
withBytes:pixelData
|
withBytes:pixelData
|
||||||
bytesPerRow:bytesPerRow];
|
bytesPerRow:bytesPerRow];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void metalDestroyTexture(gnTexture texture) {
|
void metalDestroyTexture(gnTexture texture) {
|
||||||
|
@@ -87,12 +87,9 @@ gnReturnCode getVulkanPresentQueueImage(gnPresentationQueueHandle presentationQu
|
|||||||
presentationQueue->outputDevice->outputDevice->device,
|
presentationQueue->outputDevice->outputDevice->device,
|
||||||
presentationQueue->presentationQueue->swapChain,
|
presentationQueue->presentationQueue->swapChain,
|
||||||
UINT64_MAX, VK_NULL_HANDLE, presentationQueue->outputDevice->outputDevice->barrierFence, imageIndex);
|
UINT64_MAX, VK_NULL_HANDLE, presentationQueue->outputDevice->outputDevice->barrierFence, imageIndex);
|
||||||
|
|
||||||
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
if (result == VK_ERROR_OUT_OF_DATE_KHR) return GN_OUT_OF_DATE_PRESENTATION_QUEUE;
|
||||||
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
if (result == VK_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
||||||
|
|
||||||
vkWaitForFences(presentationQueue->outputDevice->outputDevice->device, 1, &presentationQueue->outputDevice->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
vkWaitForFences(presentationQueue->outputDevice->outputDevice->device, 1, &presentationQueue->outputDevice->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
||||||
|
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,6 +6,7 @@ gnReturnCode createFence(gnFence fence, gnDevice device) {
|
|||||||
VkFenceCreateInfo fenceInfo = {
|
VkFenceCreateInfo fenceInfo = {
|
||||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
|
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
|
||||||
};
|
};
|
||||||
|
|
||||||
if (vkCreateFence(device->outputDevice->device, &fenceInfo, NULL, &fence->fence->fence) != VK_SUCCESS)
|
if (vkCreateFence(device->outputDevice->device, &fenceInfo, NULL, &fence->fence->fence) != VK_SUCCESS)
|
||||||
return GN_FAILED_TO_CREATE_FENCE;
|
return GN_FAILED_TO_CREATE_FENCE;
|
||||||
return GN_SUCCESS;
|
return GN_SUCCESS;
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#define GN_NULL_HANDLE 0
|
||||||
|
|
||||||
#define GN_HANDLE(type) \
|
#define GN_HANDLE(type) \
|
||||||
typedef struct type##_t* type##Handle; \
|
typedef struct type##_t* type##Handle; \
|
||||||
typedef struct type##_t* type
|
typedef struct type##_t* type
|
||||||
|
@@ -9,7 +9,6 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
|||||||
*instance = malloc(sizeof(struct gnInstance_t));
|
*instance = malloc(sizeof(struct gnInstance_t));
|
||||||
|
|
||||||
(*instance)->layers = loaderLayerArrayListCreate();
|
(*instance)->layers = loaderLayerArrayListCreate();
|
||||||
|
|
||||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||||
.api = info.renderingAPI,
|
.api = info.renderingAPI,
|
||||||
.layerToLoad = api_layer
|
.layerToLoad = api_layer
|
||||||
|
@@ -27,6 +27,7 @@ CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) {
|
|||||||
[layer setFramebufferOnly:YES];
|
[layer setFramebufferOnly:YES];
|
||||||
[view setLayer:layer];
|
[view setLayer:layer];
|
||||||
[view setWantsLayer:YES];
|
[view setWantsLayer:YES];
|
||||||
|
// [layer setDisplaySyncEnabled:NO];
|
||||||
CGSize viewSize = view.bounds.size;
|
CGSize viewSize = view.bounds.size;
|
||||||
CGFloat scale = window.screen.backingScaleFactor;
|
CGFloat scale = window.screen.backingScaleFactor;
|
||||||
layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||||
|
Reference in New Issue
Block a user