reuse command buffers flag
This commit is contained in:
@@ -5,7 +5,9 @@
|
||||
#import <Metal/MTLCommandEncoder.h>
|
||||
|
||||
typedef struct gnPlatformCommandBuffer_t {
|
||||
gnBool isIndirectCommandBuffer;
|
||||
id<MTLCommandBuffer> commandBuffer;
|
||||
|
||||
id<MTLCommandEncoder> encoder;
|
||||
gnGraphicsPipeline boundGraphcisPipeline;
|
||||
gnBufferHandle indexBuffer;
|
||||
@@ -13,5 +15,7 @@ typedef struct gnPlatformCommandBuffer_t {
|
||||
|
||||
gnReturnCode allocateMetalCommandBuffers(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPool pool);
|
||||
void resetMetalCommandBuffer(gnCommandBuffer commandBuffer);
|
||||
void resetMetalCommandBuffer_validated(gnCommandBuffer commandBuffer);
|
||||
gnReturnCode beginMetalCommandBuffer(gnCommandBuffer commandBuffer);
|
||||
gnReturnCode endMetalCommandBuffer(gnCommandBuffer commandBuffer);
|
||||
void destroyMetalCommandBuffer(gnCommandBuffer commandBuffer);
|
||||
|
@@ -1,15 +1,24 @@
|
||||
#include "metal_command_buffer.h"
|
||||
#include "commands/command_pool/metal_command_pool.h"
|
||||
#include "debugger/gryphn_debugger.h"
|
||||
#include "instance/gryphn_instance.h"
|
||||
#import <Metal/Metal.h>
|
||||
|
||||
gnReturnCode allocateMetalCommandBuffers(gnCommandBufferHandle* commandBuffers, uint32_t count, gnCommandPool pool) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer)); }
|
||||
commandBuffers[i]->commandBuffer = malloc(sizeof(gnPlatformCommandBuffer));
|
||||
commandBuffers[i]->commandBuffer->commandBuffer = [pool->commandPool->commandQueue commandBuffer];
|
||||
|
||||
// write a command log at some point
|
||||
if ((pool->info.flags & GN_REUSE_COMMAND_BUFFERS) == GN_REUSE_COMMAND_BUFFERS)
|
||||
commandBuffers[i]->commandBuffer->isIndirectCommandBuffer = gnTrue;
|
||||
}
|
||||
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
void resetMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
commandBuffer->commandBuffer->commandBuffer = [commandBuffer->commandPool->commandPool->commandQueue commandBuffer];
|
||||
if (commandBuffer->commandBuffer->isIndirectCommandBuffer)
|
||||
commandBuffer->commandBuffer->commandBuffer = [commandBuffer->commandPool->commandPool->commandQueue commandBuffer];
|
||||
}
|
||||
gnReturnCode beginMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
commandBuffer->commandBuffer->boundGraphcisPipeline = NULL;
|
||||
@@ -17,7 +26,8 @@ gnReturnCode beginMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
return GN_SUCCESS;
|
||||
}
|
||||
|
||||
gnReturnCode endMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
// [commandBuffer->commandBuffer->commandBuffer commit];
|
||||
return GN_SUCCESS;
|
||||
gnReturnCode endMetalCommandBuffer(gnCommandBuffer commandBuffer) { return GN_SUCCESS; }
|
||||
|
||||
void destroyMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
[commandBuffer->commandBuffer->commandBuffer release];
|
||||
}
|
||||
|
@@ -53,9 +53,8 @@ gnReturnCode createMetalFramebuffer(gnFramebuffer framebuffer, gnOutputDevice de
|
||||
wasDepthStencil = gnTrue;
|
||||
}
|
||||
if (isStencilFormat(info.renderPassDescriptor->info.attachmentInfos[i].format)) {
|
||||
gnDebuggerSetErrorMessage(device->instance->debugger, (gnMessageData){
|
||||
.message = gnCreateString("Stencil attachments are not currently supported in metal (get on this)")
|
||||
});
|
||||
MTLRenderPassStencilAttachmentDescriptor* stencilAttachment = framebuffer->framebuffer->framebuffer.stencilAttachment;
|
||||
stencilAttachment.texture = info.attachments[i]->texture->texture;
|
||||
wasDepthStencil = gnTrue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user