reuse command buffers flag
This commit is contained in:
@@ -8,6 +8,7 @@ gnCommandFunctions loadMetalCommandFunctions() {
|
||||
._gnBeginCommandBuffer = beginMetalCommandBuffer,
|
||||
._gnResetCommandBuffer = resetMetalCommandBuffer,
|
||||
._gnEndCommandBuffer = endMetalCommandBuffer,
|
||||
._gnDestroyCommandBuffer = destroyMetalCommandBuffer,
|
||||
|
||||
._gnCommandBeginRenderPass = metelBeginRenderPass,
|
||||
._gnCommandEndRenderPass = endMetalRenderPass,
|
||||
|
@@ -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,14 +1,23 @@
|
||||
#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) {
|
||||
if (commandBuffer->commandBuffer->isIndirectCommandBuffer)
|
||||
commandBuffer->commandBuffer->commandBuffer = [commandBuffer->commandPool->commandPool->commandQueue commandBuffer];
|
||||
}
|
||||
gnReturnCode beginMetalCommandBuffer(gnCommandBuffer commandBuffer) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,7 @@ gnCommandFunctions loadVulkanCommandFunctions() {
|
||||
._gnBeginCommandBuffer = beginCommandBuffer,
|
||||
._gnResetCommandBuffer = resetCommandBuffer,
|
||||
._gnEndCommandBuffer = endCommandBuffer,
|
||||
._gnDestroyCommandBuffer = destroyVulkanCommandBuffer,
|
||||
|
||||
._gnCommandBeginRenderPass = beginRenderPass,
|
||||
._gnCommandEndRenderPass = endRenderPass,
|
||||
|
@@ -78,3 +78,7 @@ void VkEndTransferOperation(VkCommandBuffer transferBuffer, VkCommandPool pool,
|
||||
vkQueueWaitIdle(syncQueue);
|
||||
vkFreeCommandBuffers(device, pool, 1, &transferBuffer);
|
||||
}
|
||||
|
||||
void destroyVulkanCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
vkFreeCommandBuffers(commandBuffer->commandPool->device->outputDevice->device, commandBuffer->commandPool->commandPool->commandPool, 1, &commandBuffer->commandBuffer->buffer);
|
||||
}
|
||||
|
@@ -19,3 +19,4 @@ gnReturnCode allocateCommandBuffers(gnCommandBufferHandle* commandBuffers, uint3
|
||||
gnReturnCode beginCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
void resetCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
gnReturnCode endCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
void destroyVulkanCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
|
@@ -30,3 +30,7 @@ gnReturnCode gnBeginCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
gnReturnCode gnEndCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
return commandBuffer->commandPool->instance->callingLayer->commandFunctions._gnEndCommandBuffer(commandBuffer);
|
||||
}
|
||||
|
||||
void gnDestroyCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
commandBuffer->commandPool->instance->callingLayer->commandFunctions._gnDestroyCommandBuffer(commandBuffer);
|
||||
}
|
||||
|
@@ -27,3 +27,4 @@ gnReturnCode gnCommandPoolAllocateCommandBuffersFromList(gnCommandBufferArrayLis
|
||||
void gnResetCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
gnReturnCode gnBeginCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
gnReturnCode gnEndCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
void gnDestroyCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
|
@@ -8,6 +8,7 @@ gnReturnCode gnCreateCommandPool(gnCommandPoolHandle* commandPool, gnOutputDevic
|
||||
(*commandPool)->instance = device->instance;
|
||||
|
||||
(*commandPool)->device = device;
|
||||
(*commandPool)->info = info;
|
||||
return device->instance->callingLayer->deviceFunctions._gnCreateCommandPool((*commandPool), device, info);
|
||||
}
|
||||
|
||||
|
@@ -3,8 +3,14 @@
|
||||
#include <utils/gryphn_error_code.h>
|
||||
#include "gryphn_handles.h"
|
||||
|
||||
typedef enum gnCommandPoolFlags {
|
||||
GN_NO_FLAGS = 0,
|
||||
GN_REUSE_COMMAND_BUFFERS = 1
|
||||
} gnCommandPoolFlags;
|
||||
|
||||
typedef struct gnCommandPoolInfo {
|
||||
uint32_t queueIndex;
|
||||
gnCommandPoolFlags flags;
|
||||
} gnCommandPoolInfo;
|
||||
|
||||
#ifdef GN_REVEAL_IMPL
|
||||
@@ -12,6 +18,7 @@ struct gnCommandPool_t {
|
||||
struct gnPlatformCommandPool_t* commandPool;
|
||||
gnDevice device;
|
||||
gnInstance instance;
|
||||
gnCommandPoolInfo info;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@@ -15,6 +15,7 @@ typedef struct gnCommandFunctions_t {
|
||||
gnReturnCode (*_gnBeginCommandBuffer)(gnCommandBufferHandle commandBuffer);
|
||||
void (*_gnResetCommandBuffer)(gnCommandBufferHandle commandBuffer);
|
||||
gnReturnCode (*_gnEndCommandBuffer)(gnCommandBufferHandle commandBuffer);
|
||||
void (*_gnDestroyCommandBuffer)(gnCommandBufferHandle commandBuffer);
|
||||
|
||||
void (*_gnCommandBeginRenderPass)(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo);
|
||||
void (*_gnCommandEndRenderPass)(gnCommandBufferHandle buffer);
|
||||
|
@@ -8,3 +8,4 @@ target_include_directories(GryphnFunctionValidator PUBLIC ${CMAKE_CURRENT_SOURCE
|
||||
target_include_directories(GryphnFunctionValidator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../)
|
||||
target_include_directories(GryphnFunctionValidator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../core/src/)
|
||||
target_include_directories(GryphnFunctionValidator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../platform/)
|
||||
target_include_directories(GryphnFunctionValidator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "function_loader.h"
|
||||
#include "instance_functions.h"
|
||||
#include "device_functions.h"
|
||||
#include "command_functions.h"
|
||||
#include "src/instance_functions.h"
|
||||
#include "src/device_functions.h"
|
||||
#include "src/command_functions.h"
|
||||
|
||||
gnInstanceFunctions loadFunctionLoaderInstanceFunctions() {
|
||||
return (gnInstanceFunctions){
|
||||
@@ -94,6 +94,7 @@ gnCommandFunctions loadFunctionLoaderCommandFunctions() {
|
||||
._gnBeginCommandBuffer = checkBeginCommandBuffer,
|
||||
._gnResetCommandBuffer = checkResetCommandBuffer,
|
||||
._gnEndCommandBuffer = checkEndCommandBuffer,
|
||||
._gnDestroyCommandBuffer = checkDestroyCommandBuffer,
|
||||
|
||||
._gnCommandBeginRenderPass = checkCommandBeginRenderPass,
|
||||
._gnCommandEndRenderPass = checkCommandEndRenderPass,
|
||||
|
@@ -21,6 +21,9 @@ void checkResetCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
gnReturnCode checkEndCommandBuffer(gnCommandBufferHandle commandBuffer) {
|
||||
CHECK_FUNCTION_WITH_RETURN_CODE_COMMAND(commandBuffer->instance, _gnEndCommandBuffer, commandBuffer);
|
||||
}
|
||||
void checkDestroyCommandBuffer(gnCommandBufferHandle buffer) {
|
||||
CHECK_VOID_FUNCTION_COMMAND(buffer->instance, _gnDestroyCommandBuffer, buffer);
|
||||
}
|
||||
|
||||
void checkCommandBeginRenderPass(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo) {
|
||||
CHECK_VOID_FUNCTION_COMMAND(buffer->instance, _gnCommandBeginRenderPass, buffer, passInfo);
|
@@ -4,6 +4,7 @@ gnReturnCode checkCommandPoolAllocateCommandBuffers(gnCommandBufferHandle* comma
|
||||
gnReturnCode checkBeginCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
void checkResetCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
gnReturnCode checkEndCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
void checkDestroyCommandBuffer(gnCommandBufferHandle commandBuffer);
|
||||
|
||||
void checkCommandBeginRenderPass(gnCommandBufferHandle buffer, gnRenderPassInfo passInfo);
|
||||
void checkCommandEndRenderPass(gnCommandBufferHandle buffer);
|
Reference in New Issue
Block a user