#pragma once #include #include #include #include "constantlocation.h" #include "graphics.h" /*! \file pipeline.h \brief Provides functions for creating and using pipelines which configure the GPU for rendering. */ #ifdef __cplusplus extern "C" { #endif struct kinc_g5_shader; // identical to kinc_g4_blending_factor_t typedef enum { KINC_G5_BLEND_ONE, KINC_G5_BLEND_ZERO, KINC_G5_BLEND_SOURCE_ALPHA, KINC_G5_BLEND_DEST_ALPHA, KINC_G5_BLEND_INV_SOURCE_ALPHA, KINC_G5_BLEND_INV_DEST_ALPHA, KINC_G5_BLEND_SOURCE_COLOR, KINC_G5_BLEND_DEST_COLOR, KINC_G5_BLEND_INV_SOURCE_COLOR, KINC_G5_BLEND_INV_DEST_COLOR, KINC_G5_BLEND_CONSTANT, KINC_G5_BLEND_INV_CONSTANT } kinc_g5_blending_factor_t; // identical to kinc_g4_blending_operation_t typedef enum { KINC_G5_BLENDOP_ADD, KINC_G5_BLENDOP_SUBTRACT, KINC_G5_BLENDOP_REVERSE_SUBTRACT, KINC_G5_BLENDOP_MIN, KINC_G5_BLENDOP_MAX } kinc_g5_blending_operation_t; typedef enum kinc_g5_cull_mode { KINC_G5_CULL_MODE_CLOCKWISE, KINC_G5_CULL_MODE_COUNTERCLOCKWISE, KINC_G5_CULL_MODE_NEVER } kinc_g5_cull_mode_t; typedef enum kinc_g5_compare_mode { KINC_G5_COMPARE_MODE_ALWAYS, KINC_G5_COMPARE_MODE_NEVER, KINC_G5_COMPARE_MODE_EQUAL, KINC_G5_COMPARE_MODE_NOT_EQUAL, KINC_G5_COMPARE_MODE_LESS, KINC_G5_COMPARE_MODE_LESS_EQUAL, KINC_G5_COMPARE_MODE_GREATER, KINC_G5_COMPARE_MODE_GREATER_EQUAL } kinc_g5_compare_mode_t; typedef enum kinc_g5_stencil_action { KINC_G5_STENCIL_ACTION_KEEP, KINC_G5_STENCIL_ACTION_ZERO, KINC_G5_STENCIL_ACTION_REPLACE, KINC_G5_STENCIL_ACTION_INCREMENT, KINC_G5_STENCIL_ACTION_INCREMENT_WRAP, KINC_G5_STENCIL_ACTION_DECREMENT, KINC_G5_STENCIL_ACTION_DECREMENT_WRAP, KINC_G5_STENCIL_ACTION_INVERT } kinc_g5_stencil_action_t; typedef struct kinc_g5_pipeline { kinc_g5_vertex_structure_t *inputLayout[16]; struct kinc_g5_shader *vertexShader; struct kinc_g5_shader *fragmentShader; struct kinc_g5_shader *geometryShader; struct kinc_g5_shader *tessellationControlShader; struct kinc_g5_shader *tessellationEvaluationShader; kinc_g5_cull_mode_t cullMode; bool depthWrite; kinc_g5_compare_mode_t depthMode; kinc_g5_compare_mode_t stencilMode; kinc_g5_stencil_action_t stencilBothPass; kinc_g5_stencil_action_t stencilDepthFail; kinc_g5_stencil_action_t stencilFail; int stencilReferenceValue; int stencilReadMask; int stencilWriteMask; // One, Zero deactivates blending kinc_g5_blending_factor_t blend_source; kinc_g5_blending_factor_t blend_destination; kinc_g5_blending_operation_t blend_operation; kinc_g5_blending_factor_t alpha_blend_source; kinc_g5_blending_factor_t alpha_blend_destination; kinc_g5_blending_operation_t alpha_blend_operation; bool colorWriteMaskRed[8]; // Per render target bool colorWriteMaskGreen[8]; bool colorWriteMaskBlue[8]; bool colorWriteMaskAlpha[8]; int colorAttachmentCount; kinc_g5_render_target_format_t colorAttachment[8]; int depthAttachmentBits; int stencilAttachmentBits; bool conservativeRasterization; PipelineState5Impl impl; } kinc_g5_pipeline_t; /// /// Initializes a pipeline. /// /// The pipeline to initialize KINC_FUNC void kinc_g5_pipeline_init(kinc_g5_pipeline_t *pipeline); void kinc_g5_internal_pipeline_init(kinc_g5_pipeline_t *pipeline); /// /// Destroys a pipeline. /// /// The pipeline to destroy KINC_FUNC void kinc_g5_pipeline_destroy(kinc_g5_pipeline_t *pipeline); /// /// Compiles a pipeline. After a pipeline has been compiled it is finalized. It cannot be compiled again and further changes to the pipeline are ignored. /// /// The pipeline to compile KINC_FUNC void kinc_g5_pipeline_compile(kinc_g5_pipeline_t *pipeline); #ifndef KINC_KONG /// /// Searches for a constant/uniform and returns a constant-location which can be used to change the constant/uniform. /// /// The pipeline to search in /// The name of the constant/uniform to find /// The constant-location of the constant/uniform KINC_FUNC kinc_g5_constant_location_t kinc_g5_pipeline_get_constant_location(kinc_g5_pipeline_t *pipeline, const char *name); /// /// Searches for a texture-declaration and returns a texture-unit which can be used to assign a texture. /// /// The pipeline to search in /// The name of the texture-declaration to search for /// The texture-unit of the texture-declaration KINC_FUNC kinc_g5_texture_unit_t kinc_g5_pipeline_get_texture_unit(kinc_g5_pipeline_t *pipeline, const char *name); #endif #ifdef __cplusplus } #endif