From ff6e3c025658a5fa1affd094f220b623e7e1b24b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 22:38:23 +0200 Subject: Adding upstream version 6.338.2. Signed-off-by: Daniel Baumann --- src/glsl/utils.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/glsl/utils.h (limited to 'src/glsl/utils.h') diff --git a/src/glsl/utils.h b/src/glsl/utils.h new file mode 100644 index 0000000..965ea9e --- /dev/null +++ b/src/glsl/utils.h @@ -0,0 +1,52 @@ +/* + * This file is part of libplacebo. + * + * libplacebo is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libplacebo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libplacebo. If not, see . + */ + +#pragma once + +#include +#include + +#include + +#define PL_SPV_VERSION(major, minor) ((major) << 16 | (minor) << 8) +#define PL_VLK_VERSION(major, minor) ((major) << 22 | (minor) << 12) + +// Max version that can be used +#define PL_MAX_SPIRV_VER PL_SPV_VERSION(1, 6) + +struct pl_spirv_version { + uint32_t env_version; + uint32_t spv_version; +}; + +// Returns minimum Vulkan version for given SPIR-V version +static inline uint32_t pl_spirv_version_to_vulkan(uint32_t spirv_ver) +{ + if (spirv_ver >= PL_SPV_VERSION(1, 6)) + return PL_VLK_VERSION(1, 3); + if (spirv_ver >= PL_SPV_VERSION(1, 4)) + return PL_VLK_VERSION(1, 2); + if (spirv_ver >= PL_SPV_VERSION(1, 1)) + return PL_VLK_VERSION(1, 1); + return PL_VLK_VERSION(1, 0); +} + +enum glsl_shader_stage { + GLSL_SHADER_VERTEX = 0, + GLSL_SHADER_FRAGMENT, + GLSL_SHADER_COMPUTE, +}; -- cgit v1.2.3