1 /* RetroArch - A frontend fror libretro. 2 * Copyright (C) 2014-2018 - Ali Bouhlel 3 * 4 * RetroArch is free software: you can redistribute it and/or modify it under the terms 5 * of the GNU General Public License as published by the Free Software Found- 6 * ation, either version 3 of the License, or (at your option) any later version. 7 * 8 * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 10 * PURPOSE. See the GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License along with RetroArch. 13 * If not, see <http://www.gnu.org/licenses/>. 14 */ 15 16 #ifndef __GLSLANG_PROCESS_H__ 17 #define __GLSLANG_PROCESS_H__ 18 19 #include <stdint.h> 20 #include <boolean.h> 21 #include <retro_common_api.h> 22 23 #include "../video_shader_parse.h" 24 #include "../../retroarch.h" 25 #include "slang_reflection.h" 26 #include "glslang_util.h" 27 28 typedef struct 29 { 30 void* ptr; 31 size_t stride; 32 } data_map_t; 33 34 typedef struct 35 { 36 void* image; 37 size_t image_stride; 38 void* size; 39 size_t size_stride; 40 } texture_map_t; 41 42 typedef struct 43 { 44 texture_map_t textures[SLANG_NUM_TEXTURE_SEMANTICS]; 45 void* uniforms[SLANG_NUM_BASE_SEMANTICS]; 46 } semantics_map_t; 47 48 typedef struct 49 { 50 void* data; 51 unsigned size; 52 unsigned offset; 53 char id[64]; 54 } uniform_sem_t; 55 56 typedef struct 57 { 58 void* texture_data; 59 enum gfx_wrap_type wrap; 60 unsigned filter; 61 unsigned stage_mask; 62 unsigned binding; 63 char id[64]; 64 } texture_sem_t; 65 66 typedef struct 67 { 68 unsigned stage_mask; 69 unsigned binding; 70 unsigned size; 71 int uniform_count; 72 uniform_sem_t* uniforms; 73 } cbuffer_sem_t; 74 75 typedef struct 76 { 77 int texture_count; 78 texture_sem_t* textures; 79 cbuffer_sem_t cbuffers[SLANG_CBUFFER_MAX]; 80 glslang_format format; 81 } pass_semantics_t; 82 83 #define SLANG_STAGE_VERTEX_MASK (1 << 0) 84 #define SLANG_STAGE_FRAGMENT_MASK (1 << 1) 85 86 RETRO_BEGIN_DECLS 87 88 /* Utility function to implement the same parameter reflection 89 * which happens in the slang backend. 90 * This does preprocess over the input file to handle #includes and so on. */ 91 bool slang_preprocess_parse_parameters(const char *shader_path, 92 struct video_shader *shader); 93 94 bool slang_process( 95 struct video_shader* shader_info, 96 unsigned pass_number, 97 enum rarch_shader_type dst_type, 98 unsigned version, 99 const semantics_map_t* semantics_map, 100 pass_semantics_t* out); 101 102 RETRO_END_DECLS 103 104 #ifdef __cplusplus 105 106 #include "glslang_util_cxx.h" 107 108 bool slang_preprocess_parse_parameters(glslang_meta& meta, 109 struct video_shader *shader); 110 #endif 111 112 #endif 113