2015-10-24 21:49:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-24 19:26:38 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
2015-11-04 08:35:55 +00:00
|
|
|
#include "GPU/ge_constants.h"
|
|
|
|
|
2016-12-26 22:51:17 +00:00
|
|
|
// TODO: Replace enums and structs with same from thin3d.h, for convenient mapping.
|
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
enum StencilValueType {
|
|
|
|
STENCIL_VALUE_UNIFORM,
|
|
|
|
STENCIL_VALUE_ZERO,
|
|
|
|
STENCIL_VALUE_ONE,
|
|
|
|
STENCIL_VALUE_KEEP,
|
|
|
|
STENCIL_VALUE_INVERT,
|
|
|
|
STENCIL_VALUE_INCR_4,
|
|
|
|
STENCIL_VALUE_INCR_8,
|
|
|
|
STENCIL_VALUE_DECR_4,
|
|
|
|
STENCIL_VALUE_DECR_8,
|
2015-03-16 02:25:34 +00:00
|
|
|
};
|
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
enum ReplaceAlphaType {
|
|
|
|
REPLACE_ALPHA_NO = 0,
|
|
|
|
REPLACE_ALPHA_YES = 1,
|
|
|
|
REPLACE_ALPHA_DUALSOURCE = 2,
|
|
|
|
};
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
enum ReplaceBlendType {
|
|
|
|
REPLACE_BLEND_NO,
|
|
|
|
REPLACE_BLEND_STANDARD,
|
|
|
|
REPLACE_BLEND_PRE_SRC,
|
|
|
|
REPLACE_BLEND_PRE_SRC_2X_ALPHA,
|
|
|
|
REPLACE_BLEND_2X_ALPHA,
|
|
|
|
REPLACE_BLEND_2X_SRC,
|
|
|
|
REPLACE_BLEND_COPY_FBO,
|
|
|
|
};
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
enum LogicOpReplaceType {
|
|
|
|
LOGICOPTYPE_NORMAL,
|
|
|
|
LOGICOPTYPE_ONE,
|
|
|
|
LOGICOPTYPE_INVERT,
|
|
|
|
};
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
bool IsAlphaTestTriviallyTrue();
|
|
|
|
bool IsColorTestAgainstZero();
|
|
|
|
bool IsColorTestTriviallyTrue();
|
|
|
|
bool IsAlphaTestAgainstZero();
|
2018-07-28 03:04:36 +00:00
|
|
|
bool NeedsTestDiscard();
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
StencilValueType ReplaceAlphaWithStencilType();
|
|
|
|
ReplaceAlphaType ReplaceAlphaWithStencil(ReplaceBlendType replaceBlend);
|
2015-11-04 08:35:55 +00:00
|
|
|
ReplaceBlendType ReplaceBlendWithShader(bool allowShaderBlend, GEBufferFormat bufferFormat);
|
2015-03-16 02:25:34 +00:00
|
|
|
|
2015-10-24 21:49:05 +00:00
|
|
|
bool CanUseHardwareTransform(int prim);
|
|
|
|
LogicOpReplaceType ReplaceLogicOpType();
|
2015-11-08 17:13:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Common representation, should be able to set this directly with any modern API.
|
|
|
|
struct ViewportAndScissor {
|
|
|
|
bool scissorEnable;
|
|
|
|
int scissorX;
|
|
|
|
int scissorY;
|
|
|
|
int scissorW;
|
|
|
|
int scissorH;
|
|
|
|
float viewportX;
|
|
|
|
float viewportY;
|
|
|
|
float viewportW;
|
|
|
|
float viewportH;
|
|
|
|
float depthRangeMin;
|
|
|
|
float depthRangeMax;
|
|
|
|
bool dirtyProj;
|
2016-01-03 20:11:05 +00:00
|
|
|
bool dirtyDepth;
|
2015-11-08 17:13:34 +00:00
|
|
|
};
|
|
|
|
void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, float renderHeight, int bufferWidth, int bufferHeight, ViewportAndScissor &out);
|
2016-01-19 03:29:45 +00:00
|
|
|
float ToScaledDepth(u16 z);
|
2016-01-19 05:01:45 +00:00
|
|
|
float FromScaledDepth(float z);
|
2016-01-20 04:19:50 +00:00
|
|
|
float DepthSliceFactor();
|
2015-11-08 19:09:30 +00:00
|
|
|
|
|
|
|
// These are common to all modern APIs and can be easily converted with a lookup table.
|
|
|
|
enum class BlendFactor : uint8_t {
|
|
|
|
ZERO,
|
|
|
|
ONE,
|
|
|
|
SRC_COLOR,
|
|
|
|
ONE_MINUS_SRC_COLOR,
|
|
|
|
DST_COLOR,
|
|
|
|
ONE_MINUS_DST_COLOR,
|
|
|
|
SRC_ALPHA,
|
|
|
|
ONE_MINUS_SRC_ALPHA,
|
|
|
|
DST_ALPHA,
|
|
|
|
ONE_MINUS_DST_ALPHA,
|
|
|
|
CONSTANT_COLOR,
|
|
|
|
ONE_MINUS_CONSTANT_COLOR,
|
|
|
|
CONSTANT_ALPHA,
|
|
|
|
ONE_MINUS_CONSTANT_ALPHA,
|
2016-12-26 22:51:17 +00:00
|
|
|
SRC1_COLOR,
|
|
|
|
ONE_MINUS_SRC1_COLOR,
|
2015-11-08 19:09:30 +00:00
|
|
|
SRC1_ALPHA,
|
|
|
|
ONE_MINUS_SRC1_ALPHA,
|
|
|
|
INVALID,
|
|
|
|
COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class BlendEq : uint8_t {
|
|
|
|
ADD,
|
|
|
|
SUBTRACT,
|
|
|
|
REVERSE_SUBTRACT,
|
|
|
|
MIN,
|
|
|
|
MAX,
|
|
|
|
COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GenericBlendState {
|
|
|
|
bool enabled;
|
2015-11-08 20:47:08 +00:00
|
|
|
bool resetShaderBlending;
|
|
|
|
bool applyShaderBlending;
|
|
|
|
bool dirtyShaderBlend;
|
|
|
|
ReplaceAlphaType replaceAlphaWithStencil;
|
2015-11-08 19:09:30 +00:00
|
|
|
|
|
|
|
BlendFactor srcColor;
|
|
|
|
BlendFactor dstColor;
|
|
|
|
BlendFactor srcAlpha;
|
|
|
|
BlendFactor dstAlpha;
|
|
|
|
|
|
|
|
BlendEq eqColor;
|
|
|
|
BlendEq eqAlpha;
|
|
|
|
|
2015-11-08 21:29:43 +00:00
|
|
|
bool useBlendColor;
|
|
|
|
u32 blendColor;
|
|
|
|
|
2015-11-08 19:09:30 +00:00
|
|
|
void setFactors(BlendFactor srcC, BlendFactor dstC, BlendFactor srcA, BlendFactor dstA) {
|
|
|
|
srcColor = srcC;
|
|
|
|
dstColor = dstC;
|
|
|
|
srcAlpha = srcA;
|
|
|
|
dstAlpha = dstA;
|
|
|
|
}
|
|
|
|
void setEquation(BlendEq eqC, BlendEq eqA) {
|
|
|
|
eqColor = eqC;
|
|
|
|
eqAlpha = eqA;
|
|
|
|
}
|
2015-11-08 21:29:43 +00:00
|
|
|
void setBlendColor(uint32_t color, uint8_t alpha) {
|
2015-11-08 21:50:16 +00:00
|
|
|
blendColor = color | ((uint32_t)alpha << 24);
|
2015-11-08 21:29:43 +00:00
|
|
|
useBlendColor = true;
|
|
|
|
}
|
|
|
|
void defaultBlendColor(uint8_t alpha) {
|
2015-11-08 21:50:16 +00:00
|
|
|
blendColor = 0xFFFFFF | ((uint32_t)alpha << 24);
|
2015-11-08 21:29:43 +00:00
|
|
|
useBlendColor = true;
|
|
|
|
}
|
2015-11-08 19:09:30 +00:00
|
|
|
};
|
2015-11-08 21:32:48 +00:00
|
|
|
|
2015-11-14 07:11:06 +00:00
|
|
|
void ConvertBlendState(GenericBlendState &blendState, bool allowShaderBlend);
|
2015-11-08 21:32:48 +00:00
|
|
|
void ApplyStencilReplaceAndLogicOp(ReplaceAlphaType replaceAlphaWithStencil, GenericBlendState &blendState);
|
2015-12-31 09:50:18 +00:00
|
|
|
|
|
|
|
struct GenericStencilFuncState {
|
|
|
|
bool enabled;
|
|
|
|
GEComparison testFunc;
|
|
|
|
u8 testRef;
|
|
|
|
u8 testMask;
|
|
|
|
u8 writeMask;
|
|
|
|
GEStencilOp sFail;
|
|
|
|
GEStencilOp zFail;
|
|
|
|
GEStencilOp zPass;
|
|
|
|
};
|
|
|
|
|
|
|
|
void ConvertStencilFuncState(GenericStencilFuncState &stencilFuncState);
|