11 #ifndef hifi_gpu_VKShared_h
12 #define hifi_gpu_VKShared_h
14 #include <vk/Config.h>
15 #include <gpu/Forward.h>
16 #include <gpu/Format.h>
17 #include <gpu/Context.h>
18 #include "VKBackend.h"
21 Q_DECLARE_LOGGING_CATEGORY(gpu_vk_logging)
22 Q_DECLARE_LOGGING_CATEGORY(trace_gpu_vk)
23 Q_DECLARE_LOGGING_CATEGORY(trace_gpu_vk_detail)
25 namespace gpu {
namespace vk {
27 gpu::Size getDedicatedMemory();
28 ComparisonFunction comparisonFuncFromGL(VkCompareOp func);
29 State::StencilOp stencilOpFromGL(VkStencilOp stencilOp);
30 State::BlendOp blendOpFromGL(VkBlendOp blendOp);
31 State::BlendArg blendArgFromGL(VkBlendFactor blendArg);
33 VkFormat evalTexelFormatInternal(
const Element& dstFormat,
const vks::Context &context);
36 bool formatHasStencil(VkFormat format);
38 VkColorComponentFlags colorMaskToVk(
const gpu::State::ColorMask &mask);
40 static const VkBlendOp BLEND_OPS_TO_VK[State::NUM_BLEND_OPS] = {
43 VK_BLEND_OP_REVERSE_SUBTRACT,
48 static const VkBlendFactor BLEND_ARGS_TO_VK[State::NUM_BLEND_ARGS] = {
51 VK_BLEND_FACTOR_SRC_COLOR,
52 VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
53 VK_BLEND_FACTOR_SRC_ALPHA,
54 VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
55 VK_BLEND_FACTOR_DST_ALPHA,
56 VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
57 VK_BLEND_FACTOR_DST_COLOR,
58 VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR,
59 VK_BLEND_FACTOR_SRC_ALPHA_SATURATE,
60 VK_BLEND_FACTOR_CONSTANT_COLOR,
61 VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
62 VK_BLEND_FACTOR_CONSTANT_ALPHA,
63 VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
66 static const VkCompareOp COMPARISON_TO_VK[
static_cast<size_t>(ComparisonFunction::NUM_COMPARISON_FUNCS)] = {
70 VK_COMPARE_OP_LESS_OR_EQUAL,
71 VK_COMPARE_OP_GREATER,
72 VK_COMPARE_OP_NOT_EQUAL,
73 VK_COMPARE_OP_GREATER_OR_EQUAL,
77 static const VkPrimitiveTopology PRIMITIVE_TO_VK[gpu::NUM_PRIMITIVES] = {
78 VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
79 VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
80 VK_PRIMITIVE_TOPOLOGY_LINE_STRIP,
81 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
82 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
83 VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN,
120 template <
typename GPUType>
121 struct VKObject :
public GPUObject {
123 VKObject(VKBackend& backend,
const GPUType& gpuObject) : _gpuObject(gpuObject), _backend(backend.shared_from_this()) {}
125 virtual ~VKObject() { }
127 const GPUType& _gpuObject;
130 const std::weak_ptr<VKBackend> _backend;