finish depth buffering

This commit is contained in:
Gregory Wells
2025-06-17 15:21:16 -04:00
parent 86f2ac6e5a
commit e4e182610a
4 changed files with 116 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
#include "gryphn_graphics_pipeline.h"
#include "core/gryphn_platform_functions.h"
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, struct gnOutputDevice_t* device, struct gnGraphicsPipelineInfo_t info) {
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnDevice device, gnGraphicsPipelineInfo info) {
*graphicsPipeline = malloc(sizeof(struct gnGraphicsPipeline_t));
(*graphicsPipeline)->device = device;
(*graphicsPipeline)->info = info;

View File

@@ -14,14 +14,25 @@ typedef enum gnDynamicState_e {
GN_DYNAMIC_STATE_MAX
} gnDynamicState;
typedef struct gnDynamicStateInfo_t {
typedef struct gnDynamicStateInfo {
uint32_t dynamicStateCount;
enum gnDynamicState_e* dynamicStates;
} gnDynamicStateInfo;
typedef enum gnPrimitiveType_e {
typedef enum gnPrimitiveType {
GN_PRIMITIVE_POINTS, GN_PRIMITIVE_LINES, GN_PRIMITIVE_LINE_STRIP, GN_PRIMITIVE_TRIANGLES, GN_PRIMITIVE_TRIANGLE_STRIP
} gnPrimativeType;
} gnPrimitiveType;
typedef enum gnBlendFactor_e {
GN_BLEND_FACTOR_ZERO,
GN_BLEND_FACTOR_ONE,
GN_BLEND_FACTOR_SRC_ALPHA,
GN_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
} gnBlendFactor;
typedef enum gnBlendOperation_e {
GN_OPERATION_ADD
} gnBlendOperation;
typedef struct gnViewport_t {
gnVec2 position;
@@ -47,41 +58,57 @@ typedef enum gnCullDirection_e {
GN_DIRECTION_CLOCK_WISE, GN_DIRECTION_COUNTER_CLOCK_WISE
} gnCullDirection;
typedef enum gnCompareOperation {
GN_COMPARE_NEVER, GN_COMPARE_LESS, GN_COMPARE_EQUAL,
GN_COMPARE_LESS_OR_EQUAL, GN_COMPARE_GREATER, GN_COMPARE_NOT_EQUAL,
GN_COMPARE_GREATER_OR_EQUAL, GN_COMPARE_ALWAYS
} gnCompareOperation;
typedef enum gnStencilOperation {
GN_STENCIL_KEEP, GN_STENCIL_ZERO, GN_STENCIL_REPLACE,
GN_STENCIL_INCREMENT_AND_CLAMP, GN_STENCIL_DECREMENT_AND_CLAMP,
GN_STENCIL_INVERT, GN_STENCIL_INCREMENT_AND_WRAP,
GN_STENCIL_DECREMENT_AND_WRAP,
} gnStencilOperation;
typedef struct gnCullMode_t {
enum gnCullFace_e face;
enum gnCullDirection_e direction;
} gnCullMode;
typedef enum gnBlendFactor_e {
GN_BLEND_FACTOR_ZERO,
GN_BLEND_FACTOR_ONE,
GN_BLEND_FACTOR_SRC_ALPHA,
GN_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
} gnBlendFactor;
typedef enum gnBlendOperation_e {
GN_OPERATION_ADD
} gnBlendOperation;
typedef struct gnColorBlending_t {
gnBool enable;
enum gnBlendFactor_e sourceColorBlendFactor;
enum gnBlendFactor_e sourceAlphaBlendFactor;
enum gnBlendFactor_e destinationColorBlendFactor;
enum gnBlendFactor_e destinationAlphaBlendFactor;
gnBlendFactor sourceColorBlendFactor;
gnBlendFactor sourceAlphaBlendFactor;
gnBlendFactor destinationColorBlendFactor;
gnBlendFactor destinationAlphaBlendFactor;
enum gnBlendOperation_e colorBlendOperation;
enum gnBlendOperation_e alphaBlendOperation;
gnBlendOperation colorBlendOperation;
gnBlendOperation alphaBlendOperation;
} gnColorBlending;
typedef struct gnStencilState {
gnStencilOperation failOperation, passOperation, depthFailOperation;
gnCompareOperation compareOperation;
uint32_t compareMask, writeMask, reference;
} gnStencilState;
typedef struct gnDepthStencilState {
gnBool depthTestEnable, depthWriteEnable;
gnCompareOperation operation;
gnBool stencilTestEnable;
gnStencilState front, back;
} gnDepthStencilState;
typedef struct gnGraphicsPipelineInfo_t {
struct gnDynamicStateInfo_t dynamicState;
enum gnPrimitiveType_e primitiveType;
struct gnViewport_t viewport;
struct gnScissor_t scissor;
enum gnFillMode_e fillMode;
struct gnCullMode_t cullMode;
struct gnColorBlending_t colorBlending;
gnDynamicStateInfo dynamicState;
gnPrimitiveType primitiveType;
gnViewport viewport;
gnScissor scissor;
gnFillMode fillMode;
gnCullMode cullMode;
gnColorBlending colorBlending;
gnDepthStencilState depthStencil;
uint32_t subpassIndex;
gnRenderPassDescriptorHandle renderPassDescriptor;
@@ -101,5 +128,5 @@ struct gnGraphicsPipeline_t {
};
#endif
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnOutputDeviceHandle device, struct gnGraphicsPipelineInfo_t info);
gnReturnCode gnCreateGraphicsPipeline(gnGraphicsPipelineHandle* graphicsPipeline, gnOutputDeviceHandle device, gnGraphicsPipelineInfo info);
void gnDestroyGraphicsPipeline(gnGraphicsPipelineHandle graphicsPipeline);