summaryrefslogtreecommitdiff
path: root/servers/rendering/shader_language.h
diff options
context:
space:
mode:
Diffstat (limited to 'servers/rendering/shader_language.h')
-rw-r--r--servers/rendering/shader_language.h39
1 files changed, 34 insertions, 5 deletions
diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h
index a4226a9764..1e302f5805 100644
--- a/servers/rendering/shader_language.h
+++ b/servers/rendering/shader_language.h
@@ -38,6 +38,7 @@
#include "core/templates/rb_map.h"
#include "core/typedefs.h"
#include "core/variant/variant.h"
+#include "scene/resources/shader_include.h"
#ifdef DEBUG_ENABLED
#include "shader_warnings.h"
@@ -153,6 +154,7 @@ public:
TK_SEMICOLON,
TK_PERIOD,
TK_UNIFORM,
+ TK_UNIFORM_GROUP,
TK_INSTANCE,
TK_GLOBAL,
TK_VARYING,
@@ -162,6 +164,7 @@ public:
TK_RENDER_MODE,
TK_HINT_DEFAULT_WHITE_TEXTURE,
TK_HINT_DEFAULT_BLACK_TEXTURE,
+ TK_HINT_DEFAULT_TRANSPARENT_TEXTURE,
TK_HINT_NORMAL_TEXTURE,
TK_HINT_ROUGHNESS_NORMAL_TEXTURE,
TK_HINT_ROUGHNESS_R,
@@ -173,6 +176,9 @@ public:
TK_HINT_SOURCE_COLOR,
TK_HINT_RANGE,
TK_HINT_INSTANCE_INDEX,
+ TK_HINT_SCREEN_TEXTURE,
+ TK_HINT_NORMAL_ROUGHNESS_TEXTURE,
+ TK_HINT_DEPTH_TEXTURE,
TK_FILTER_NEAREST,
TK_FILTER_LINEAR,
TK_FILTER_NEAREST_MIPMAP,
@@ -477,7 +483,7 @@ public:
int array_size = 0;
union Value {
- bool boolean;
+ bool boolean = false;
float real;
int32_t sint;
uint32_t uint;
@@ -662,7 +668,11 @@ public:
HINT_ROUGHNESS_GRAY,
HINT_DEFAULT_BLACK,
HINT_DEFAULT_WHITE,
+ HINT_DEFAULT_TRANSPARENT,
HINT_ANISOTROPY,
+ HINT_SCREEN_TEXTURE,
+ HINT_NORMAL_ROUGHNESS_TEXTURE,
+ HINT_DEPTH_TEXTURE,
HINT_MAX
};
@@ -686,6 +696,8 @@ public:
TextureRepeat repeat = REPEAT_DEFAULT;
float hint_range[3];
int instance_index = 0;
+ String group;
+ String subgroup;
Uniform() {
hint_range[0] = 0.0f;
@@ -865,7 +877,12 @@ public:
};
static bool has_builtin(const HashMap<StringName, ShaderLanguage::FunctionInfo> &p_functions, const StringName &p_name);
- typedef DataType (*GlobalVariableGetTypeFunc)(const StringName &p_name);
+ typedef DataType (*GlobalShaderUniformGetTypeFunc)(const StringName &p_name);
+
+ struct FilePosition {
+ String file;
+ int line = 0;
+ };
private:
struct KeyWord {
@@ -878,12 +895,14 @@ private:
static const KeyWord keyword_list[];
- GlobalVariableGetTypeFunc global_var_get_type_func = nullptr;
+ GlobalShaderUniformGetTypeFunc global_shader_uniform_get_type_func = nullptr;
bool error_set = false;
String error_str;
int error_line = 0;
+ Vector<FilePosition> include_positions;
+
#ifdef DEBUG_ENABLED
struct Usage {
int decl_line;
@@ -928,6 +947,10 @@ private:
StringName current_function;
bool last_const = false;
StringName last_name;
+ bool is_shader_inc = false;
+
+ String current_uniform_group_name;
+ String current_uniform_subgroup_name;
VaryingFunctionNames varying_function_names;
@@ -951,6 +974,7 @@ private:
error_line = tk_line;
error_set = true;
error_str = p_str;
+ include_positions.write[include_positions.size() - 1].line = tk_line;
}
void _set_expected_error(const String &p_what) {
@@ -1026,6 +1050,10 @@ private:
};
CompletionType completion_type;
+ ShaderNode::Uniform::Hint current_uniform_hint = ShaderNode::Uniform::HINT_NONE;
+ TextureFilter current_uniform_filter = FILTER_DEFAULT;
+ TextureRepeat current_uniform_repeat = REPEAT_DEFAULT;
+ bool current_uniform_instance_index_defined = false;
int completion_line = 0;
BlockNode *completion_block = nullptr;
DataType completion_base;
@@ -1049,7 +1077,6 @@ private:
static bool is_const_suffix_lut_initialized;
Error _validate_precision(DataType p_type, DataPrecision p_precision);
- Error _validate_datatype(DataType p_type);
bool _compare_datatypes(DataType p_datatype_a, String p_datatype_name_a, int p_array_size_a, DataType p_datatype_b, String p_datatype_name_b, int p_array_size_b);
bool _compare_datatypes_in_nodes(Node *a, Node *b);
@@ -1098,13 +1125,15 @@ public:
Vector<ModeInfo> render_modes;
VaryingFunctionNames varying_function_names = VaryingFunctionNames();
HashSet<String> shader_types;
- GlobalVariableGetTypeFunc global_variable_type_func = nullptr;
+ GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr;
+ bool is_include = false;
};
Error compile(const String &p_code, const ShaderCompileInfo &p_info);
Error complete(const String &p_code, const ShaderCompileInfo &p_info, List<ScriptLanguage::CodeCompletionOption> *r_options, String &r_call_hint);
String get_error_text();
+ Vector<FilePosition> get_include_positions();
int get_error_line();
ShaderNode *get_shader();