CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Vulkan/StateMappingVulkan.h
Views: 1401
1
#pragma once
2
3
#include "Common/GPU/Vulkan/VulkanLoader.h"
4
5
#include <cstring>
6
7
class FramebufferManagerVulkan;
8
9
struct ScissorRect {
10
int x, y;
11
int width, height;
12
};
13
14
struct VulkanDynamicState {
15
VkViewport viewport;
16
ScissorRect scissor;
17
bool useBlendColor;
18
uint32_t blendColor;
19
bool useStencil;
20
uint8_t stencilRef;
21
uint8_t stencilWriteMask;
22
uint8_t stencilCompareMask;
23
};
24
25
// Let's pack this tight using bitfields.
26
// If an enable flag is set to 0, all the data fields for that section should
27
// also be set to 0.
28
// ~64 bits.
29
// Can't use enums unfortunately, they end up signed and breaking values above half their ranges.
30
struct VulkanPipelineRasterStateKey {
31
// Blend
32
unsigned int blendEnable : 1;
33
unsigned int srcColor : 5; // VkBlendFactor
34
unsigned int destColor : 5; // VkBlendFactor
35
unsigned int srcAlpha : 5; // VkBlendFactor
36
unsigned int destAlpha : 5; // VkBlendFactor
37
// bool useBlendConstant : 1; // sacrifice a bit to cheaply check if we need to update the blend color
38
unsigned int blendOpColor : 3; // VkBlendOp
39
unsigned int blendOpAlpha : 3; // VkBlendOp
40
unsigned int logicOpEnable : 1;
41
unsigned int logicOp : 4; // VkLogicOp
42
unsigned int colorWriteMask : 4;
43
44
// Depth/Stencil
45
unsigned int depthClampEnable : 1;
46
unsigned int depthTestEnable : 1;
47
unsigned int depthWriteEnable : 1;
48
unsigned int depthCompareOp : 3; // VkCompareOp
49
unsigned int stencilTestEnable : 1;
50
unsigned int stencilCompareOp : 3; // VkCompareOp
51
unsigned int stencilPassOp : 4; // VkStencilOp
52
unsigned int stencilFailOp : 4; // VkStencilOp
53
unsigned int stencilDepthFailOp : 4; // VkStencilOp
54
55
// We'll use dynamic state for writemask, reference and comparemask to start with,
56
// and viewport/scissor.
57
58
// Rasterizer
59
unsigned int cullMode : 2; // VkCullModeFlagBits
60
unsigned int topology : 4; // VkPrimitiveTopology
61
62
bool operator < (const VulkanPipelineRasterStateKey &other) const {
63
size_t size = sizeof(VulkanPipelineRasterStateKey);
64
return memcmp(this, &other, size) < 0;
65
}
66
};
67
68