2016-01-09 00:23:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-10-04 21:24:14 +00:00
|
|
|
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
2016-01-09 00:23:32 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
class FramebufferManagerVulkan;
|
|
|
|
|
|
|
|
struct VulkanDynamicState {
|
|
|
|
VkViewport viewport;
|
|
|
|
VkRect2D scissor;
|
|
|
|
bool useBlendColor;
|
|
|
|
uint32_t blendColor;
|
|
|
|
bool useStencil;
|
|
|
|
uint8_t stencilRef;
|
|
|
|
uint8_t stencilWriteMask;
|
|
|
|
uint8_t stencilCompareMask;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Let's pack this tight using bitfields.
|
|
|
|
// If an enable flag is set to 0, all the data fields for that section should
|
|
|
|
// also be set to 0.
|
2017-12-27 00:35:14 +00:00
|
|
|
// ~64 bits.
|
2016-01-09 00:23:32 +00:00
|
|
|
// Can't use enums unfortunately, they end up signed and breaking values above half their ranges.
|
|
|
|
struct VulkanPipelineRasterStateKey {
|
|
|
|
// Blend
|
2016-03-20 13:54:21 +00:00
|
|
|
unsigned int blendEnable : 1;
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int srcColor : 5; // VkBlendFactor
|
|
|
|
unsigned int destColor : 5; // VkBlendFactor
|
|
|
|
unsigned int srcAlpha : 5; // VkBlendFactor
|
|
|
|
unsigned int destAlpha : 5; // VkBlendFactor
|
2016-03-13 23:53:57 +00:00
|
|
|
// bool useBlendConstant : 1; // sacrifice a bit to cheaply check if we need to update the blend color
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int blendOpColor : 3; // VkBlendOp
|
|
|
|
unsigned int blendOpAlpha : 3; // VkBlendOp
|
2016-03-20 13:54:21 +00:00
|
|
|
unsigned int logicOpEnable : 1;
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int logicOp : 4; // VkLogicOp
|
2016-01-24 16:30:26 +00:00
|
|
|
unsigned int colorWriteMask : 4;
|
2016-01-09 00:23:32 +00:00
|
|
|
|
|
|
|
// Depth/Stencil
|
2017-12-27 00:35:14 +00:00
|
|
|
unsigned int depthClampEnable : 1;
|
2016-03-20 13:54:21 +00:00
|
|
|
unsigned int depthTestEnable : 1;
|
|
|
|
unsigned int depthWriteEnable : 1;
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int depthCompareOp : 3; // VkCompareOp
|
2016-03-20 13:54:21 +00:00
|
|
|
unsigned int stencilTestEnable : 1;
|
|
|
|
unsigned int stencilCompareOp : 3; // VkCompareOp
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int stencilPassOp : 4; // VkStencilOp
|
2016-03-20 13:54:21 +00:00
|
|
|
unsigned int stencilFailOp : 4; // VkStencilOp
|
2016-01-09 00:23:32 +00:00
|
|
|
unsigned int stencilDepthFailOp : 4; // VkStencilOp
|
|
|
|
|
|
|
|
// We'll use dynamic state for writemask, reference and comparemask to start with,
|
|
|
|
// and viewport/scissor.
|
|
|
|
|
|
|
|
// Rasterizer
|
|
|
|
unsigned int cullMode : 2; // VkCullModeFlagBits
|
|
|
|
unsigned int topology : 4; // VkPrimitiveTopology
|
|
|
|
|
|
|
|
bool operator < (const VulkanPipelineRasterStateKey &other) const {
|
2016-03-20 13:54:21 +00:00
|
|
|
size_t size = sizeof(VulkanPipelineRasterStateKey);
|
|
|
|
return memcmp(this, &other, size) < 0;
|
2016-01-09 00:23:32 +00:00
|
|
|
}
|
2017-12-27 00:35:14 +00:00
|
|
|
};
|