~ppsspp/ppsspp/ppsspp_1.3.0

« back to all changes in this revision

Viewing changes to GPU/Vulkan/StateMappingVulkan.h

  • Committer: Sérgio Benjamim
  • Date: 2017-01-02 00:12:05 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20170102001205-cxbta9za203nmjwm
1.3.0 source (from ppsspp_1.3.0-r160.p5.l1762.a165.t83~56~ubuntu16.04.1.tar.xz).

Show diffs side-by-side

added added

removed removed

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