2016-02-16 20:24:00 +01:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 13:40:32 +01:00
|
|
|
* Copyright (C) 2010-2017 - Hans-Kristian Arntzen
|
2016-02-16 20:24:00 +01:00
|
|
|
*
|
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLSLANG_UTIL_HPP
|
|
|
|
#define GLSLANG_UTIL_HPP
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2018-02-01 15:07:12 +01:00
|
|
|
#include <retro_common_api.h>
|
2016-03-26 17:59:50 +01:00
|
|
|
|
2018-02-01 15:07:12 +01:00
|
|
|
typedef enum glslang_format
|
2016-03-26 22:52:32 +01:00
|
|
|
{
|
2018-02-01 15:13:58 +01:00
|
|
|
SLANG_FORMAT_UNKNOWN = 0,
|
|
|
|
|
2016-03-26 22:52:32 +01:00
|
|
|
// 8-bit
|
2018-02-01 15:13:58 +01:00
|
|
|
SLANG_FORMAT_R8_UNORM,
|
2016-03-26 22:52:32 +01:00
|
|
|
SLANG_FORMAT_R8_UINT,
|
|
|
|
SLANG_FORMAT_R8_SINT,
|
|
|
|
SLANG_FORMAT_R8G8_UNORM,
|
|
|
|
SLANG_FORMAT_R8G8_UINT,
|
|
|
|
SLANG_FORMAT_R8G8_SINT,
|
|
|
|
SLANG_FORMAT_R8G8B8A8_UNORM,
|
|
|
|
SLANG_FORMAT_R8G8B8A8_UINT,
|
|
|
|
SLANG_FORMAT_R8G8B8A8_SINT,
|
|
|
|
SLANG_FORMAT_R8G8B8A8_SRGB,
|
|
|
|
|
|
|
|
// 10-bit
|
2016-03-26 23:49:57 +01:00
|
|
|
SLANG_FORMAT_A2B10G10R10_UNORM_PACK32,
|
|
|
|
SLANG_FORMAT_A2B10G10R10_UINT_PACK32,
|
2016-03-26 22:52:32 +01:00
|
|
|
|
|
|
|
// 16-bit
|
|
|
|
SLANG_FORMAT_R16_UINT,
|
|
|
|
SLANG_FORMAT_R16_SINT,
|
|
|
|
SLANG_FORMAT_R16_SFLOAT,
|
|
|
|
SLANG_FORMAT_R16G16_UINT,
|
|
|
|
SLANG_FORMAT_R16G16_SINT,
|
|
|
|
SLANG_FORMAT_R16G16_SFLOAT,
|
|
|
|
SLANG_FORMAT_R16G16B16A16_UINT,
|
|
|
|
SLANG_FORMAT_R16G16B16A16_SINT,
|
|
|
|
SLANG_FORMAT_R16G16B16A16_SFLOAT,
|
|
|
|
|
|
|
|
// 32-bit
|
|
|
|
SLANG_FORMAT_R32_UINT,
|
|
|
|
SLANG_FORMAT_R32_SINT,
|
2016-03-26 23:49:57 +01:00
|
|
|
SLANG_FORMAT_R32_SFLOAT,
|
2016-03-26 22:52:32 +01:00
|
|
|
SLANG_FORMAT_R32G32_UINT,
|
|
|
|
SLANG_FORMAT_R32G32_SINT,
|
2016-03-26 23:49:57 +01:00
|
|
|
SLANG_FORMAT_R32G32_SFLOAT,
|
2016-03-26 22:52:32 +01:00
|
|
|
SLANG_FORMAT_R32G32B32A32_UINT,
|
|
|
|
SLANG_FORMAT_R32G32B32A32_SINT,
|
2016-03-26 23:49:57 +01:00
|
|
|
SLANG_FORMAT_R32G32B32A32_SFLOAT,
|
2016-03-26 22:52:32 +01:00
|
|
|
|
2018-02-01 15:13:58 +01:00
|
|
|
SLANG_FORMAT_MAX
|
2018-02-01 15:07:12 +01:00
|
|
|
}glslang_format;
|
|
|
|
|
|
|
|
RETRO_BEGIN_DECLS
|
|
|
|
|
|
|
|
const char *glslang_format_to_string(glslang_format fmt);
|
|
|
|
|
|
|
|
RETRO_END_DECLS
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2016-03-26 22:52:32 +01:00
|
|
|
|
2016-08-01 15:48:09 +02:00
|
|
|
struct glslang_parameter
|
|
|
|
{
|
|
|
|
std::string id;
|
|
|
|
std::string desc;
|
|
|
|
float initial;
|
|
|
|
float minimum;
|
|
|
|
float maximum;
|
|
|
|
float step;
|
|
|
|
};
|
|
|
|
|
2016-03-26 17:59:50 +01:00
|
|
|
struct glslang_meta
|
|
|
|
{
|
2016-08-01 15:48:09 +02:00
|
|
|
std::vector<glslang_parameter> parameters;
|
2016-03-26 17:59:50 +01:00
|
|
|
std::string name;
|
2018-02-04 15:49:53 +01:00
|
|
|
glslang_format rt_format;
|
|
|
|
|
|
|
|
glslang_meta()
|
|
|
|
{
|
|
|
|
rt_format = SLANG_FORMAT_UNKNOWN;
|
|
|
|
}
|
2016-03-26 17:59:50 +01:00
|
|
|
};
|
2016-02-16 20:24:00 +01:00
|
|
|
|
|
|
|
struct glslang_output
|
|
|
|
{
|
|
|
|
std::vector<uint32_t> vertex;
|
|
|
|
std::vector<uint32_t> fragment;
|
2016-03-26 17:59:50 +01:00
|
|
|
glslang_meta meta;
|
2016-02-16 20:24:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
bool glslang_compile_shader(const char *shader_path, glslang_output *output);
|
|
|
|
|
2016-12-20 15:50:50 +01:00
|
|
|
// Helpers for internal use.
|
|
|
|
bool glslang_read_shader_file(const char *path, std::vector<std::string> *output, bool root_file);
|
|
|
|
bool glslang_parse_meta(const std::vector<std::string> &lines, glslang_meta *meta);
|
2018-02-01 15:07:12 +01:00
|
|
|
#endif
|
2016-12-20 15:50:50 +01:00
|
|
|
|
2016-02-16 20:24:00 +01:00
|
|
|
#endif
|
|
|
|
|