CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/GPU/Vulkan/StateMappingVulkan.h
Views: 1401
#pragma once12#include "Common/GPU/Vulkan/VulkanLoader.h"34#include <cstring>56class FramebufferManagerVulkan;78struct ScissorRect {9int x, y;10int width, height;11};1213struct VulkanDynamicState {14VkViewport viewport;15ScissorRect scissor;16bool useBlendColor;17uint32_t blendColor;18bool useStencil;19uint8_t stencilRef;20uint8_t stencilWriteMask;21uint8_t stencilCompareMask;22};2324// Let's pack this tight using bitfields.25// If an enable flag is set to 0, all the data fields for that section should26// also be set to 0.27// ~64 bits.28// Can't use enums unfortunately, they end up signed and breaking values above half their ranges.29struct VulkanPipelineRasterStateKey {30// Blend31unsigned int blendEnable : 1;32unsigned int srcColor : 5; // VkBlendFactor33unsigned int destColor : 5; // VkBlendFactor34unsigned int srcAlpha : 5; // VkBlendFactor35unsigned int destAlpha : 5; // VkBlendFactor36// bool useBlendConstant : 1; // sacrifice a bit to cheaply check if we need to update the blend color37unsigned int blendOpColor : 3; // VkBlendOp38unsigned int blendOpAlpha : 3; // VkBlendOp39unsigned int logicOpEnable : 1;40unsigned int logicOp : 4; // VkLogicOp41unsigned int colorWriteMask : 4;4243// Depth/Stencil44unsigned int depthClampEnable : 1;45unsigned int depthTestEnable : 1;46unsigned int depthWriteEnable : 1;47unsigned int depthCompareOp : 3; // VkCompareOp48unsigned int stencilTestEnable : 1;49unsigned int stencilCompareOp : 3; // VkCompareOp50unsigned int stencilPassOp : 4; // VkStencilOp51unsigned int stencilFailOp : 4; // VkStencilOp52unsigned int stencilDepthFailOp : 4; // VkStencilOp5354// We'll use dynamic state for writemask, reference and comparemask to start with,55// and viewport/scissor.5657// Rasterizer58unsigned int cullMode : 2; // VkCullModeFlagBits59unsigned int topology : 4; // VkPrimitiveTopology6061bool operator < (const VulkanPipelineRasterStateKey &other) const {62size_t size = sizeof(VulkanPipelineRasterStateKey);63return memcmp(this, &other, size) < 0;64}65};666768