#pragma once
#ifndef GLSL_OPTIMIZER_H
#define GLSL_OPTIMIZER_H
extern "C" {
struct glslopt_shader;
struct glslopt_ctx;
enum glslopt_shader_type {
kGlslOptShaderVertex = 0,
kGlslOptShaderFragment,
};
enum glslopt_options {
kGlslOptionSkipPreprocessor = (1<<0), kGlslOptionNotFullShader = (1<<1), };
enum glslopt_target {
kGlslTargetOpenGL = 0,
kGlslTargetOpenGLES20 = 1,
kGlslTargetOpenGLES30 = 2,
kGlslTargetMetal = 3,
};
enum glslopt_basic_type {
kGlslTypeFloat = 0,
kGlslTypeInt,
kGlslTypeBool,
kGlslTypeTex2D,
kGlslTypeTex3D,
kGlslTypeTexCube,
kGlslTypeTex2DShadow,
kGlslTypeTex2DArray,
kGlslTypeOther,
kGlslTypeCount
};
enum glslopt_precision {
kGlslPrecHigh = 0,
kGlslPrecMedium,
kGlslPrecLow,
kGlslPrecCount
};
glslopt_ctx* glslopt_initialize (glslopt_target target);
void glslopt_cleanup (glslopt_ctx* ctx);
void glslopt_set_max_unroll_iterations (glslopt_ctx* ctx, unsigned iterations);
glslopt_shader* glslopt_optimize (glslopt_ctx* ctx, glslopt_shader_type type, const char* shaderSource, unsigned options);
bool glslopt_get_status (glslopt_shader* shader);
const char* glslopt_get_output (glslopt_shader* shader);
const char* glslopt_get_raw_output (glslopt_shader* shader);
const char* glslopt_get_log (glslopt_shader* shader);
void glslopt_shader_delete (glslopt_shader* shader);
int glslopt_shader_get_input_count (glslopt_shader* shader);
void glslopt_shader_get_input_desc (glslopt_shader* shader, int index, const char** outName, glslopt_basic_type* outType, glslopt_precision* outPrec, int* outVecSize, int* outMatSize, int* outArraySize, int* outLocation);
int glslopt_shader_get_uniform_count (glslopt_shader* shader);
int glslopt_shader_get_uniform_total_size (glslopt_shader* shader);
void glslopt_shader_get_uniform_desc (glslopt_shader* shader, int index, const char** outName, glslopt_basic_type* outType, glslopt_precision* outPrec, int* outVecSize, int* outMatSize, int* outArraySize, int* outLocation);
int glslopt_shader_get_texture_count (glslopt_shader* shader);
void glslopt_shader_get_texture_desc (glslopt_shader* shader, int index, const char** outName, glslopt_basic_type* outType, glslopt_precision* outPrec, int* outVecSize, int* outMatSize, int* outArraySize, int* outLocation);
void glslopt_shader_get_stats (glslopt_shader* shader, int* approxMath, int* approxTex, int* approxFlow);
}
#endif