diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-16 15:01:07 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:10 +0300 |
commit | 2ae1c895a2f7590d0783a27176085da45ef12bc5 (patch) | |
tree | e4cb63134deaca31908b4e9ddfff96614bfa1e0e /source/blender/gpu/GPU_state.h | |
parent | 2eddfa85e00d9efa7571721e605a331ca4cd5bc6 (diff) |
GPUState: Add GL backend and state tracking but do not use it
This is just the backend work. It is not plugged in yet because it
needs more external cleanup/refactor.
Diffstat (limited to 'source/blender/gpu/GPU_state.h')
-rw-r--r-- | source/blender/gpu/GPU_state.h | 80 |
1 files changed, 69 insertions, 11 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 2a940b97104..19bb8001491 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -24,6 +24,70 @@ extern "C" { #endif +typedef enum eGPUWriteMask { + GPU_WRITE_RED = (1 << 0), + GPU_WRITE_GREEN = (1 << 1), + GPU_WRITE_BLUE = (1 << 2), + GPU_WRITE_ALPHA = (1 << 3), + GPU_WRITE_DEPTH = (1 << 4), + GPU_WRITE_COLOR = (GPU_WRITE_RED | GPU_WRITE_GREEN | GPU_WRITE_BLUE | GPU_WRITE_ALPHA), +} eGPUWriteMask; + +/** + * Defines the fixed pipeline blending equation. + * SRC is the output color from the shader. + * DST is the color from the framebuffer. + * The blending equation is : + * (SRC * A) + (DST * B). + * The blend mode will modify the A and B parameters. + */ +typedef enum eGPUBlend { + GPU_BLEND_NONE = 0, + /** Premult variants will _NOT_ multiply rgb output by alpha. */ + GPU_BLEND_ALPHA, + GPU_BLEND_ALPHA_PREMULT, + GPU_BLEND_ADDITIVE, + GPU_BLEND_ADDITIVE_PREMULT, + GPU_BLEND_MULTIPLY, + GPU_BLEND_SUBTRACT, + /** Replace logic op: SRC * (1 - DST) + * NOTE: Does not modify alpha. */ + GPU_BLEND_INVERT, + /** Order independant transparency. + * NOTE: Cannot be used as is. Needs special setup (framebuffer, shader ...). */ + GPU_BLEND_OIT, + /** Special blend to add color under and multiply dst color by src alpha. */ + GPU_BLEND_BACKGROUND, + /** Custom blend parameters using dual source blending : SRC0 + SRC1 * DST + * NOTE: Can only be used with _ONE_ Draw Buffer and shader needs to be specialized. */ + GPU_BLEND_CUSTOM, +} eGPUBlend; + +typedef enum eGPUDepthTest { + GPU_DEPTH_NONE = 0, + GPU_DEPTH_ALWAYS, + GPU_DEPTH_LESS, + GPU_DEPTH_LESS_EQUAL, + GPU_DEPTH_EQUAL, + GPU_DEPTH_GREATER, + GPU_DEPTH_GREATER_EQUAL, +} eGPUDepthTest; + +typedef enum eGPUStencilTest { + GPU_STENCIL_NONE = 0, + GPU_STENCIL_ALWAYS, + GPU_STENCIL_EQUAL, + GPU_STENCIL_NEQUAL, +} eGPUStencilTest; + +typedef enum eGPUStencilOp { + GPU_STENCIL_OP_NONE = 0, + GPU_STENCIL_OP_REPLACE, + /** Special values for stencil shadows. */ + GPU_STENCIL_OP_COUNT_DEPTH_PASS, + GPU_STENCIL_OP_COUNT_DEPTH_FAIL, +} eGPUStencilOp; + /* These map directly to the GL_ blend functions, to minimize API add as needed*/ typedef enum eGPUBlendFunction { GPU_ONE, @@ -33,21 +97,15 @@ typedef enum eGPUBlendFunction { GPU_ZERO, } eGPUBlendFunction; -/* These map directly to the GL_ filter functions, to minimize API add as needed*/ -typedef enum eGPUFilterFunction { - GPU_NEAREST, - GPU_LINEAR, -} eGPUFilterFunction; - -typedef enum eGPUFaceCull { +typedef enum eGPUFaceCullTest { GPU_CULL_NONE = 0, /* Culling disabled. */ GPU_CULL_FRONT, GPU_CULL_BACK, -} eGPUFaceCull; +} eGPUFaceCullTest; typedef enum eGPUProvokingVertex { - GPU_VERTEX_FIRST = 0, - GPU_VERTEX_LAST, /* Default */ + GPU_VERTEX_LAST = 0, /* Default. */ + GPU_VERTEX_FIRST = 1, /* Follow Blender loop order. */ } eGPUProvokingVertex; /* Initialize @@ -62,7 +120,7 @@ void GPU_blend_set_func_separate(eGPUBlendFunction src_rgb, eGPUBlendFunction dst_rgb, eGPUBlendFunction src_alpha, eGPUBlendFunction dst_alpha); -void GPU_face_culling(eGPUFaceCull culling); +void GPU_face_culling(eGPUFaceCullTest culling); void GPU_front_facing(bool invert); void GPU_provoking_vertex(eGPUProvokingVertex vert); void GPU_depth_range(float near, float far); |