some housekeeping
This commit is contained in:
@@ -103,8 +103,7 @@ gnReturnCode createMetalGraphicsPipeline(gnGraphicsPipeline graphicsPipeline, gn
|
||||
|
||||
MTLDepthStencilDescriptor* depthStencilDesc = [[MTLDepthStencilDescriptor alloc] init];
|
||||
depthStencilDesc.depthWriteEnabled = info.depthStencil.depthWriteEnable;
|
||||
depthStencilDesc.depthCompareFunction = MTLCompareFunctionLess;
|
||||
|
||||
depthStencilDesc.depthCompareFunction = mtlGrypnCompareOperation(info.depthStencil.operation);
|
||||
graphicsPipeline->graphicsPipeline->depthState = [device->outputDevice->device newDepthStencilStateWithDescriptor:depthStencilDesc];
|
||||
|
||||
[descriptor setVertexDescriptor:vertexDescriptor];
|
||||
|
@@ -31,14 +31,6 @@ gnReturnCode createMetalShaderModule(gnShaderModule module, gnDevice device, gnS
|
||||
|
||||
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);
|
||||
// [[buffer(0)]] is reserved for stage_in, [[buffer(1)]] is reserved for push_constant
|
||||
uint32_t currentBufferBinding = 2, currentTextureBinding = 0;
|
||||
|
@@ -46,7 +46,7 @@ gnReturnCode createMetalTexture(gnTexture texture, gnDevice device, const gnText
|
||||
void metalTextureData(gnTextureHandle texture, void* pixelData) {
|
||||
MTLRegion region = {
|
||||
{ 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
|
||||
@@ -54,7 +54,6 @@ void metalTextureData(gnTextureHandle texture, void* pixelData) {
|
||||
mipmapLevel:0
|
||||
withBytes:pixelData
|
||||
bytesPerRow:bytesPerRow];
|
||||
|
||||
}
|
||||
|
||||
void metalDestroyTexture(gnTexture texture) {
|
||||
|
@@ -87,12 +87,9 @@ gnReturnCode getVulkanPresentQueueImage(gnPresentationQueueHandle presentationQu
|
||||
presentationQueue->outputDevice->outputDevice->device,
|
||||
presentationQueue->presentationQueue->swapChain,
|
||||
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_SUBOPTIMAL_KHR) return GN_SUBOPTIMAL_PRESENTATION_QUEUE;
|
||||
|
||||
vkWaitForFences(presentationQueue->outputDevice->outputDevice->device, 1, &presentationQueue->outputDevice->outputDevice->barrierFence, VK_TRUE, UINT64_MAX);
|
||||
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
|
@@ -6,6 +6,7 @@ gnReturnCode createFence(gnFence fence, gnDevice device) {
|
||||
VkFenceCreateInfo fenceInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
|
||||
};
|
||||
|
||||
if (vkCreateFence(device->outputDevice->device, &fenceInfo, NULL, &fence->fence->fence) != VK_SUCCESS)
|
||||
return GN_FAILED_TO_CREATE_FENCE;
|
||||
return GN_SUCCESS;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define GN_NULL_HANDLE 0
|
||||
|
||||
#define GN_HANDLE(type) \
|
||||
typedef struct type##_t* type##Handle; \
|
||||
typedef struct type##_t* type
|
||||
|
@@ -9,7 +9,6 @@ gnReturnCode gnCreateInstance(gnInstanceHandle* instance, gnInstanceInfo info) {
|
||||
*instance = malloc(sizeof(struct gnInstance_t));
|
||||
|
||||
(*instance)->layers = loaderLayerArrayListCreate();
|
||||
|
||||
loaderLayerArrayListAdd(&(*instance)->layers, loadLayer((loaderInfo){
|
||||
.api = info.renderingAPI,
|
||||
.layerToLoad = api_layer
|
||||
|
@@ -27,6 +27,7 @@ CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) {
|
||||
[layer setFramebufferOnly:YES];
|
||||
[view setLayer:layer];
|
||||
[view setWantsLayer:YES];
|
||||
// [layer setDisplaySyncEnabled:NO];
|
||||
CGSize viewSize = view.bounds.size;
|
||||
CGFloat scale = window.screen.backingScaleFactor;
|
||||
layer.pixelFormat = MTLPixelFormatBGRA8Unorm;
|
||||
|
Reference in New Issue
Block a user